Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement On Member Search Using DN (Distinguished Name) #12

Open
rouxn-bsi opened this issue Oct 17, 2024 · 0 comments
Open

Improvement On Member Search Using DN (Distinguished Name) #12

rouxn-bsi opened this issue Oct 17, 2024 · 0 comments

Comments

@rouxn-bsi
Copy link

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:
image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant