This commit is contained in:
8
main.go
8
main.go
@@ -91,6 +91,10 @@ func GetGroupsOfUser(username string, baseDN string, conn *ldap.Conn) ([]string,
|
||||
|
||||
sr.PrettyPrint(2)
|
||||
|
||||
for _, entry := range sr.Entries {
|
||||
entry.PrettyPrint(2)
|
||||
}
|
||||
|
||||
/*
|
||||
userdn := sr.Entries[0].DN
|
||||
fmt.Printf("userdn is '%s' from CN '%s'", userdn, samAccountName)
|
||||
@@ -99,7 +103,7 @@ func GetGroupsOfUser(username string, baseDN string, conn *ldap.Conn) ([]string,
|
||||
baseDN,
|
||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
fmt.Sprintf("(memberUid=%s)", userdn),
|
||||
[]string{"cn"}, // can it be something else than "cn"?
|
||||
[]string{}, // can it be something else than "cn"?
|
||||
nil,
|
||||
)
|
||||
sr, err = conn.Search(searchRequest)
|
||||
@@ -107,13 +111,11 @@ func GetGroupsOfUser(username string, baseDN string, conn *ldap.Conn) ([]string,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
for _, entry := range sr.Entries {
|
||||
fmt.Println(entry.GetAttributeValue("cn"))
|
||||
groups = append(groups, entry.GetAttributeValue("cn"))
|
||||
}
|
||||
*/
|
||||
|
||||
return groups, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user