Dear All,
I have requirement to authenticate my web application using LDAP Authentication against Lotus Notes(Not Active Directory).
Besides get list of user from LDAP. I am able to get list of users from LDAP using following class
LdapConnection
SearchRequest
SearchResponse
SearchResultEntryCollection
But I don't know how to authenticate user with LDAP Password. I am able to validate only user id.
whether password can be taken?
How to find what encryption they have used.
Kindly guide me on the same.
many suggest following code, but it is not validating the users' password rather it does only user alone. Password given in the code is used for binding with LDAP Directory.
public bool IsAuthenticated(string domain, string username, string pwd){
string domainAndUsername = domain + @"\" + username;
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
try
{
//Bind to the native AdsObject to force authentication.
object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if(null == result)
{
return false;
}
//Update the new path to the user in the directory.
_path = result.Path;
_filterAttribute = (string)result.Properties["cn"][0];
}
catch (Exception ex)
{
throw new Exception("Error authenticating user. " + ex.Message);
}
return true;
}
With Regards
Palanivelrajan