From 0bdefa94847cdf2899a38a479f0ce3a64ec1b1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E4=B8=AB=E8=AE=B2=E6=A2=B5?= Date: Mon, 18 Jul 2022 16:38:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=8Eldap=E5=90=8C=E6=AD=A5=E8=BF=87?= =?UTF-8?q?=E6=9D=A5=E4=B9=8B=E5=90=8EgroupType=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/openldap_logic.go | 3 ++- public/common/init_mysql_data.go | 46 +------------------------------- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/logic/openldap_logic.go b/logic/openldap_logic.go index 9d40e23..2ef4330 100644 --- a/logic/openldap_logic.go +++ b/logic/openldap_logic.go @@ -2,6 +2,7 @@ package logic import ( "fmt" + "strings" "github.com/eryajf/go-ldap-admin/model" "github.com/eryajf/go-ldap-admin/public/client/openldap" @@ -63,7 +64,7 @@ func (d OpenLdapLogic) AddDepts(group *model.Group) error { if !isql.Group.Exist(tools.H{"group_dn": group.GroupDN}) { // 此时的 group 已经附带了Build后动态关联好的字段,接下来将一些确定性的其他字段值添加上,就可以创建这个分组了 group.Creator = "system" - group.GroupType = "cn" + group.GroupType = strings.Split(strings.Split(group.GroupDN, ",")[0], "=")[0] parentid, err := d.getParentGroupID(group) if err != nil { return err diff --git a/public/common/init_mysql_data.go b/public/common/init_mysql_data.go index 33ba6d7..d1b1b5a 100644 --- a/public/common/init_mysql_data.go +++ b/public/common/init_mysql_data.go @@ -705,7 +705,7 @@ func InitData() { GroupName: "root", Remark: "Base", Creator: "system", - GroupType: "ou", + GroupType: "", ParentId: 0, SourceDeptId: "0", Source: "openldap", @@ -748,50 +748,6 @@ func InitData() { SourceDeptParentId: fmt.Sprintf("%s_%d", config.Conf.FeiShu.Flag, 0), GroupDN: fmt.Sprintf("ou=%s,%s", config.Conf.FeiShu.Flag+"root", config.Conf.Ldap.BaseDN), }, - // { - // Model: gorm.Model{ID: 2}, - // GroupName: "jenkins", - // Remark: "Jenkins对应权限组管理", - // Creator: "系统", - // GroupType: "ou", - // ParentId: 0, - // }, - // { - // Model: gorm.Model{ID: 3}, - // GroupName: "ceshizu", - // Remark: "测试组", - // Creator: "系统", - // GroupType: "cn", - // Users: users[:1], - // ParentId: 1, - // }, - // { - // Model: gorm.Model{ID: 4}, - // GroupName: "yunweizu", - // Remark: "运维组", - // Creator: "系统", - // GroupType: "cn", - // Users: users[:1], - // ParentId: 1, - // }, - // { - // Model: gorm.Model{ID: 5}, - // GroupName: "test-admin", - // Remark: "admin测试环境", - // Creator: "系统", - // GroupType: "cn", - // Users: users[:1], - // ParentId: 2, - // }, - // { - // Model: gorm.Model{ID: 6}, - // GroupName: "prod-admin", - // Remark: "admin正式环境", - // Creator: "系统", - // GroupType: "cn", - // Users: users[:1], - // ParentId: 2, - // }, } for _, group := range groups {