Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 LDAP
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.
 
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 24-Feb-13 18:47pm
Edited 24-Feb-13 19:20pm
SoMad128.1K
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

SELECT userid, username from TableName
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.141022.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100