Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am able to authenticate the users using the following code through LDAP. Can anyone please suggest me how to retieve the User Id for the corresponding Username. I wanted to kow how can we query LDAP to retrieve the UserID for the coresponding Username.

C#
try
{
    LdapConnection connection = new LdapConnection("myserver.mycompany.com");
    NetworkCredential credential = new NetworkCredential(textBoxUsername.Text, passwordBox.Password);
    connection.Credential = credential;
    connection.Bind();
    AddData admin = new AddData();

    admin.Show();
    this.Close();
}
catch (LdapException lexc)
{
    String error = lexc.ServerErrorMessage;
    MessageBox.Show("User Authentication Failed! Please Try again.");
}
catch (Exception exc)
{
    MessageBox.Show(Convert.ToString(exc));
}
Posted
Updated 24-Feb-13 19:20pm
v3

1 solution

SELECT userid, username from TableName
 
Share this answer
 

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