func (u *UserInfoLDAPSource) GetgroupsofUser(username string) ([]string, error) {
	conn, err := u.getTargetLDAPConnection()
	if err != nil {
		log.Println(err)
		return nil, err
	}
	defer conn.Close()

	searchRequest := ldap.NewSearchRequest(
		u.GroupSearchBaseDNs,
		ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
		"(&(memberUid="+username+" ))",
		[]string{"cn"}, //memberOf (if searching other way around using usersdn instead of groupdn)
		nil,
	)
	sr, err := conn.Search(searchRequest)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	groups := []string{}
	for _, entry := range sr.Entries {
		groups = append(groups, entry.GetAttributeValue("cn"))
	}
	return groups, nil
}
// GetGroupsOfUser returns the all groups of a user. --required
GetGroupsOfUser returns the all groups of a user. --required
// GetGroupsOfUser returns the all groups of a user . -- required
func (u *UserInfoLDAPSource) GetgroupsofUser(username string) ([]string, error) {
	conn, err := u.getTargetLDAPConnection()
	if err != nil {
		log.Println(err)
		return nil, err
	}
	defer conn.Close()
	searchRequest := ldap.NewSearchRequest(
		u.GroupSearchBaseDNs,
		ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
		"(&(memberUid="+username+" ))",
		[]string{"cn"}, 
		nil,
	)
	sr, err := conn.Search(searchRequest)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	groups := []string{}
	for _, entry := range sr.Entries {
		groups = append(groups, entry.GetAttributeValue("cn"))
	}
	return groups, nil
}
func ( u * UserInfoLDAPSource ) GetgroupsofUser ( username string ) ( [ ] string , error ) { conn , err := u . getTargetLDAPConnection ( ) if err != nil { log . Println ( err ) return nil , err } defer conn . Close ( ) searchRequest := ldap . NewSearchRequest ( u . GroupSearchBaseDNs , ldap . ScopeWholeSubtree , ldap . NeverDerefAliases , 0 , 0 , false , " " + username + " " , [ ] string { " " } , nil , ) sr , err := conn . Search ( searchRequest ) if err != nil { log . Println ( err ) return nil , err } groups := [ ] string { } for _ , entry := range sr . Entries { groups = append ( groups , entry . GetAttributeValue ( " " ) ) } return groups , nil }
GetGroupsOfUser returns the all groups of a user.
GetGroupsOfUser returns the all groups of a user .
//memberOf (if searching other way around using usersdn instead of groupdn)