mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-02 13:01:23 +01:00
Merge pull request #13621 from stonezdj/201127_fail_to_add_ldap_group
Lowercase the LDAP DN in UnderBaseDN
This commit is contained in:
commit
dec12308a1
@ -434,11 +434,11 @@ func (session *Session) searchGroup(groupDN, filter, gName, groupNameAttribute s
|
||||
|
||||
// UnderBaseDN - check if the childDN is under the baseDN, if the baseDN equals current DN, return true
|
||||
func UnderBaseDN(baseDN, childDN string) (bool, error) {
|
||||
base, err := goldap.ParseDN(baseDN)
|
||||
base, err := goldap.ParseDN(strings.ToLower(baseDN))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
child, err := goldap.ParseDN(childDN)
|
||||
child, err := goldap.ParseDN(strings.ToLower(childDN))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -615,6 +615,12 @@ func TestUnderBaseDN(t *testing.T) {
|
||||
wantError: true,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: `should be case-insensitive`,
|
||||
in: args{"CN=Users,CN=harbor,DC=com", "cn=harbor_group_1,cn=users,cn=harbor,dc=com"},
|
||||
wantError: false,
|
||||
want: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user