In our corporate LDAP structure a 'user' has two attributes:
uid = the id of the user
manager = the DN of the user's manager
Since I'm writing a script to find out the organization chain for a user, I'd like to be able to find the uid of a manager with a single query. Right now, I have to do it in 2 queries:
$ ldapsearch -h ldap.example.com -p 389 -b dc=example,dc=com uid=myuid manager
dn: cn=mycn,L=AMER,DC=EXAMPLE,DC=COM
manager: cn=mymanagercn,L=AMER,DC=EXAMPLE,DC=COM
Parse out the cn value 'mymanagercn', then run another query:
$ ldapsearch -h ldap.example.com -p 389 -b dc=example,dc=com cn=mymanagercn uid
dn: cn=mymanagercn,L=AMER,DC=EXAMPLE,DC=COM
uid: mymanageruid
Is there a way to do this with 1 query? Bonus points if you can do this using the Net::LDAP Perl modules!