views:

309

answers:

2

Using Active Directory, am trying to find the SamAccountName and email of the user’s manager.

I find the logged on user in the AD by search where sAMAccountName = Domain\Account. I then retrieve the manager property, which looks like this, for example:

"CN=Doe\, Jane E.,OU=Employees,OU=Users,OU=Detroit,OU=United States,DC=na,DC=gmc,DC=gmc,DC=com"

How can I use this presumed key to find the user record for this person? What field would I match on?

+1  A: 

The entry for the manager is the manager's Binding String. You can feed it back into a request to active directory by binding it to an object that will return the manager's information.

Dan Monego
+1  A: 

If I remember correctly, that is their Distinguished Name, which means you can use it as the direct reference to their profile

LDAP://CN=Doe, Jane E.,OU=Employees,OU=Users,OU=Detroit,OU=United States,DC=na,DC=gmc,DC=gmc,DC=com

I also think it will return that name if the profile exists. If it has been deleted then I believe it runs a GUID of some sort (based on memory - this might be incorrect)

Hugoware