LDAP Bind: cannot put multiple attr for user filter #1511

Closed
opened 2025-11-02 04:03:24 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @dolanor on GitHub (Feb 9, 2018).

  • Gitea version (or commit ref): 1.3.2+3-g88c363f
  • Git version:
  • Operating system: docker container in host Ubuntu 16.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

We can only use 1 %s in the LDAP user filter. If we try to match both the uid and the mail, the LDAP won't execute the query and will do nothing but show that it couldn't find the user, if you input both the username or the email.

Hence, a filter like this will work

(&(memberOf=cn=gitea,ou=apps,dc=mydomain,dc=com)(uid=%s))

But not this one

(&(memberOf=cn=gitea,ou=apps,dc=mydomain,dc=com)(|(uid=%s)(mail=%s)))
Originally created by @dolanor on GitHub (Feb 9, 2018). - Gitea version (or commit ref): 1.3.2+3-g88c363f - Git version: - Operating system: docker container in host Ubuntu 16.04 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description We can only use 1 `%s` in the LDAP user filter. If we try to match both the `uid` and the `mail`, the LDAP won't execute the query and will do nothing but show that it couldn't find the user, if you input both the username or the email. Hence, a filter like this will work ``` (&(memberOf=cn=gitea,ou=apps,dc=mydomain,dc=com)(uid=%s)) ``` But not this one ``` (&(memberOf=cn=gitea,ou=apps,dc=mydomain,dc=com)(|(uid=%s)(mail=%s))) ```
GiteaMirror added the type/question label 2025-11-02 04:03:24 -06:00
Author
Owner

@lafriks commented on GitHub (Feb 9, 2018):

Use %[1]s instead of %s than it should work

@lafriks commented on GitHub (Feb 9, 2018): Use `%[1]s` instead of `%s` than it should work
Author
Owner

@dolanor commented on GitHub (Feb 9, 2018):

!!!
Thank you! I forgot about that!

@dolanor commented on GitHub (Feb 9, 2018): !!! Thank you! I forgot about that!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1511