Hi All,
I have a web service method which works fine when called from my local
machine i.e. from localhost but when I publish the web services to a remote
machine it throws an invalid cast soap exception.
That web service method access Active Directory to get the group names for
the given user. Following is the code.
DirectorySearch er dirSearcher = new DirectorySearch er();
dirSearcher.Fil ter = String.Format(" (cn={0})", strCommonName);
dirSearcher.Pro pertiesToLoad.A dd("MemberOf") ;
SearchResult result = dirSearcher.Fin dOne();
string group = (string)result. Properties["memberOf"][0]
It's the last line where it throws an exception,
Unable to cast object of type 'System.Byte[]' to type 'System.String' .
And this happens only when I try to use the web service method from the
remote server. It works fine when used from my local machine.
Using VS .NET 2005 to develop the web services.
The remote server is a 64 bit Windows XP machine running VS.NET 2005 runtime.
Thanks for any help!
Abhi 4 4805
"Abhi" <Ab**@discussio ns.microsoft.co mwrote in message
news:29******** *************** ***********@mic rosoft.com...
Hi All,
I have a web service method which works fine when called from my local
machine i.e. from localhost but when I publish the web services to a
remote
machine it throws an invalid cast soap exception.
That web service method access Active Directory to get the group names for
the given user. Following is the code.
DirectorySearch er dirSearcher = new DirectorySearch er();
dirSearcher.Fil ter = String.Format(" (cn={0})",
strCommonName);
dirSearcher.Pro pertiesToLoad.A dd("MemberOf") ;
SearchResult result = dirSearcher.Fin dOne();
string group = (string)result. Properties["memberOf"][0]
It's the last line where it throws an exception,
Unable to cast object of type 'System.Byte[]' to type 'System.String' .
So, why is it returning System.Byte[]? What's in that byte array?
I suspect that memberOf has a different meaning to your local machine than
it does to your server.
John
John,
You might be right becasue I chnaged my code to accept a byte array and then
convert it to a string as follows,
byte[] byteArray =
(byte[])result.Propert ies["memberOf"][counter];
string group = "";
foreach (byte t in byteArray)
{
char c = Convert.ToChar( t);
group += c.ToString();
}
and it works fine on the remote server but fails! on my machine throwing an
exception which say unavble to convert a string to byte[].
And to answer your question that byte array converted to string gives me the
group name.
How can I make it work on both machines?
Thanks,
Abhi
"John Saunders" wrote:
"Abhi" <Ab**@discussio ns.microsoft.co mwrote in message
news:29******** *************** ***********@mic rosoft.com...
Hi All,
I have a web service method which works fine when called from my local
machine i.e. from localhost but when I publish the web services to a
remote
machine it throws an invalid cast soap exception.
That web service method access Active Directory to get the group names for
the given user. Following is the code.
DirectorySearch er dirSearcher = new DirectorySearch er();
dirSearcher.Fil ter = String.Format(" (cn={0})",
strCommonName);
dirSearcher.Pro pertiesToLoad.A dd("MemberOf") ;
SearchResult result = dirSearcher.Fin dOne();
string group = (string)result. Properties["memberOf"][0]
It's the last line where it throws an exception,
Unable to cast object of type 'System.Byte[]' to type 'System.String' .
So, why is it returning System.Byte[]? What's in that byte array?
I suspect that memberOf has a different meaning to your local machine than
it does to your server.
John
"Abhi" <Ab**@discussio ns.microsoft.co mwrote in message
news:09******** *************** ***********@mic rosoft.com...
John,
You might be right becasue I chnaged my code to accept a byte array and
then
convert it to a string as follows,
byte[] byteArray =
(byte[])result.Propert ies["memberOf"][counter];
string group = "";
foreach (byte t in byteArray)
{
char c = Convert.ToChar( t);
group += c.ToString();
}
and it works fine on the remote server but fails! on my machine throwing
an
exception which say unavble to convert a string to byte[].
And to answer your question that byte array converted to string gives me
the
group name.
How can I make it work on both machines?
This is not a web services question any more. The question is, "why is
memberOf different on these two machines and how can I make it the same or
at least make it look like it's the same".
John
Yep, this no longer remains a web service question. Initially I thought it's
the WSDL playing some tricks and not interpreting the returned object
correctly but that doesn't seems to be the case. I don't know a whole lot
about Active Directory or LDAP. Please let me know if there is a similar
discussion forum for active directory services so I can post the right
question.
Thanks for your help
-Abhi
"John Saunders" wrote:
"Abhi" <Ab**@discussio ns.microsoft.co mwrote in message
news:09******** *************** ***********@mic rosoft.com...
John,
You might be right becasue I chnaged my code to accept a byte array and
then
convert it to a string as follows,
byte[] byteArray =
(byte[])result.Propert ies["memberOf"][counter];
string group = "";
foreach (byte t in byteArray)
{
char c = Convert.ToChar( t);
group += c.ToString();
}
and it works fine on the remote server but fails! on my machine throwing
an
exception which say unavble to convert a string to byte[].
And to answer your question that byte array converted to string gives me
the
group name.
How can I make it work on both machines?
This is not a web services question any more. The question is, "why is
memberOf different on these two machines and how can I make it the same or
at least make it look like it's the same".
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe |
last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located.
When trying to add a web reference to a C# project I get an error message
'There was an error downloading 'http://mydomain.com:port/webservice.asmx'
The operation has timed-out
(I've tried with and without using a separate port for the service)
The weird thing is the page does show up on the left side of the screen
listing the available methods but the Add...
|
by: felecha |
last post by:
I'm working on a system that has a several computers that run an
alerting system. There are 2 "Host" machines that have no user
interface, and one "Admin" station that has an Administrator's
application for configuring and reporting. They are on a simple
local network, just the 3 machines, no wider access.
We do a certain amount of communication between them, using UDP and
MessageQueueing and also in one instance a VB.Net Windows Forms...
|
by: Evan Camilleri |
last post by:
I have a problem for a Windows Service to login on an SQL server (different
machine) - neither Windows Authentication nor SQL Authentication worked.
LOGIN FAILED FOR USER sa (for example).
If SQL Server is on the same PC of the Windows Service the connection works
OK.
The same code works in a Windows Form using same user and authentication
methods to the SQL Server on a different machine.
|
by: Manfred Braun |
last post by:
Hello All!
I am writing a management application, which has to access remote machines
registry via System.Diagnostics.EventLog.CreateEventSource .
For each machine, I connect to, I create a DirectoryEntry and connect to
that machine specifying credentials. That's becauase the running user does
not has the right permissions .
The application is written in C# and the action taken is done with threads
from the threadpool.
|
by: David Laub |
last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be
an integration issue, this may be the better place to posr:
I have written a dot net/c# Web Services doesn't fully work with J2ME client
a) c# web service works with c# WIndows Client (local & remote web service)
b) c# web service works with J2ME client - when the Web Service is local
c) c# web service fails with J2ME client - when the Web Service is remote
...
| |
by: RdS |
last post by:
Hello,
I use sourcesafe and vb 2003 for my dev environment. on the sourcesafe
server I also have sql2005 and reporting services installed. The web app
references this sql server for db. When I compile the app on my local
machine which is used for development I am able to lauch application with no
problem. When I run my web app on my local machine which uses my IIS 5
(WinXP Pro) the application runs fine. But if I connect to server...
|
by: JamesB |
last post by:
I am writing a service that monitors when a particular app is started.
Works, but I need to get the user who is currently logged in, and of course
Environment.UserName returns the service logon (NT_AUTHORITY\SYSTEM).
I understand that when the service starts, no user may be logged in, but
that's ok, as the app I am monitoring can only be run by a logged in user.
Do I need to use WMI to get the user context of Explorer.exe or is there a...
|
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= |
last post by:
我们现在遇到一个问题,通过wcf创建的webservice,选择windows
service作为宿主,采用java作为客户端调用成功,但是无法使用asp.net ajax调用。
我们参考了http://msdn.microsoft.com/zh-cn/library/bb410780.aspx的资料,并且下载了相应的sample
code,但是发现这些sample基本上都需要在iis上部署一个svc文件,但是根据当前业务需求,我们无法部署iis服务器。...
|
by: Scott |
last post by:
Attempting to install WCF service on stand alone 2003 server as a admin user
(not administrator but user "WCF" i.e user added to local admin group). It
fails with user error:
The description for Event ID ( 11001 ) in Source ( MsiInstaller ) cannot be
found. The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. You may be
able to use the /AUXSOURCE= flag to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |