Click here to Skip to main content
15,885,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am working on a website to manage ldap. I am stuck in a situation, when I am trying to authenticate user with account locked or disabled it fails.
What I want to do is first authenticate user after that show message that account locked or disabled.

I am coding like this
C#
LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("SJTPNOC.com", 636));
connection.SessionOptions.VerifyServerCertificate = new VerifyServerCertificateCallback((con, cer) => true);
connection.SessionOptions.ProtocolVersion = 3;        
connection.AuthType = AuthType.Basic;       
connection.SessionOptions.SecureSocketLayer = true;
connection.Timeout = new TimeSpan(0, 0, 10);   
connection.Credential = new NetworkCredential(username, password);
using (connection){
connection.Bind();
}
Posted

1 solution

This won't work. Binding to LDAP server implies a user that can establish connection to the server. A disabled or locked user by definition can't. You will need to use a service account to get into ldap and do the query.
 
Share this answer
 
Comments
mayankkarki 18-Dec-12 8:32am    
Thanks
I have a admin account but with that I can only check username existence but not user password
Zoltán Zörgő 18-Dec-12 8:37am    
Of course. You need to separate these two: with the service account you check if it is locked or disabled, with the user name and password you can validate credentials.
mayankkarki 18-Dec-12 9:21am    
Its not working for change password at next logon also. So without user authentication how I can allow user to change password.
Zoltán Zörgő 18-Dec-12 9:24am    
Ok, let's start from the beginning: what do you want to accomplish exactly? Not how, what?
mayankkarki 18-Dec-12 9:27am    
I am working on a website that allow user to change password. There is a login page in which user enters username and password, and I perform authentication.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900