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 {