I want be able to find who is a manager for a specific user. I have no idea of where to start. Please help.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With