I am currently using Directory Searcher for Authenticating user against AD.
DirectoryEntry adsEntry = new DirectoryEntry(ConfigurationManager.AppSettings["ADConnectionString"], username, password, System.DirectoryServices.AuthenticationTypes.Secure);
DirectorySearcher adsSearcher = new DirectorySearcher(adsEntry);
adsSearcher.Filter = "(sAMAccountName=" + _userName + ")";
SetPropertiesToLoad(ref adsSearcher);
SearchResult adsSearchResult = adsSearcher.FindOne();
Logger.Debug("After adsSearcher.FindOne() success");
if (!ExtractPropertiesReceivedFromAD(adsSearchResult, ref emailAddress, ref _name, username, ref errorMessage))
return false;
This is working fine for many of the AD setups, but recently i encountered that 1 of the AD doesnt allow connection to it.
My client says they have LDAP Authentication in place, so i can't directly query to AD without supplying Service Account credentials.
So in this case to connect with AD using LDAP i need 1 credentials, and post that to validate user identity i need his own username/password.
Now how can i accommodate such situation in DirectorySearcher?