add support of group/groupOfNames/groupOfUniqueNames (#6)

This commit is contained in:
Nikolay Stupak 2019-11-01 16:24:24 +03:00 committed by Kostya Lepa
parent d8c1f4795d
commit 949b123e92
2 changed files with 6 additions and 1 deletions

2
go.mod
View File

@ -19,3 +19,5 @@ require (
gopkg.in/asn1-ber.v1 v1.0.0-20170511165959-379148ca0225 // indirect
gopkg.in/ldap.v2 v2.5.1
)
go 1.13

View File

@ -344,7 +344,10 @@ func (c *ldapConn) SearchUser(user string, attrs ...string) ([]map[string]interf
}
func (c *ldapConn) SearchUserRoles(user string, attrs ...string) ([]map[string]interface{}, error) {
query := fmt.Sprintf("(&(objectClass=group)(member=%s))", user)
query := fmt.Sprintf("(|"+
"(&(|(objectClass=group)(objectClass=groupOfNames))(member=%[1]s))"+
"(&(objectClass=groupOfUniqueNames)(uniqueMember=%[1]s))"+
")", user)
return c.searchEntries(c.RoleBaseDN, query, attrs)
}