From bce453e103b1e17317ff3a75944c403f449e3cfd Mon Sep 17 00:00:00 2001 From: alphaeusmote <41258468-alphaeusmote@users.noreply.replit.com> Date: Thu, 10 Apr 2025 16:19:20 +0000 Subject: [PATCH] Fix dynamic group creation by ensuring rootDSE is included in the target group DN. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/8067ff26-7051-4f66-861e-57f8abe7a2db.jpg --- .../components/dynamic-groups/rule-editor.tsx | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/client/src/components/dynamic-groups/rule-editor.tsx b/client/src/components/dynamic-groups/rule-editor.tsx index 9b8ed1b..7bdf810 100644 --- a/client/src/components/dynamic-groups/rule-editor.tsx +++ b/client/src/components/dynamic-groups/rule-editor.tsx @@ -128,9 +128,44 @@ export const RuleEditor: React.FC = ({ rule, onSave, onCancel } }; // Compute the full target group DN + // Get the rootDSE string based on the first selected LDAP connection + const getRootDSE = () => { + if (!formData.connections || formData.connections.length === 0) { + return "DC=example,DC=com"; // Default if no connection selected + } + + const selectedConnection = ldapConnections.find(conn => + formData.connections.includes(conn.id) + ); + + if (!selectedConnection || !selectedConnection.domain) { + return "DC=example,DC=com"; // Fallback if no domain info + } + + const domainParts = selectedConnection.domain.split('.'); + return domainParts.map(part => `DC=${part}`).join(','); + }; + + // Ensure OU path has rootDSE appended + const ensureRootDSE = (ouPath: string) => { + if (!ouPath) return ''; + + // Check if the path already contains DC= + if (ouPath.includes('DC=')) { + return ouPath; + } + + // Ensure a comma between the OU path and rootDSE if needed + const separator = ouPath.endsWith(',') ? '' : ','; + return `${ouPath}${separator}${getRootDSE()}`; + }; + const getTargetGroupDN = () => { if (!formData.targetGroupName || !formData.targetOU) return ''; - return `CN=${formData.targetGroupName},${formData.targetOU}`; + + // Ensure targetOU has rootDSE + const fullOU = ensureRootDSE(formData.targetOU); + return `CN=${formData.targetGroupName},${fullOU}`; }; // Handle form submission