-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Can't filter groups in Windows Active Directory (LDAP BindDN Authentication) #23615
Comments
Analyzing the listLdapGroupMemberships function code it have a boolean value to apply a group filter, the docs explain about that group filter, but this filter isn't present in the UI to set. |
Found the problem... The bool value is WRONG when there is no text in the UI field |
Workaround: set "Verify group membership in LDAP" to |
I was using |
Do you mean that: gitea/services/auth/source/ldap/source_search.go Lines 211 to 213 in 22fec16
should actually be: if applyGroupFilter && groupFilter != "" {
searchFilter = fmt.Sprintf("(&(%s)(%s=%s))", groupFilter, source.GroupMemberUID, ldap.EscapeFilter(uid))
} else { If so does the below patch solve the problem? PATCHdiff --git a/services/auth/source/ldap/source_search.go b/services/auth/source/ldap/source_search.go
index 5a2d25b0c..2a61386ae 100644
--- a/services/auth/source/ldap/source_search.go
+++ b/services/auth/source/ldap/source_search.go
@@ -208,7 +208,7 @@ func (source *Source) listLdapGroupMemberships(l *ldap.Conn, uid string, applyGr
}
var searchFilter string
- if applyGroupFilter {
+ if applyGroupFilter && groupFilter != "" {
searchFilter = fmt.Sprintf("(&(%s)(%s=%s))", groupFilter, source.GroupMemberUID, ldap.EscapeFilter(uid))
} else {
searchFilter = fmt.Sprintf("(%s=%s)", source.GroupMemberUID, ldap.EscapeFilter(uid))
|
…is non-empty When running listLdapGroupMemberships check if the groupFilter is empty before using it to list memberships. Fix go-gitea#23615 Signed-off-by: Andrew Thornton <art27@cantab.net>
… is empty (go-gitea#23745) When running listLdapGroupMemberships check if the groupFilter is empty before using it to list memberships. Fix go-gitea#23615 Signed-off-by: Andrew Thornton <art27@cantab.net>
Hi, So I am having the exact same issue, except the workaround to populate the 'Verify group membership in LDAP' stops my LDAP search altogether. If I leave it blank I get the error described in this issue. This is the debug with the field populated Git Version Gitea Version |
Description
I'm trying to automate the organization and teams grouping with my LDAP authentication (Authentication is working fine) but the configuration to add Users to groups do not work.
Log states that the filter failed:
2023/03/21 11:17:21 ...dap/source_search.go:228:listLdapGroupMemberships() [E] [6419bc71] Failed group search in LDAP with filter [(&()(member=CN=User Teste,CN=Users,DC=agst,DC=com,DC=br))]: LDAP Result Code 201 "Filter Compile Error": ldap: error parsing filter
For what i see that empty
&()
in the filter start is the problem, i can't see any way to remove it in the UI.If i search only (member=CN=User Teste,CN=Users,DC=agst,DC=com,DC=br) manually the groups are displayed correctly.
Gitea Version
1.19.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
Git Version
2.39.1.windows.1
Operating System
Windows Server 2022 (20348.803)
How are you running Gitea?
AMD64 Binary From Git Releases Page
Database
SQLite
The text was updated successfully, but these errors were encountered: