python : ldap where clause -


conn=ldap.initialize('ldap://ldap.server.com:389') results=conn.search_s('ou=active,ou=infra,o=company', ldap.scope_subtree,'uid=bob')  results=[('uid=bob,ou=active,ou=infra,o=company', {'telephonenumber': [''], 'cn': ['bob bensen (bob)'], 'uidnumber': ['123'], 'manager': ['cn=andy home (ahome),ou=sector,ou=dept,o=company'])]  results[0][1]['manager']  ---> ['cn=andy home (ahome),ou=sector,ou=dept,o=company'] 

how uid of users in 'ou=active,ou=infra,o=company' manager's cn = ahome?

change last part of line, filter from:

results = conn.search_s('ou=active,ou=infra,o=company', ldap.scope_subtree,'uid=bob') 

to like:

results = conn.search_s(     'ou=active,ou=infra,o=company',     ldap.scope_subtree,     'manager=cn=andy home (ahome),ou=sector,ou=dept,o=company' ) 

note manager attribute stores full dn of manager object, it's not enough specify ahome. may need look-up dn first before doing search (it should first item of each ldap result).


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -