Using python ldap3, getting memberof by userid

512 views Asked by At

Can someone help me out with a search for memberof by cn = 'userid' ?

this is what I have so far:

c.search( search_base='DC=ms,DC=ds,DC=company,DC=com',
            search_filter='(CN=userid)',
            search_scope='SUBTREE',
            attributes=['memberOf']) 
1

There are 1 answers

0
Riyas On BEST ANSWER
c.search(search_base='DC=ms,DC=ds,DC=company,DC=com',
         search_filter=('(sAMAccountName={0})').format(usrname),
         search_scope=SUBTREE,
         attributes=['cn', 'displayName', 'mail','member'])

The above worked for me.

Also you can refer this url as well. Good luck.