Hi all,
We have a windows application built on .Net Framework 4.7.2. In this application, we try to authenticate a user using LDAP authentication. When we try to authenticate a user, it says authentication failed.
We have another third party application which also authenticates using LDAP. If we use the same credentials that we used for the windows application (mentioned above), authentication succeeds.
There is one difference between the windows application and the third party application. The third party application makes use of 'Bind Password' which is not used in the windows application.
So the question is, what is the use of this 'Bind Password' which is provided in addition to the user credentials. Does anybody know as to how to use this 'Bind Password'??
Any help is appreciated!!
private string AuthenticateUser(string username, string password, ref SearchResultEntry results)
{
string errorMessage = string.Empty;
System.DirectoryServices.Protocols.LdapConnection ldapConnection = null;
try
{
// Create the new LDAP connection
LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier(Convert.ToString(CoreData.SnmpcToolkit.LdapServerIPAddress), 389);
ldapConnection = new System.DirectoryServices.Protocols.LdapConnection(ldi);
ldapConnection.AuthType = AuthType.Basic;
NetworkCredential nc = new NetworkCredential("CN=" + username + "," + CoreData.SnmpcToolkit.LdapDistinguishedName, password);
ldapConnection.Timeout = new TimeSpan(0, 0, 20);
ldapConnection.Bind(nc);
SearchRequest request = new SearchRequest(CoreData.SnmpcToolkit.LdapDistinguishedName, "(sAMAccountName=" + username + ")", System.DirectoryServices.Protocols.SearchScope.Subtree);
SearchResponse response = (SearchResponse)ldapConnection.SendRequest(request);
if (response.Entries.Count == 1)
{
results = response.Entries[0];
}
}
catch (Exception ex)
{
errorMessage = ex.Message;
}
return errorMessage;
}
Thank you in advance!!