This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-19 22:30:27 +00:00
|
|
|
package ldap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nmcclain/ldap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func AKAttrsToLDAP(attrs interface{}) []*ldap.EntryAttribute {
|
|
|
|
attrList := []*ldap.EntryAttribute{}
|
|
|
|
for attrKey, attrValue := range attrs.(map[string]interface{}) {
|
|
|
|
entry := &ldap.EntryAttribute{Name: attrKey}
|
2021-04-26 10:24:46 +00:00
|
|
|
switch t := attrValue.(type) {
|
2021-04-19 22:30:27 +00:00
|
|
|
case []string:
|
2021-04-26 10:24:46 +00:00
|
|
|
entry.Values = t
|
2021-04-19 22:30:27 +00:00
|
|
|
case string:
|
2021-04-26 10:24:46 +00:00
|
|
|
entry.Values = []string{t}
|
2021-04-19 22:30:27 +00:00
|
|
|
}
|
|
|
|
attrList = append(attrList, entry)
|
|
|
|
}
|
|
|
|
return attrList
|
|
|
|
}
|