fix
This commit is contained in:
@@ -13,14 +13,14 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddLdapOrginationMemberLogic struct {
|
||||
type AddLdapOrganizationMemberLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAddLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLdapOrginationMemberLogic {
|
||||
return &AddLdapOrginationMemberLogic{
|
||||
func NewAddLdapOrganizationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLdapOrganizationMemberLogic {
|
||||
return &AddLdapOrganizationMemberLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
@@ -28,13 +28,13 @@ func NewAddLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *AddLdapOrginationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *AddLdapOrganizationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *AddLdapOrginationMemberLogic) AddLdapOrginationMember(req *types.AddLdapOrginationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationDN = strings.Trim(req.OrginationDN, " ")
|
||||
func (l *AddLdapOrganizationMemberLogic) AddLdapOrganizationMember(req *types.AddLdapOrganizationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
req.UserDN = strings.Trim(req.UserDN, " ")
|
||||
if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" {
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的目标组织DN")
|
||||
}
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
@@ -45,6 +45,6 @@ func (l *AddLdapOrginationMemberLogic) AddLdapOrginationMember(req *types.AddLda
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *AddLdapOrginationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *AddLdapOrganizationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
@@ -14,14 +14,14 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateLdapOrginationLogic struct {
|
||||
type CreateLdapOrganizationLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLdapOrginationLogic {
|
||||
return &CreateLdapOrginationLogic{
|
||||
func NewCreateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLdapOrganizationLogic {
|
||||
return &CreateLdapOrganizationLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
@@ -29,32 +29,32 @@ func NewCreateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *CreateLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *CreateLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *CreateLdapOrginationLogic) CreateLdapOrgination(req *types.CreateLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationOu = strings.Trim(req.OrginationOu, " ")
|
||||
req.ParentOrginationDN = strings.Trim(req.ParentOrginationDN, " ")
|
||||
func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationOu = strings.Trim(req.OrganizationOu, " ")
|
||||
req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ")
|
||||
req.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
|
||||
if req.OrginationOu == "" {
|
||||
if req.OrganizationOu == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,organization_ou不能为空")
|
||||
}
|
||||
if len(strings.Split(req.OrginationOu, ",")) != 1 {
|
||||
if len(strings.Split(req.OrganizationOu, ",")) != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,不合法的organization_ou")
|
||||
}
|
||||
if req.ParentOrginationDN == "" {
|
||||
if req.ParentOrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,parentOrganization_dn不能为空")
|
||||
}
|
||||
if req.BusinessCategory == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,business_category不能为空")
|
||||
}
|
||||
//组装organization dn
|
||||
organizationDN := "ou=" + req.OrginationOu + "," + req.ParentOrginationDN
|
||||
organizationDN := "ou=" + req.OrganizationOu + "," + 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},
|
||||
"ou": {req.OrginationOu},
|
||||
"ou": {req.OrganizationOu},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
"uniqueMember": {l.svcCtx.Config.Ldap.RootDN}, //创建groupOfUniqueNames对象类型需要至少一个member,把root加进去
|
||||
})
|
||||
@@ -66,6 +66,6 @@ func (l *CreateLdapOrginationLogic) CreateLdapOrgination(req *types.CreateLdapOr
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *CreateLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *CreateLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
@@ -14,14 +14,14 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteLdapOrginationLogic struct {
|
||||
type DeleteLdapOrganizationLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLdapOrginationLogic {
|
||||
return &DeleteLdapOrginationLogic{
|
||||
func NewDeleteLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLdapOrganizationLogic {
|
||||
return &DeleteLdapOrganizationLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
@@ -29,19 +29,16 @@ func NewDeleteLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *DeleteLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *DeleteLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *DeleteLdapOrginationLogic) DeleteLdapOrgination(req *types.DeleteLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationDN = strings.Trim(req.OrginationDN, " ")
|
||||
if req.OrginationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "组织DN不能为空")
|
||||
}
|
||||
if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" {
|
||||
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")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
if err := ldapServer.Delete(req.OrginationDN); err != nil {
|
||||
if err := ldapServer.Delete(req.OrganizationDN); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "删除ldap组织失败,", err.Error())
|
||||
}
|
||||
@@ -49,6 +46,6 @@ func (l *DeleteLdapOrginationLogic) DeleteLdapOrgination(req *types.DeleteLdapOr
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *DeleteLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *DeleteLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
@@ -16,14 +16,14 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetLdapOrginationsLogic struct {
|
||||
type GetLdapOrganizationsLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetLdapOrginationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLdapOrginationsLogic {
|
||||
return &GetLdapOrginationsLogic{
|
||||
func NewGetLdapOrganizationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLdapOrganizationsLogic {
|
||||
return &GetLdapOrganizationsLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
@@ -31,7 +31,7 @@ func NewGetLdapOrginationsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *GetLdapOrginationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *GetLdapOrganizationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
type DNItem struct {
|
||||
Attribute map[string]interface{} `json:"attribute"`
|
||||
@@ -41,7 +41,7 @@ type DNItem struct {
|
||||
Child []*DNItem `json:"child"`
|
||||
}
|
||||
|
||||
func (l *GetLdapOrginationsLogic) GetLdapOrginations(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
//从ldap获取组织架构数据
|
||||
rootCn := strings.Split(l.svcCtx.Config.Ldap.RootDN, ",")
|
||||
if len(rootCn) == 0 {
|
||||
@@ -120,6 +120,6 @@ func (l *GetLdapOrginationsLogic) GetLdapOrginations(req *types.Request, userinf
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *GetLdapOrginationsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *GetLdapOrganizationsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
@@ -12,14 +12,14 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RemoveLdapOrginationMemberLogic struct {
|
||||
type RemoveLdapOrganizationMemberLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewRemoveLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveLdapOrginationMemberLogic {
|
||||
return &RemoveLdapOrginationMemberLogic{
|
||||
func NewRemoveLdapOrganizationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveLdapOrganizationMemberLogic {
|
||||
return &RemoveLdapOrganizationMemberLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
@@ -27,10 +27,10 @@ func NewRemoveLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.Service
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *RemoveLdapOrginationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *RemoveLdapOrganizationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *RemoveLdapOrginationMemberLogic) RemoveLdapOrginationMember(req *types.RemoveLdapOrginationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
func (l *RemoveLdapOrganizationMemberLogic) RemoveLdapOrganizationMember(req *types.RemoveLdapOrganizationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
@@ -38,6 +38,6 @@ func (l *RemoveLdapOrginationMemberLogic) RemoveLdapOrginationMember(req *types.
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *RemoveLdapOrginationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *RemoveLdapOrganizationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
@@ -14,14 +14,14 @@ import (
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateLdapOrginationLogic struct {
|
||||
type UpdateLdapOrganizationLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLdapOrginationLogic {
|
||||
return &UpdateLdapOrginationLogic{
|
||||
func NewUpdateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLdapOrganizationLogic {
|
||||
return &UpdateLdapOrganizationLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
@@ -29,19 +29,19 @@ func NewUpdateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *UpdateLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *UpdateLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *UpdateLdapOrginationLogic) UpdateLdapOrgination(req *types.UpdateLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationDN = strings.Trim(req.OrginationDN, " ")
|
||||
if req.OrginationDN == "" {
|
||||
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不能为空")
|
||||
}
|
||||
if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" {
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
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.OrginationDN, map[string][]string{
|
||||
if err := ldapServer.Update(req.OrganizationDN, map[string][]string{
|
||||
"cn": {req.BusinessCategory},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
}); err != nil {
|
||||
@@ -52,6 +52,6 @@ func (l *UpdateLdapOrginationLogic) UpdateLdapOrgination(req *types.UpdateLdapOr
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *UpdateLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *UpdateLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
||||
Reference in New Issue
Block a user