fix
This commit is contained in:
@@ -36,7 +36,7 @@ func NewCreateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationEnName = strings.Trim(req.OrganizationEnName, " ")
|
||||
req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ")
|
||||
req.OrganizationName = strings.Trim(req.OrganizationName, " ")
|
||||
req.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
|
||||
if len(strings.Split(req.OrganizationEnName, ",")) != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不符合规范")
|
||||
}
|
||||
@@ -47,17 +47,17 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
||||
if req.ParentOrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,父级DN不能为空")
|
||||
}
|
||||
if req.OrganizationName == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织中文名不能为空")
|
||||
if req.BusinessCategory == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织分类名不能为空")
|
||||
}
|
||||
//组装organization dn
|
||||
organizationDN := "ou=" + req.OrganizationEnName + "," + req.ParentOrganizationDN
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
err := ldapServer.Create(organizationDN, map[string][]string{
|
||||
"objectClass": {"top", "groupOfUniqueNames"},
|
||||
"cn": {req.OrganizationName},
|
||||
"cn": {req.OrganizationEnName},
|
||||
"ou": {req.OrganizationEnName},
|
||||
"businessCategory": {req.OrganizationName},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
"uniqueMember": {l.svcCtx.Config.Ldap.RootDN}, //创建groupOfUniqueNames对象类型需要至少一个member,把root加进去
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -74,7 +74,7 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri
|
||||
"shadowWarning": {"7"}, //固有属性
|
||||
"loginShell": {"/usr/sbin/nologin"}, //固有属性
|
||||
"homeDirectory": {"/home/users/" + userNamePinyin},
|
||||
"employeeType": {"1"}, //1正式 2实习 3外包
|
||||
"employeeType": {fmt.Sprintf("%d", req.EmployeeType)}, //1正式 2实习 3外包
|
||||
"uidNumber": {fmt.Sprintf("%d", userData.Id)},
|
||||
"gidNumber": {fmt.Sprintf("%d", userData.Id)},
|
||||
"uid": {userNamePinyin},
|
||||
|
||||
@@ -62,6 +62,7 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri
|
||||
"mobile": {req.Mobile},
|
||||
"postalAddress": {req.Avatar},
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)},
|
||||
"employeeType": {fmt.Sprintf("%d", req.EmployeeType)},
|
||||
}
|
||||
err := ldapServer.Update(req.UserDN, attr)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user