fix
This commit is contained in:
parent
3996b3e1cb
commit
0862a8e652
|
@ -92,41 +92,53 @@ func (l *GetLdapOrganizationMembersLogic) GetLdapOrganizationMembers(req *types.
|
|||
}
|
||||
userList := make([]types.GetLdapOrganizationMembersItem, 0, memberCount)
|
||||
for _, entry := range result.Entries {
|
||||
userInfo := types.GetLdapOrganizationMembersItem{
|
||||
user := types.GetLdapOrganizationMembersItem{
|
||||
UserDN: entry.DN,
|
||||
}
|
||||
canAppend := true
|
||||
for _, attr := range entry.Attributes {
|
||||
switch attr.Name {
|
||||
case "uidNumber": //用户id
|
||||
if len(attr.Values) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "用户id不存在")
|
||||
}
|
||||
userInfo.UserId, err = strconv.ParseInt(attr.Values[0], 10, 64)
|
||||
user.UserId, err = strconv.ParseInt(attr.Values[0], 10, 64)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "用户id转数字失败")
|
||||
}
|
||||
case "sn": //用户真名
|
||||
userInfo.UserName = strings.Join(attr.Values, "")
|
||||
user.UserName = strings.Join(attr.Values, "")
|
||||
case "mail": //邮箱
|
||||
userInfo.Email = strings.Join(attr.Values, "")
|
||||
user.Email = strings.Join(attr.Values, "")
|
||||
case "mobile": //手机号
|
||||
userInfo.Mobile = strings.Join(attr.Values, "")
|
||||
user.Mobile = strings.Join(attr.Values, "")
|
||||
case "postalAddress": //头像
|
||||
userInfo.Avatar = strings.Join(attr.Values, "")
|
||||
user.Avatar = strings.Join(attr.Values, "")
|
||||
case "postalCode": //状态
|
||||
if len(attr.Values) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "用户状态不存在")
|
||||
}
|
||||
userInfo.Status, err = strconv.ParseInt(attr.Values[0], 10, 64)
|
||||
user.Status, err = strconv.ParseInt(attr.Values[0], 10, 64)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "用户状态转数字失败")
|
||||
}
|
||||
//无效员工就不要显示了
|
||||
if user.Status != 1 {
|
||||
//从该组中移除该成员
|
||||
if err = ldapServer.RemoveUserFromOrganization(req.OrganizationDN, entry.DN); err != nil {
|
||||
logx.Error("移除组中离职成员失败,", err.Error())
|
||||
}
|
||||
canAppend = false //要移除的成员就不要显示了
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
//添加列表
|
||||
userList = append(userList, userInfo)
|
||||
if canAppend {
|
||||
userList = append(userList, user)
|
||||
}
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLdapOrganizationMembersRsp{
|
||||
List: userList,
|
||||
|
|
Loading…
Reference in New Issue
Block a user