-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Hi again / (Re)Bonjour @MrBE4R,
I think the search for members using the DN (Distinguished Name) should be adjusted in this part of the code:

Here are the two reasons why:
1/ You're recreating a filter to find the member, but you're not directly using the "user_filter" parameter set in the config.json.
For example, I’m using JumpCloud, and the class is not "objectClass=user" but "objectClass=jumpcloudUser", which I’ve already defined in the config.json like this:
"user_filter": "(&(objectClass=jumpcloudUser)(memberOf=CN=jc-gitlab-users,ou=Users,o=XXXXXXXXXXX,dc=jumpcloud,dc=com))",
2/ Additionally, you already have the DN (Distinguished Name) to retrieve the user's details. Although I'm a bit of a novice with LDAP, it seems the code should be:
for user_dn, user_data in l.search_s(base=member,
scope=ldap.SCOPE_BASE,
filterstr='(objectClass=*)',
attrlist=['uid', 'mail', 'cn']):
Reference: https://superuser.com/questions/1652940/ldap-filter-to-search-for-a-dn ==> see answer a).
Just FYI, in JumpCloud LDAP, we can’t use answer b) like in your current implementation since it adheres to a apparently more standard LDAP setup.
I still really appreciate the script you made—I'm just trying to modify it to support different LDAP implementations.
Cheers,
Nicolas