I am attempting to use LDAP to retrieve a list of users from within a web
service. When the FindAll() method is invoked, I receive the following
exception: "The specified domain either does not exist or could not be
contacted."
The code that does not work from within the web service works fine from
within a Windows forms application, so my first guess is that the issue is
security related.
Any ideas on how to use LDAP from within a web service?
Thanks for your help.
Chris
Here is the relevant code from the web service:
DirectorySearcher ds = new DirectorySearcher();
ds.SearchRoot = new DirectoryEntry(""); // start searching from local domain
ds.Filter = String.Format("(&(objectCategory=user)(name={0}))" ,
txtUserName.Text);
ds.PropertyNamesOnly = true;
ds.PropertiesToLoad.Add("name");
ds.PropertiesToLoad.Add("SAMAccountName");
ds.SearchScope = SearchScope.Subtree;
ds.CacheResults = false;
ds.ReferralChasing = ReferralChasingOption.None;
ds.Sort = new SortOption("name", SortDirection.Ascending);
// start searching
SearchResultCollection src = ds.FindAll();