fix
This commit is contained in:
parent
804a7f656e
commit
b0750bdafc
|
@ -46,6 +46,9 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri
|
|||
if req.Password == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "密码不能为空")
|
||||
}
|
||||
if req.Email == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "邮箱不能为空")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
//把用户名转pinyin
|
||||
userNamePinyin := chinese_to_pinyin.ChineseToPinyin(req.UserName)
|
||||
|
@ -55,7 +58,7 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri
|
|||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "获取自增用户id失败")
|
||||
}
|
||||
userDN := fmt.Sprintf("cn=%s,%s", userNamePinyin, l.svcCtx.Config.Ldap.PeopleGroupDN)
|
||||
userDN := fmt.Sprintf("cn=%s,%s", req.Email, l.svcCtx.Config.Ldap.PeopleGroupDN)
|
||||
if err := ldapServer.Create(userDN, map[string][]string{
|
||||
"objectClass": {"person", "organizationalPerson", "inetOrgPerson", "posixAccount", "top", "shadowAccount"}, //固有属性
|
||||
"shadowLastChange": {"19676"}, //固有属性
|
||||
|
@ -66,7 +69,7 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri
|
|||
"homeDirectory": {"/home/users/" + userNamePinyin},
|
||||
"uidNumber": {fmt.Sprintf("%d", userData.Id)},
|
||||
"gidNumber": {fmt.Sprintf("%d", userData.Id)},
|
||||
"uid": {userNamePinyin},
|
||||
"uid": {fmt.Sprintf("%d", userData.Id)},
|
||||
"cn": {userNamePinyin},
|
||||
"sn": {req.UserName},
|
||||
"mail": {req.Email},
|
||||
|
|
Loading…
Reference in New Issue
Block a user