Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-11-17 11:53:44 +08:00
commit 93924f1f3d
2 changed files with 8 additions and 14 deletions

View File

@ -36,7 +36,11 @@ func (l *GetLdapOrganizationMembersLogic) GetLdapOrganizationMembers(req *types.
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" { if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,无效的组织DN") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,无效的组织DN")
} }
//先获取组织信息
/*ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
filter := "(objectClass=groupOfUniqueNames)"
fields := ""
ldapServer.Search(req.OrganizationDN, ldap.ScopeWholeSubtree, filter, nil, nil)*/
return resp.SetStatus(basic.CodeOK) return resp.SetStatus(basic.CodeOK)
} }

View File

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