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 {
|
||||
return nil, errors.New("查询到不到用户信息")
|
||||
}
|
||||
user := &LdapUserInfo{}
|
||||
for _, entry := range res.Entries {
|
||||
if entry.DN != userDN {
|
||||
continue
|
||||
if len(res.Entries) == 0 {
|
||||
return nil, errors.New("ldap user not exists(entry not exists)")
|
||||
}
|
||||
user.UserDN = entry.DN
|
||||
for _, attr := range entry.Attributes {
|
||||
userEntry := res.Entries[0]
|
||||
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 {
|
||||
case "uidNumber": //用户id
|
||||
if len(attr.Values) == 0 {
|
||||
|
@ -73,8 +77,6 @@ func (l *Ldap) GetLdapUserInfo(userDN string) (*LdapUserInfo, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
if user.UserId == 0 {
|
||||
return nil, errors.New("查询到的不是用户信息!!!")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user