Factoring the model user and correcting password
This commit is contained in:
parent
890604b943
commit
b182683030
1 changed files with 31 additions and 0 deletions
|
@ -23,6 +23,37 @@ type User struct {
|
||||||
UID string
|
UID string
|
||||||
Description string
|
Description string
|
||||||
Password string
|
Password string
|
||||||
|
CanAdmin bool
|
||||||
|
CanInvite bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func get(user User, config *ConfigFile, ldapConn *ldap.Conn) (*User, error) {
|
||||||
|
searchReq := ldap.NewSearchRequest(
|
||||||
|
user.DN,
|
||||||
|
ldap.ScopeBaseObject,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
"",
|
||||||
|
[]string{
|
||||||
|
"*",
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
searchRes, err := ldapConn.Search(searchReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resUser := User{
|
||||||
|
DN: user.DN,
|
||||||
|
GivenName: searchRes.Entries[0].GetAttributeValue("givenName"),
|
||||||
|
DisplayName: searchRes.Entries[0].GetAttributeValue("displayName"),
|
||||||
|
SN: searchRes.Entries[0].GetAttributeValue("sn"),
|
||||||
|
UID: searchRes.Entries[0].GetAttributeValue("uid"),
|
||||||
|
CN: searchRes.Entries[0].GetAttributeValue("cn"),
|
||||||
|
}
|
||||||
|
return &resUser, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
func add(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
|
||||||
|
|
Loading…
Reference in a new issue