fix
This commit is contained in:
parent
e5a73420b6
commit
79faa6a377
@ -29,13 +29,17 @@ func (l *Ldap) GetLdapUserInfo(userDN string) (*LdapUserInfo, error) {
|
|||||||
if len(res.Entries) != 1 {
|
if len(res.Entries) != 1 {
|
||||||
return nil, errors.New("查询到不到用户信息")
|
return nil, errors.New("查询到不到用户信息")
|
||||||
}
|
}
|
||||||
user := &LdapUserInfo{}
|
if len(res.Entries) == 0 {
|
||||||
for _, entry := range res.Entries {
|
return nil, errors.New("ldap user not exists(entry not exists)")
|
||||||
if entry.DN != userDN {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
user.UserDN = entry.DN
|
userEntry := res.Entries[0]
|
||||||
for _, attr := range entry.Attributes {
|
if userEntry.DN != userDN {
|
||||||
|
return nil, errors.New("ldap user not exists(DN not match)")
|
||||||
|
}
|
||||||
|
user := &LdapUserInfo{
|
||||||
|
UserDN: userEntry.DN,
|
||||||
|
}
|
||||||
|
for _, attr := range userEntry.Attributes {
|
||||||
switch attr.Name {
|
switch attr.Name {
|
||||||
case "uidNumber": //用户id
|
case "uidNumber": //用户id
|
||||||
if len(attr.Values) == 0 {
|
if len(attr.Values) == 0 {
|
||||||
@ -73,8 +77,6 @@ func (l *Ldap) GetLdapUserInfo(userDN string) (*LdapUserInfo, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
|
||||||
if user.UserId == 0 {
|
if user.UserId == 0 {
|
||||||
return nil, errors.New("查询到的不是用户信息!!!")
|
return nil, errors.New("查询到的不是用户信息!!!")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user