Reputation: 1664
I need an LDAP query which returns the single OU in an Active Directory which in turn contains a given username (based on the samAccountName). Is that possible using a single LDAP query to an Active Directory?
Example: User with samAccountName abcd1234 is in OU=HR created under the main AD. I need a query returning the OU including its attributes, the only allowed parameter is the username.
Upvotes: 1
Views: 285
Reputation: 2869
This will require two LDAP queries. One to retrieve the DN of the user, then another that queries for the OU/container of the user based on a portion of the user's DN (minus their RDN). There is no way around it (That I'm familiar with anyway).
Upvotes: 2