[ { "id": "adex08-1", "type": "tab", "label": "Read, edit and replace a list - DRY RUN", "disabled": false, "info": "Read otherTelephone, add/remove one exact string, then replace the COMPLETE list. Missing values become an empty list; a scalar becomes a one-item list. Repeating against an already matching state is a no-op. This sequence is NOT atomic: a concurrent edit between read and write can be overwritten. Coordinate writers before enabling real changes. With insufficient read rights an omitted attribute may look empty: verify read access first. Every Inject reads fresh data; this flow is not a locking or merge guarantee." }, { "id": "adex08-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": "adex08-3", "type": "comment", "z": "adex08-1", "name": "Read, edit and replace a list - DRY RUN", "x": 350, "y": 40, "wires": [], "info": "Read otherTelephone, add/remove one exact string, then replace the COMPLETE list. Missing values become an empty list; a scalar becomes a one-item list. Repeating against an already matching state is a no-op. This sequence is NOT atomic: a concurrent edit between read and write can be overwritten. Coordinate writers before enabling real changes. With insufficient read rights an omitted attribute may look empty: verify read access first. Every Inject reads fresh data; this flow is not a locking or merge guarantee.\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": "adex08-4", "type": "debug", "z": "adex08-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": "adex08-5", "type": "debug", "z": "adex08-1", "name": "Already in desired state", "x": 1150, "y": 130, "wires": [], "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg" }, { "id": "adex08-6", "type": "debug", "z": "adex08-1", "name": "Error incl. msg.error", "x": 1150, "y": 180, "wires": [], "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg" }, { "id": "adex08-7", "type": "function", "z": "adex08-1", "name": "Inspect result and msg.error", "x": 870, "y": 110, "wires": [ [ "adex08-4" ], [ "adex08-5" ], [ "adex08-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": "adex08-8", "type": "function", "z": "adex08-1", "name": "Build full replacement list", "x": 600, "y": 400, "wires": [ [ "adex08-9" ], [ "adex08-7" ] ], "func": "const r=msg.lookup;\nif (!r || !r.success || r.count!==1 || !r.object || !r.object.dn) { msg.error={message:'Exactly one readable user required'}; return [null,msg]; }\nif (!['add','remove'].includes(msg.editMode) || typeof msg.editValue!=='string' || !msg.editValue) { msg.error={message:'Invalid list edit'}; return [null,msg]; }\nconst raw=r.object.otherTelephone;\nconst before=raw==null?[]:(Array.isArray(raw)?raw:[raw]);\nif (!before.every(v=>typeof v==='string')) { msg.error={message:'Unexpected attribute values'}; return [null,msg]; }\nmsg.originalValues=before.slice();\nconst values=msg.editMode==='add'?[...new Set([...before,msg.editValue])]:before.filter(v=>v!==msg.editValue);\nmsg.ad.user=r.object.dn; msg.ad.attribute='otherTelephone'; msg.ad.valueType='multiString'; msg.ad.attributeAction='set'; msg.ad.value=values; msg.ad.dryRun=true;\nreturn [msg,null];", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [] }, { "id": "adex08-9", "type": "ms-ad-set-user-attribute", "z": "adex08-1", "name": "", "x": 620, "y": 500, "wires": [ [ "adex08-7" ], [ "adex08-7" ] ], "configName": "adex08-2", "baseDN": "", "customInputPaths": false, "userSearchField": "auto", "attribute": "otherTelephone", "action": "set", "valueType": "multiString", "value": "", "outputProperty": "ad.result", "dryRun": true }, { "id": "adex08-10", "type": "ms-ad-object-lookup", "z": "adex08-1", "name": "", "x": 340, "y": 400, "wires": [ [ "adex08-8" ] ], "configName": "adex08-2", "baseDN": "", "customInputPaths": false, "objectType": "user", "searchField": "sAMAccountName", "additionalAttributes": "otherTelephone", "requireExactlyOne": true, "returnFirstOnly": false, "setAdDn": false, "outputProperty": "lookup" }, { "id": "adex08-11", "type": "inject", "z": "adex08-1", "name": "Read then add one phone", "x": 230, "y": 280, "wires": [ [ "adex08-10" ] ], "props": [ { "p": "ad.user", "v": "ExampleUser", "vt": "str" }, { "p": "ad.dryRun", "v": "true", "vt": "bool" }, { "p": "ad.searchValue", "v": "ExampleUser", "vt": "str" }, { "p": "editMode", "v": "add", "vt": "str" }, { "p": "editValue", "v": "+49 555 0109", "vt": "str" } ], "once": false, "onceDelay": 0.1, "repeat": "", "crontab": "", "topic": "" }, { "id": "adex08-12", "type": "inject", "z": "adex08-1", "name": "Read then remove one phone", "x": 230, "y": 370, "wires": [ [ "adex08-10" ] ], "props": [ { "p": "ad.user", "v": "ExampleUser", "vt": "str" }, { "p": "ad.dryRun", "v": "true", "vt": "bool" }, { "p": "ad.searchValue", "v": "ExampleUser", "vt": "str" }, { "p": "editMode", "v": "remove", "vt": "str" }, { "p": "editValue", "v": "+49 555 0109", "vt": "str" } ], "once": false, "onceDelay": 0.1, "repeat": "", "crontab": "", "topic": "" } ]