locked
Authenticate user in LDAP RRS feed

  • Question

  • Hi,
    I have a directory in structure like
    ou=system,ou=valeteck,cn=mayank

    Now their is username and password for system. CN 'mayank' has password also.
    Now I have to authenticate 'mayank' by checking username and password.

    I am creating a directoryentry object with domain of system and its username and password. Used a search filter to get mayank and then access its password to validate but its not working.
    Monday, August 13, 2012 1:54 PM

All replies

  • Hi Mayank,

    Welcome to the MSDN Forum.

    What program language do you use? What version of VS do you use? 

    What is the related code and the exception messages or error messages?

    Would you like to provide more information about this issue for us? Thank you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 14, 2012 3:15 AM
  • Hi,

    I have a directory structure like

    cn=mayank,ou=valeteck,ou=system

    ou=system is password protected and user 'mayank' also has value in userPassword property.

    If I am coding like this using username and password of 'mayank' I get error of "Bad username or password"

    DirectoryEntry dEntry=new DirectoryEntry("ldap://localhost:389/cn=mayank,ou=valeteck,ou=system","cn=mayank","password");

    Not get any result. but if I provide username and password of system I get object but the question is same how to check userPassword property beacuse the value it return in hashed format.

    • Merged by Mike Feng Friday, August 17, 2012 5:51 AM duplicate
    Thursday, August 16, 2012 7:23 AM
  • Hi,

    I have a directory structure like

    cn=mayank,ou=valeteck,ou=system

    ou=system is password protected and user 'mayank' also has value in userPassword property.

    If I am coding like this using username and password of 'mayank' I get error of "Bad username or password"

    DirectoryEntry dEntry=new DirectoryEntry("ldap://localhost:389/cn=mayank,ou=valeteck,ou=system","cn=mayank","password");

    Not get any result. but if I provide username and password of system I get object but the question is same how to check userPassword property beacuse the value it return in hashed format.

    Friday, August 17, 2012 5:39 AM
  • Hi Mayank,

    First, try to pass the username just "mayank", not "cn=mayank".

    If it doesn't work, please try to access "system" level by level. I mean this :

    DirectoryEntry myBankEntry=new DirectoryEntry("ldap://localhost:389/cn=mayank","mayank","password");
    DirectoryEntry SystenEntry=myBankEntry.Children.Find("ou=system");

    Here is sample about find method:http://msdn.microsoft.com/en-us/library/39zxbb5w.aspx 

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 17, 2012 6:09 AM
  • Thanks for reply,

    First thing I want to tell you that I am using apache server.

    I just want to check that password entered by the user is matched with 'mayank' userPassword property. 

    I just find out that for whole directory there is admin level user and authentication parameters and I can authenticate to directory only by using them.

    Currently  I easily get authenticate to it and also get object of 'mayank' but 'userPassword' property is hashed so I unable to match it with user input value.

    Friday, August 17, 2012 6:50 AM