I've built an asp.net project which can get the ActiveDirectory user's data .
I had 4 values to get the information :
1.username
2.password
3.DomainName
4.DomainExtension(like com,local,..)
and the company's computers are under WORKGROUP and they just connect to AD server to get the user's info.
this is my code for getting info:
try
{
String Path = "LDAP:// " + DomainName + "." + DomainExt + "/DC=" + DomainName + ",DC=" + DomainExt;
DirectoryEntry Entry = new DirectoryEntry(Path, DomainName + @"\" + Username, Password);
DirectorySearcher search = new DirectorySearcher(Entry);
search.Filter = String.Format("(SAMAccountName={0})", Username);
search.PropertiesToLoad.Add("sn");
SearchResult result = search.FindOne();
Value = (string)result.Properties["sn"][0];
}
catch (Exception ex)
{
return ex.Message;
}
And I've done this successfully at my office local network ... but when I tested it at the company I've got this error :
Logon failure: unknown user name or bad password.
on this <<SearchResult result = search.FindOne();>>
and they can get the user's info with this username and password with some other program .. so there isn't anything wrong with the username and password ..
and I really don't know how to fix it ...