From aec7ea5c0833f9b276f350d29831eb0442f2201a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 16 Nov 2023 14:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/updateldaporginationlogic.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/ldap-admin/internal/logic/updateldaporginationlogic.go b/server/ldap-admin/internal/logic/updateldaporginationlogic.go index 385cd044..3ec68a1d 100644 --- a/server/ldap-admin/internal/logic/updateldaporginationlogic.go +++ b/server/ldap-admin/internal/logic/updateldaporginationlogic.go @@ -37,12 +37,18 @@ func (l *UpdateLdapOrginationLogic) UpdateLdapOrgination(req *types.UpdateLdapOr if req.OrginationDN == "" { 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 { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeServiceErr, "删除ldap组织失败,", err.Error()) + if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" { + return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的组织DN") } - return resp.SetStatusWithMessage(basic.CodeOK, "删除成功") + 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{ + "orgination_dn": {req.OrginationDN}, + "business_category": {req.BusinessCategory}, + }); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeServiceErr, "更新ldap组织失败,", err.Error()) + } + return resp.SetStatusWithMessage(basic.CodeOK, "更新成功") return resp.SetStatus(basic.CodeOK) }