Saturday, March 24, 2012

Web service problem

Hi all,

I have another question regarding webservices. I have one set up to access the active directory. As a test i have put in the following code as a method to see if it works.

[WebMethod(Description="Test function to test AD access")]
public string testFunction(string username, string pwd)
{
string testStr = string.Empty;
DirectoryEntry de = new DirectoryEntry("LDAP://DC=optos,DC=eye" ,username ,pwd);
foreach(DirectoryEntry child in de.Children)
{
testStr = testStr + "<BR>" + child.Name.ToString();
}

return testStr;
}

I have a similar piece of code on the form where i call the web service for, and this is where the problem lies.

The code runs fine on the form which calls the web service. When i call the web service however i get the following error:

<i>"Server was unable to process request. --> The specified domain either does not exist or could not be contacted"</i>

The security on the main form is set to impersonate=true and anonymous access has been removed from the IIS properties for the app. On the web service, again impersonte=true but this time anonymous is checked. When it is unchecked i get Access denied errors.

Does anyone have any ideas why this is happening.

Thanks,

GrantWeb services don't run under the context of the logged in user. They run under the context of the caller. This means that you will need to pass credentials to the web service.

http://support.microsoft.com/default.aspx?scid=kb;en-us;813834
Hi Mendhak,

That was a seriously quick response, thank you.

I'll look over the link and see if i can't get something working. I'll post back either way to let you know.

Cheers

Grant
Thanks Mendhak, that worked perfectly.

0 comments:

Post a Comment