diff --git a/client/src/components/dynamic-groups/rule-editor.tsx b/client/src/components/dynamic-groups/rule-editor.tsx index f7a0877..f182b69 100644 --- a/client/src/components/dynamic-groups/rule-editor.tsx +++ b/client/src/components/dynamic-groups/rule-editor.tsx @@ -439,12 +439,15 @@ export const RuleEditor: React.FC = ({ rule, onSave, onCancel }
{ - // Direct insertion of variable or prefixed OU segment + // Direct insertion of variable which should already be properly formatted + // with OU= or DC= prefix by the VariableSelector const currentValue = formData.targetOU || ''; - // Check if this is a variable or a direct DC value - const newValue = variable.startsWith("DC=") || variable.startsWith("OU=") - ? (currentValue && !currentValue.endsWith(",") ? currentValue + "," : currentValue) + variable + + // Add a comma if needed before adding the variable + const newValue = (currentValue && !currentValue.endsWith(",") && variable !== '') + ? currentValue + "," + variable : currentValue + variable; + setFormData({ ...formData, targetOU: newValue }); }} connections={formData.connections} @@ -482,9 +485,9 @@ export const RuleEditor: React.FC = ({ rule, onSave, onCancel }
{ - const variableText = `{${variable}}`; + // Variable was already formatted with CN= prefix by the VariableSelector const currentValue = formData.targetGroupName || ''; - const newValue = currentValue + variableText; + const newValue = currentValue + variable; setFormData({ ...formData, targetGroupName: newValue }); }} connections={formData.connections} diff --git a/client/src/components/dynamic-groups/variable-selector.tsx b/client/src/components/dynamic-groups/variable-selector.tsx index 580a043..ea7cff6 100644 --- a/client/src/components/dynamic-groups/variable-selector.tsx +++ b/client/src/components/dynamic-groups/variable-selector.tsx @@ -88,7 +88,9 @@ const VariableSelector: React.FC = ({ onSelectVariable, c const formattedVar = `OU={${attribute}}`; onSelectVariable(formattedVar); } else { - onSelectVariable(attribute); + // Format for group name with CN prefix + const formattedVar = `CN={${attribute}}`; + onSelectVariable(formattedVar); } setIsOpen(false); }; @@ -108,7 +110,9 @@ const VariableSelector: React.FC = ({ onSelectVariable, c const formattedVar = `OU={${customAttribute.trim()}}`; onSelectVariable(formattedVar); } else { - onSelectVariable(customAttribute.trim()); + // Format custom attribute for group name with CN prefix + const formattedVar = `CN={${customAttribute.trim()}}`; + onSelectVariable(formattedVar); } setCustomAttribute(''); setIsOpen(false);