我有一个来自 LDAP 的示例结果,如下所示:
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
我正在尝试获取 Python LDAP3 中用户“USERID123”的所有“memberOf”。
我尝试了以下方法:
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)
但我无法在 conn.search 中重新创建查询以查找特定用户的“memberOf”。如何执行此查询以在 ldap3 查询中获得我想要的结果?