Last night while writing function to check User in Active Directory I was getting the error message:” An operations error occurred”. This my code :
Code:
try
{
DirectoryEntry de = new DirectoryEntry("LDAP://myDomain");
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(&(objectClass=user)(sAMAccountName=" + userName + "))";
deSearch.SearchScope = SearchScope.Subtree;
Code:
SearchResult results = deSearch.FindOne(); //-->Error here
if (results != null)
{
return true;
}
return false;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
When I tried to run Localhost it works very well without any error message but although when I connect to other PC I am getting the error. Can anyone please help.
Bookmarks