Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding Manager for LDAP user

I want be able to find who is a manager for a specific user. I have no idea of where to start. Please help.

like image 244
Amarnauth Persaud Avatar asked Sep 14 '25 02:09

Amarnauth Persaud


1 Answers

You need to know what your LDAP path is for your user - if you have no idea, you might want to download my LDAP browser BeaverTail.

enter image description here

Once you know what your user's LDAP path looks like, it's pretty easy: bind to that user by means of its LDAP path, and grab it's Manager property:

DirectoryEntry deUser = new DirectoryEntry("LDAP://cn=John Doe,cn=Users,dc=YourCorp,dc=com");

if(deUser != null)
{
   // check if the manager property is set - it could be NULL (no manager defined)
   if(deUser.Properties["manager"] != null)
   {
      string managerDN = deUser.Properties["manager"][0].ToString();
   }
}

That Manager property again contains a "distinguished name" (DN) - i.e. an LDAP path - for the manager's DirectoryEntry.

like image 170
marc_s Avatar answered Sep 15 '25 17:09

marc_s