new oclib
This commit is contained in:
@@ -468,6 +468,7 @@ func (c *ldapConn) SearchRoles(attrs ...string) ([]map[string][]string, error) {
|
||||
|
||||
// searchEntries executes a LDAP query, and returns a result as entries where each entry is mapping of LDAP attributes.
|
||||
func (c *ldapConn) searchEntries(baseDN, query string, attrs []string) ([]map[string][]string, error) {
|
||||
fmt.Println(baseDN, query, attrs)
|
||||
req := ldap.NewSearchRequest(baseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, query, attrs, nil)
|
||||
res, err := c.Search(req)
|
||||
if err != nil {
|
||||
@@ -476,7 +477,7 @@ func (c *ldapConn) searchEntries(baseDN, query string, attrs []string) ([]map[st
|
||||
|
||||
var entries []map[string][]string
|
||||
for _, v := range res.Entries {
|
||||
entry := map[string][]string{"dn": []string{v.DN}}
|
||||
entry := map[string][]string{"dn": {v.DN}}
|
||||
for _, attr := range v.Attributes {
|
||||
// We need the first value only for the named attribute.
|
||||
entry[attr.Name] = attr.Values
|
||||
|
||||
Reference in New Issue
Block a user