How to get a user's OUs

Michael Ströder michael at
Wed Sep 10 09:21:24 CEST 2008

Gustavo Narea wrote:
> On Monday September 8, 2008 23:47:19 you wrote:
>> This question is not very clear. Do you mean the attribute 'ou' of the
>> user's entry or the ou-Container the user's entry is in? If you're
>> working with AD it's probably the latter. Then it's the DN of the user's
>> entry parent entry.
> Thanks for your answer, and sorry for not being clear.
> Say I (dn: uid=gnarea,ou=directors,dc=example,dc=org)

So this is on AD?

> also belong to 
> ou=sysadmins,dc=example,dc=org and ou=betatesters,dc=example,dc=org. How can I 
> get the set of all the Organizational Units I belong to?

What does "also belong to" mean? The user entry
uid=gnarea,ou=directors,dc=example,dc=org being a member of a group
entry? Note that groups are independent from AD's ou-structure.

Regarding the ou-structure gnarea is simply in

> I'm looking for something that if I give the  
> "uid=gnarea,ou=directors,dc=example,dc=org" DN, it returns a tuple/list made 
> up of the items: 'directors', 'sysadmins' and 'betatesters'.

I don't know how your entries ou=sysadmins,dc=example,dc=org and
ou=betatesters,dc=example,dc=org look like.

> I need this because I'm using group-based authentication in my application.
Authorization I guess.

Please make yourself familiar with group entries and how they differ
from ou entries (which are probably not what you want).

Ciao, Michael.

More information about the python-ldap mailing list