Hello, Im trying to see if a user exists in active directory. The
code I have has been posted elsewhere and apparantly works for
others....but it will not work for me. I get the error: "The
specified domain either does not exist or could not be contacted."
Can anyone please help me? Im completely lost here.
Here is the code (roughly the same code works when I create it in
vbs):
string LDAPPath = "LDAP://DC=mydomain,DC=mydc,DC=mydc2,DC=mydc3,DC=com";
DirectoryEntry de = new DirectoryEntry();
de.Path = LDAPPath.ToString();
DirectorySearcher searcher = new DirectorySearcher();
searcher.SearchRoot = de;
searcher.Filter = "(name=clfield)";
searcher.PageSize = 10;
searcher.SearchScope = SearchScope.Subtree;
searcher.PropertiesToLoad.Add("name");
searcher.PropertiesToLoad.Add("userAccountControl" );
SearchResultCollection results = searcher.FindAll();
string szTest = "";
foreach(SearchResult result in results)
{
szTest = result.Properties["name"][0].ToString();
}
Thanks - B. Rubble