I have an example result from LDAP like this:
USERID123, Users, UserProvisioning, Production, ztb.icb.company.com
dn: CN=USERID123, ,OU=Users,OU=UserProvisioning,OU=Production,DC=ztb,DC=icb,DC=company,DC=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: user
cn: USERID123
sn: Mueller
c: DE
l: Frankfurt
title: M.Sc.
telephoneNumber: +49 69 136 27289
givenName: Lukas
distinguishedName: CN=USERID123,OU=Users,OU=UserProvisioning,OU=Production,DC=zt
b,DC=icb,DC=company,DC=com
instanceType: 4
whenCreated: 20191023230941.0Z
whenChanged: 20200907052944.0Z
displayName: Mueller, Lukas
uSNCreated: 21302914
memberOf: CN=GG_APP-013979-DQI-KYC-PROD-CONSUMER-GCRR,OU=Groups,OU=UserProvisi
oning,OU=Production,DC=ztb,DC=icb,DC=company,DC=com
memberOf: CN=GG_APP-013479-DQI-KYC-DEV-CONSUMER-GCRR,OU=Groups,OU=UserProvisi
oning,OU=Production,DC=ztb,DC=icb,DC=company,DC=com
memberOf: CN=GG_APP-011479-DQI-KYC-TUD-CONSUMER-GCRR,OU=Groups,OU=UserProvisi
oning,OU=Production,DC=ztb,DC=icb,DC=company,DC=com
I am trying to get all "memberOf" for the User "USERID123" in Python LDAP3.
I tried the following:
if conn.bind():
conn.search(
search_base='OU=Groups,OU=UserProvisioning,OU=Production,DC=ztb,DC=icb,DC=company,DC=com',
search_filter='(objectClass=group)',
search_scope='SUBTREE',
attributes=['memberOf']
)
for entry in conn.entries:
print(entry.memberOf.values)
But I am not able to recreate the query in conn.search to find the "memberOf" for a specific user. How can I do this query to get my desired results in a ldap3 query?
You can see all the values of memberOf in the "example result from LDAP".
If you are really asking for all the groups the user is a Member of then your search would be more like:
Or if using Microsoft Active Directory use this filter: