package mapping // 部门组的命名与 DN 构造。 // // LLDAP 组不嵌套(组里只能有用户),且组身份必须稳定:部门改名不能引起组 // displayName/CN 变化,否则 Authelia 与下游对组的引用会连锁失效。因此组名用 // 部门稳定索引(open_department_id)派生,而不是拼音——拼音对可读但多义、且 // 改名即换身份。可读的部门中文名不进入组名,存放在数据库的 name 列与用户的 // business_category 里供展示(见 AGENTS.md 约束 12)。 import ( "strings" "idsync/internal/ldaplib" ) // GroupRootDN 返回部门组根 OU 的完整 DN。LLDAP 分组固定挂在 ou=groups 下。 func GroupRootDN(baseDN string) string { return "ou=groups," + strings.TrimSpace(baseDN) } // DeptGroupDN 由部门稳定索引派生出该部门组的完整 DN。 // // 形如 cn=,ou=groups,。open_department_id 在飞书租户内全局唯一、 // 且部门改名/挪动不变,因此组身份稳定;部门树的父子/层级关系只维护在 SQLite 的 // mirror_departments.parent_id,不从组名解码(见 AGENTS.md 约束 12)。 func DeptGroupDN(deptID, baseDN string) string { return ldaplib.GroupDN(deptID, GroupRootDN(baseDN)) }