fix
This commit is contained in:
@@ -36,7 +36,7 @@ func (l *AddLdapOrganizationMemberLogic) AddLdapOrganizationMember(req *types.Ad
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
req.UserDN = strings.Trim(req.UserDN, " ")
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的目标组织DN")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,无效的目标组织DN")
|
||||
}
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的用户DN")
|
||||
|
||||
@@ -36,17 +36,14 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
||||
req.OrganizationOu = strings.Trim(req.OrganizationOu, " ")
|
||||
req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ")
|
||||
req.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
|
||||
if req.OrganizationOu == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,organization_ou不能为空")
|
||||
}
|
||||
if len(strings.Split(req.OrganizationOu, ",")) != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,不合法的organization_ou")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,不合法的组织ou")
|
||||
}
|
||||
if req.ParentOrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,parentOrganization_dn不能为空")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,父级DN不能为空")
|
||||
}
|
||||
if req.BusinessCategory == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,business_category不能为空")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,分类名不能为空")
|
||||
}
|
||||
//组装organization dn
|
||||
organizationDN := "ou=" + req.OrganizationOu + "," + req.ParentOrganizationDN
|
||||
|
||||
@@ -42,13 +42,13 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri
|
||||
req.Email = strings.Trim(req.Email, " ")
|
||||
req.Password = strings.Trim(req.Password, " ")
|
||||
if req.UserName == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "用户名不能为空")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,用户名不能为空")
|
||||
}
|
||||
if req.Password == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "密码不能为空")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,密码不能为空")
|
||||
}
|
||||
if !email.IsEmailValid(req.Email) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "邮箱格式不正确")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,邮箱格式不正确")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
//把用户名转pinyin
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewDeleteLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
func (l *DeleteLdapOrganizationLogic) DeleteLdapOrganization(req *types.DeleteLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
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)
|
||||
if err := ldapServer.Delete(req.OrganizationDN); err != nil {
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewDeleteLdapUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *De
|
||||
func (l *DeleteLdapUserLogic) DeleteLdapUser(req *types.DeleteLdapUserReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.UserDN = strings.Trim(req.UserDN, " ")
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
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)
|
||||
err := ldapServer.Update(req.UserDN, map[string][]string{
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewGetLdapUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
|
||||
|
||||
func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
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)
|
||||
res, err := ldapServer.Search(req.UserDN, ldap.ScopeWholeSubtree, "", nil, nil)
|
||||
|
||||
@@ -36,10 +36,10 @@ func (l *RemoveLdapOrganizationMemberLogic) RemoveLdapOrganizationMember(req *ty
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
req.UserDN = strings.Trim(req.UserDN, " ")
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的目标组织DN")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,无效的目标组织DN")
|
||||
}
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
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)
|
||||
err := ldapServer.RemoveUserFromOrganization(req.OrganizationDN, req.UserDN)
|
||||
|
||||
@@ -35,10 +35,10 @@ func NewUpdateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
func (l *UpdateLdapOrganizationLogic) UpdateLdapOrganization(req *types.UpdateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
if req.OrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "组织DN不能为空")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织DN不能为空")
|
||||
}
|
||||
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)
|
||||
if err := ldapServer.Update(req.OrganizationDN, map[string][]string{
|
||||
|
||||
@@ -44,7 +44,7 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri
|
||||
//todo 验证下是不是本人
|
||||
}
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的用户DN")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,无效的用户DN")
|
||||
}
|
||||
//把用户名转pinyin
|
||||
userNamePinyin := chinese_to_pinyin.ChineseToPinyin(req.UserName)
|
||||
|
||||
Reference in New Issue
Block a user