Click here to Skip to main content
12,451,896 members (67,560 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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
Updated 24-Feb-13 19:20pm
SoMad161.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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2016
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