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

add a ldap_scope parameter #921

Closed
tdm4 opened this issue Jun 24, 2024 · 4 comments · Fixed by #939
Closed

add a ldap_scope parameter #921

tdm4 opened this issue Jun 24, 2024 · 4 comments · Fixed by #939
Assignees
Milestone

Comments

@tdm4
Copy link

tdm4 commented Jun 24, 2024

Hi,

I need a way of setting the LDAP search filter to use SCOPE = one (instead of subtree). Is this possible? Our setup looks like this:

ou=people
      |
       -  cn=user1
       -  cn=user2
       ...
       |
       - ou=deactivated
           |
           - cn=user3
           - cn=user4

Having scope=one would only search and find users like user1 and user2 but would exclude 'user3' and 'user4.

It seems the LDAP search doesn't work despite trying modifiers like NOT (!(ou=deactivated))

Any ideas on how this could be achieved?

Thanks,
Tom

@davidcoutadeur
Copy link

Hello,

It seems that ldap_search is missing the scope parameters. Any search is done with sub scope.

See: https://www.php.net/manual/en/function.ldap-search.php

You could replace ldap_search by ldap_list, which is doing exactly what you want, but it wouldn't be convenient for the software maintenance.

Maybe we could have a selector for choosing the right function (ldap_list, ldap_search or ldap_read), given a scope parameter, but it's quite a work.

@coudot
Copy link
Member

coudot commented Jun 24, 2024

Yes, selecting the scope could be a new feature

If you are using OpenLDAP, you can use extended filter matching:

(!(ou:dn:=deactivated))

@tdm4
Copy link
Author

tdm4 commented Jun 26, 2024

Yes, selecting the scope could be a new feature

If you are using OpenLDAP, you can use extended filter matching:

(!(ou:dn:=deactivated))

Thanks! That did the trick!
Worth noting... if you have more than one OU group under there, you can AND the NOTs like so:

$ldap_filter = "(&(objectClass=person)($ldap_login_attribute={login})(!(ou:dn:=deactivated))(!(ou:dn:=disabled)))";

(for example)

@davidcoutadeur
Copy link

davidcoutadeur commented Jul 10, 2024

Done in #939

Don't forget to update composer dependency: "ltb-project/ltb-common": "dev-main" to the correct version when released. (0.3.0)

@davidcoutadeur davidcoutadeur changed the title Is it possible to use a search scope other than subtree? add a ldap_scope parameter Jul 10, 2024
@davidcoutadeur davidcoutadeur self-assigned this Jul 10, 2024
davidcoutadeur pushed a commit that referenced this issue Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants