[ { "id": "adex07-1", "type": "tab", "label": "Resolve DN references - DRY RUN", "disabled": false, "info": "Resolve each reference user with Require exactly one before passing its DN. The target ExampleUser is independently resolved by Set attribute. The manager branch uses dn; the secretary branch uses multiDn and replaces the entire secretary list. Commas are part of DNs, not separators. Replace ExampleManager and ExampleAssistant with authorized reference identities." }, { "id": "adex07-2", "type": "ms-ad-config", "name": "Example Active Directory - CONFIGURE ME", "protocol": "ldaps", "host": "dc.example.com", "port": "", "baseDN": "DC=example,DC=com", "tlsEnabled": true, "rejectUnauthorized": true, "tlsServername": "", "caCert": "", "caCertPath": "" }, { "id": "adex07-3", "type": "comment", "z": "adex07-1", "name": "Resolve DN references - DRY RUN", "x": 350, "y": 40, "wires": [], "info": "Resolve each reference user with Require exactly one before passing its DN. The target ExampleUser is independently resolved by Set attribute. The manager branch uses dn; the secretary branch uses multiDn and replaces the entire secretary list. Commas are part of DNs, not separators. Replace ExampleManager and ExampleAssistant with authorized reference identities.\n\nManual Injects only. All writes are DRY RUN in both node and message. Replace neutral identities and configure AD credentials before running. No credentials are embedded." }, { "id": "adex07-4", "type": "debug", "z": "adex07-1", "name": "Would change (dry-run) / changed", "x": 1150, "y": 80, "wires": [], "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg" }, { "id": "adex07-5", "type": "debug", "z": "adex07-1", "name": "Already in desired state", "x": 1150, "y": 130, "wires": [], "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg" }, { "id": "adex07-6", "type": "debug", "z": "adex07-1", "name": "Error incl. msg.error", "x": 1150, "y": 180, "wires": [], "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg" }, { "id": "adex07-7", "type": "function", "z": "adex07-1", "name": "Inspect result and msg.error", "x": 870, "y": 110, "wires": [ [ "adex07-4" ], [ "adex07-5" ], [ "adex07-6" ] ], "func": "const result = msg.ad.result;\nif (!result || !result.success) { msg.payload = { error: msg.error || (result && result.error), result }; return [null, null, msg]; }\nmsg.payload = { dryRun: result.dryRun, changed: result.changed, alreadyInDesiredState: result.alreadyInDesiredState, changes: result.changes };\nreturn result.alreadyInDesiredState ? [null, msg, null] : [msg, null, null];", "outputs": 3, "noerr": 0, "initialize": "", "finalize": "", "libs": [] }, { "id": "adex07-8", "type": "inject", "z": "adex07-1", "name": "Resolve manager then plan assignment", "x": 230, "y": 300, "wires": [ [ "adex07-11" ] ], "props": [ { "p": "ad.user", "v": "ExampleUser", "vt": "str" }, { "p": "ad.dryRun", "v": "true", "vt": "bool" }, { "p": "ad.searchValue", "v": "ExampleManager", "vt": "str" } ], "once": false, "onceDelay": 0.1, "repeat": "", "crontab": "", "topic": "" }, { "id": "adex07-9", "type": "function", "z": "adex07-1", "name": "Use resolved manager DN", "x": 560, "y": 300, "wires": [ [ "adex07-10" ], [ "adex07-7" ] ], "func": "const r = msg.lookup;\nif (!r || !r.success || r.count !== 1 || !r.object || !r.object.dn) { msg.error = { message: 'Reference lookup must return exactly one DN' }; return [null, msg]; }\nmsg.ad.attribute='manager'; msg.ad.valueType='dn'; msg.ad.attributeAction='set'; msg.ad.value=r.object.dn; msg.ad.dryRun=true; return [msg,null];", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [] }, { "id": "adex07-10", "type": "ms-ad-set-user-attribute", "z": "adex07-1", "name": "", "x": 620, "y": 360, "wires": [ [ "adex07-7" ], [ "adex07-7" ] ], "configName": "adex07-2", "baseDN": "", "customInputPaths": false, "userSearchField": "auto", "attribute": "manager", "action": "set", "valueType": "dn", "value": "", "outputProperty": "ad.result", "dryRun": true }, { "id": "adex07-11", "type": "ms-ad-object-lookup", "z": "adex07-1", "name": "", "x": 330, "y": 360, "wires": [ [ "adex07-9" ] ], "configName": "adex07-2", "baseDN": "", "customInputPaths": false, "objectType": "user", "searchField": "sAMAccountName", "additionalAttributes": "", "requireExactlyOne": true, "returnFirstOnly": false, "setAdDn": false, "outputProperty": "lookup" }, { "id": "adex07-12", "type": "inject", "z": "adex07-1", "name": "Resolve two secretary references", "x": 230, "y": 540, "wires": [ [ "adex07-17" ] ], "props": [ { "p": "ad.user", "v": "ExampleUser", "vt": "str" }, { "p": "ad.dryRun", "v": "true", "vt": "bool" }, { "p": "ad.searchValue", "v": "ExampleManager", "vt": "str" } ], "once": false, "onceDelay": 0.1, "repeat": "", "crontab": "", "topic": "" }, { "id": "adex07-13", "type": "function", "z": "adex07-1", "name": "Save first DN; resolve second", "x": 560, "y": 540, "wires": [ [ "adex07-16" ], [ "adex07-7" ] ], "func": "const r = msg.lookup;\nif (!r || !r.success || r.count !== 1 || !r.object || !r.object.dn) { msg.error = { message: 'Reference lookup must return exactly one DN' }; return [null, msg]; }\nmsg.referenceDns=[r.object.dn]; msg.ad.searchValue='ExampleAssistant'; return [msg,null];", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [] }, { "id": "adex07-14", "type": "function", "z": "adex07-1", "name": "Use resolved DN array", "x": 560, "y": 760, "wires": [ [ "adex07-15" ], [ "adex07-7" ] ], "func": "const r = msg.lookup;\nif (!r || !r.success || r.count !== 1 || !r.object || !r.object.dn) { msg.error = { message: 'Reference lookup must return exactly one DN' }; return [null, msg]; }\nmsg.ad.attribute='secretary'; msg.ad.valueType='multiDn'; msg.ad.attributeAction='set'; msg.ad.value=[...new Set([...msg.referenceDns,r.object.dn])]; if(msg.dnFormat==='lines') msg.ad.value=msg.ad.value.join('\\n'); msg.ad.dryRun=true; return [msg,null];", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [] }, { "id": "adex07-15", "type": "ms-ad-set-user-attribute", "z": "adex07-1", "name": "", "x": 620, "y": 850, "wires": [ [ "adex07-7" ], [ "adex07-7" ] ], "configName": "adex07-2", "baseDN": "", "customInputPaths": false, "userSearchField": "auto", "attribute": "secretary", "action": "set", "valueType": "multiDn", "value": "", "outputProperty": "ad.result", "dryRun": true }, { "id": "adex07-16", "type": "ms-ad-object-lookup", "z": "adex07-1", "name": "", "x": 330, "y": 760, "wires": [ [ "adex07-14" ] ], "configName": "adex07-2", "baseDN": "", "customInputPaths": false, "objectType": "user", "searchField": "sAMAccountName", "additionalAttributes": "", "requireExactlyOne": true, "returnFirstOnly": false, "setAdDn": false, "outputProperty": "lookup" }, { "id": "adex07-17", "type": "ms-ad-object-lookup", "z": "adex07-1", "name": "", "x": 330, "y": 600, "wires": [ [ "adex07-13" ] ], "configName": "adex07-2", "baseDN": "", "customInputPaths": false, "objectType": "user", "searchField": "sAMAccountName", "additionalAttributes": "", "requireExactlyOne": true, "returnFirstOnly": false, "setAdDn": false, "outputProperty": "lookup" }, { "id": "adex07-12-lines", "type": "inject", "z": "adex07-1", "name": "Resolve two DNs as newline input", "x": 230, "y": 1000, "wires": [ [ "adex07-17" ] ], "props": [ { "p": "ad.user", "v": "ExampleUser", "vt": "str" }, { "p": "ad.dryRun", "v": "true", "vt": "bool" }, { "p": "ad.searchValue", "v": "ExampleManager", "vt": "str" }, { "p": "dnFormat", "v": "lines", "vt": "str" } ], "once": false, "onceDelay": 0.1, "repeat": "", "crontab": "", "topic": "" } ]