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,D C=mydc3,DC=com" ;
DirectoryEntry de = new DirectoryEntry( );
de.Path = LDAPPath.ToStri ng();
DirectorySearch er searcher = new DirectorySearch er();
searcher.Search Root = de;
searcher.Filter = "(name=clfield) ";
searcher.PageSi ze = 10;
searcher.Search Scope = SearchScope.Sub tree;
searcher.Proper tiesToLoad.Add( "name");
searcher.Proper tiesToLoad.Add( "userAccountCon trol");
SearchResultCol lection results = searcher.FindAl l();
string szTest = "";
foreach(SearchR esult result in results)
{
szTest = result.Properti es["name"][0].ToString();
}
Thanks - B. Rubble
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,D C=mydc3,DC=com" ;
DirectoryEntry de = new DirectoryEntry( );
de.Path = LDAPPath.ToStri ng();
DirectorySearch er searcher = new DirectorySearch er();
searcher.Search Root = de;
searcher.Filter = "(name=clfield) ";
searcher.PageSi ze = 10;
searcher.Search Scope = SearchScope.Sub tree;
searcher.Proper tiesToLoad.Add( "name");
searcher.Proper tiesToLoad.Add( "userAccountCon trol");
SearchResultCol lection results = searcher.FindAl l();
string szTest = "";
foreach(SearchR esult result in results)
{
szTest = result.Properti es["name"][0].ToString();
}
Thanks - B. Rubble
Comment