Search for LDAP_MATCHING_RULE_IN_CHAIN groups

Signed-off-by: Yann David <davidyann88@gmail.com>
This commit is contained in:
Yann David 2019-07-23 12:17:54 -04:00
parent d38a08b15a
commit 51eb8bc60f
No known key found for this signature in database
GPG Key ID: B005C1919206F2E0

View File

@ -220,6 +220,22 @@ func (session *Session) SearchUser(username string) ([]models.LdapUser, error) {
}
u.GroupDNList = groupDNList
}
log.Debugf("Searching for nested groups")
nestedGroupDNList := []string{}
nestedGroupFilter := createNestedGroupFilter(ldapEntry.DN)
result, err := session.SearchLdap(nestedGroupFilter)
if err != nil {
return nil, err
}
for _, groupEntry := range result.Entries {
nestedGroupDNList = append(nestedGroupDNList, strings.TrimSpace(groupEntry.DN))
log.Debugf("Found group %v", groupEntry.DN)
}
u.GroupDNList = append(u.GroupDNList, nestedGroupDNList...)
log.Debugf("Done searching for nested groups")
u.DN = ldapEntry.DN
ldapUsers = append(ldapUsers, u)
@ -419,3 +435,9 @@ func createGroupSearchFilter(oldFilter, groupName, groupNameAttribute string) st
}
return filter
}
func createNestedGroupFilter(userDN string) string {
filter := ""
filter = "(&(objectClass=group)(member:1.2.840.113556.1.4.1941:=" + userDN + "))"
return filter
}