//GroupInfoByField used to retrieve the information of a given group cn, but use a given field to make the search.
GroupInfoByField used to retrieve the information of a given group cn, but use a given field to make the search.
// GroupInfoByField used to retrieve the information of a given group cn but use a given field to make the search .
func (lc *HelperLDAP) GroupInfoByField(groupname string, fieldForUnicValue string) (map[string]interface{}, liberr.Error) {
	var (
		err     liberr.Error
		src     *ldap.SearchResult
		grpInfo map[string]interface{}
	)
	src, err = lc.runSearch(fmt.Sprintf(lc.config.FilterGroup, fieldForUnicValue, groupname), []string{})
	if err != nil {
		return grpInfo, err
	}
	if len(src.Entries) == 0 {
		return nil, ErrorLDAPGroupNotFound.Error(nil)
	}
	grpInfo = make(map[string]interface{}, len(src.Entries[0].Attributes))
	for _, entry := range src.Entries {
		for _, entryAttribute := range entry.Attributes {
			grpInfo[entryAttribute.Name] = entryAttribute.Values
		}
	}
	lc.getLogEntry(liblog.DebugLevel, "ldap group find success").FieldAdd("ldap.group", groupname).FieldAdd("ldap.map", grpInfo).Log()
	return grpInfo, nil
}
func ( lc * HelperLDAP ) GroupInfoByField ( groupname string , fieldForUnicValue string ) ( map [ string ] interface { } , liberr . Error ) { var ( err liberr . Error src * ldap . SearchResult grpInfo map [ string ] interface { } ) src , err = lc . runSearch ( fmt . Sprintf ( lc . config . FilterGroup , fieldForUnicValue , groupname ) , [ ] string { } ) if err != nil { return grpInfo , err } if len ( src . Entries ) == 0 { return nil , ErrorLDAPGroupNotFound . Error ( nil ) } grpInfo = make ( map [ string ] interface { } , len ( src . Entries [ 0 ] . Attributes ) ) for _ , entry := range src . Entries { for _ , entryAttribute := range entry . Attributes { grpInfo [ entryAttribute . Name ] = entryAttribute . Values } } lc . getLogEntry ( liblog . DebugLevel , " " ) . FieldAdd ( " " , groupname ) . FieldAdd ( " " , grpInfo ) . Log ( ) return grpInfo , nil }
GroupInfoByField used to retrieve the information of a given group cn, but use a given field to make the search.
GroupInfoByField used to retrieve the information of a given group cn but use a given field to make the search .