I an facing problem while changing password in active directory.. when i run the code it goes in get user function n returns null value.. why is it happening.. can anybody through some light on this..
thanks in advance
private DirectoryEntry GetDirectoryObject()
{
DirectoryEntry oDE;
oDE = new DirectoryEntry("LDAP://192.168.11.9","Administrator","asd12!@", AuthenticationTypes.Secure);
return oDE;
}
private DirectoryEntry GetUser(string ADUser)
{
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = "(&(objectClass=user)(SAMAccountName=" + ADUser + "))";
deSearch.SearchScope = SearchScope.Subtree;
SearchResult results = deSearch.FindOne();
if (!(results == null))
{
de = new DirectoryEntry(results.Path, "Administrator", "asd12!@", AuthenticationTypes.Secure);
return de;
}
else
{
return null;
}