This commit is contained in:
laodaming 2023-11-17 11:42:27 +08:00
parent 27d4166fae
commit 6e71132721

View File

@ -38,7 +38,7 @@ func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, us
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误用户DN错误")
}
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
res, err := ldapServer.Search(req.UserDN, ldap.ScopeWholeSubtree, "", nil, nil)
res, err := ldapServer.Search(req.UserDN, ldap.ScopeWholeSubtree, "(objectClass=inetOrgPerson)", nil, nil)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "获取用户信息失败:"+err.Error())
@ -46,7 +46,6 @@ func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, us
if len(res.Entries) != 1 {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "查询到不到用户信息")
}
isUser := false
apiRsp := types.GetLdapUserInfoRsp{
UserId: 0,
Status: 0,
@ -55,15 +54,6 @@ func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, us
apiRsp.UserDN = entry.DN
for _, attr := range entry.Attributes {
switch attr.Name {
case "objectClass": //objectcalss属性特别处理
for _, objectClassVal := range attr.Values {
if objectClassVal == "inetOrgPerson" {
isUser = true
}
}
if !isUser {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "查询到的不是用户信息!!")
}
case "uidNumber": //用户id
if len(attr.Values) == 0 {
return resp.SetStatusWithMessage(basic.CodeServiceErr, "用户id不存在")