fix
This commit is contained in:
parent
86216a6456
commit
648e200d87
|
@ -3,6 +3,7 @@ package logic
|
|||
import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/chinese_to_pinyin"
|
||||
"fusenapi/utils/ldap_lib"
|
||||
"strings"
|
||||
|
||||
|
@ -35,24 +36,28 @@ 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.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
|
||||
req.OrganizationName = strings.Trim(req.OrganizationName, " ")
|
||||
if len(strings.Split(req.OrganizationEnName, ",")) != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,不合法的组织ou")
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不符合规范")
|
||||
}
|
||||
//转拼音比较下
|
||||
if req.OrganizationEnName != chinese_to_pinyin.ChineseToPinyin(req.OrganizationEnName) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不能包含中文")
|
||||
}
|
||||
if req.ParentOrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,父级DN不能为空")
|
||||
}
|
||||
if req.BusinessCategory == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,分类名不能为空")
|
||||
if req.OrganizationName == "" {
|
||||
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.BusinessCategory},
|
||||
"cn": {req.OrganizationName},
|
||||
"ou": {req.OrganizationEnName},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
"businessCategory": {req.OrganizationName},
|
||||
"uniqueMember": {l.svcCtx.Config.Ldap.RootDN}, //创建groupOfUniqueNames对象类型需要至少一个member,把root加进去
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -108,7 +108,7 @@ type MenuItem struct {
|
|||
|
||||
type CreateLdapOrganizationReq struct {
|
||||
OrganizationEnName string `json:"organization_en_name"` //组织英文名
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
OrganizationName string `json:"organization_name"` //组织中文名称
|
||||
ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ type MenuItem {
|
|||
//增加ldap组织
|
||||
type CreateLdapOrganizationReq {
|
||||
OrganizationEnName string `json:"organization_en_name"` //组织英文名
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
OrganizationName string `json:"organization_name"` //组织中文名称
|
||||
ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn
|
||||
}
|
||||
//删除ldap组织
|
||||
|
|
Loading…
Reference in New Issue
Block a user