@hansolo72/node-red-activedirectory 0.9.1

Node-RED nodes for Microsoft Active Directory, including authentication, object lookup, membership checks, raw LDAP queries and safe write actions.

npm install @hansolo72/node-red-activedirectory

@hansolo72/node-red-activedirectory

Node-RED nodes for Microsoft Active Directory.

This package is focused on practical Active Directory workflows, not only on generic LDAP queries. It provides nodes for guided AD object lookup, user authentication, recursive group membership checks and raw LDAP queries.

Quick start

Requires Node.js 22.9.0 or later and Node-RED 4.x or later. See the compatibility notes for the versions exercised by the test suite.

After the package is available on npm, run this command in your Node-RED user directory and restart Node-RED.

npm install @hansolo72/node-red-activedirectory

You can also search for the package under Manage palette → Install once it is listed in the Node-RED Flow Library. For a local archive, see From a local package.

  1. Import the user lookup example from Menu → Import → Examples → @hansolo72/node-red-activedirectory.
  2. Open the example AD Config and select LDAPS, enter Domain / DC and bind credentials. Keep certificate verification enabled and configure CA trust as needed. Leave Base DN empty to discover it from RootDSE.
  3. Select Test connection, replace the sample username with a user in your directory, deploy, and click the Inject button. Inspect the result in the Debug sidebar.

Example flows · AD configuration · TLS and CA trust · Troubleshooting results

Status

This is the first public release line of this package. Earlier builds were internal tests, not public releases. The current local release candidate is 0.9.1. The API is pre-1.0 and may change before a stable release.

The package includes read operations and three write nodes with dry-run enabled by default. English and German editor help document their inputs, message overrides and outputs. See Testing for verification scope and Remaining work and limitations for open cases.

Included nodes

Node Purpose
AD Config (ms-ad-config) Shared LDAP/LDAPS connection, bind credentials, Base DN, certificates and connection test. This is a configuration node rather than a palette operation.
Object lookup Looks up users, groups, computers, contacts, organizational units or any AD object with a guided configuration.
Authenticate user Authenticates a user and optionally checks recursive group membership.
Is user member of Checks whether a user is a direct or nested member of a group.
LDAP query Runs a raw LDAP query for expert use cases.
User account action Safely disables, enables or unlocks exactly one resolved user. Dry run is enabled by default.
Group membership action Safely ensures that a resolved user is directly present in or absent from a resolved group. Dry run is enabled by default.
Set user attribute Safely sets or clears one or more attributes on exactly one resolved user. Dry run is enabled by default.

All nodes use the same configuration dropdown label: Config.

Multilingual support

The editor and help use English as the base language and include German translations. Catalogs are stored per registered node JavaScript file so Node-RED can load them in the node-specific namespace:

nodes/locales/en-US/ms-ad-object-lookup.json
nodes/locales/de-DE/ms-ad-object-lookup.json
nodes/locales/en-US/config.json
nodes/locales/de-DE/config.json

Each per-node catalog contains the keys used by that node. Localized help files are supplied alongside the JSON catalogs as nodes/locales/en-US/*.html and nodes/locales/de-DE/*.html. The catalogs cover editor labels, placeholders, form tips, palette and output labels, structured errors and many runtime status messages. Error code values are not translated. Missing translations fall back to English/default text; a few runtime status messages remain fixed English text.

Editor-side translation helpers are scoped to each node. German palette labels use short natural wording; verify labels and help in both editor languages during acceptance testing.

Safe write actions

The three write-action nodes use the following safeguards:

  • Dry run is enabled by default.
  • sAMAccountName, userPrincipalName or distinguishedName can be used as input.
  • Inputs are resolved first.
  • The write operation is only executed if exactly one target object was found.
  • The actual LDAP modify operation is always executed against the resolved distinguishedName.
  • The current state is read before writing.
  • The output contains whether anything changed and the old/new values where applicable.
  • A started LDAP Modify is never automatically replayed after an error. If the response was lost, inspect the directory before deliberately retrying. Transport failover is available before the write starts.

User account action supports:

  • Disable user
  • Enable user
  • Unlock user

Group membership action supports idempotent desired states:

  • Member should be present
  • Member should be absent

Set user attribute supports:

  • Set value
  • Clear attribute
  • One configured attribute in the UI
  • Multiple changes through msg.ad.attributeChanges

Supported value types are string, number, boolean, date as LDAP generalizedTime, dn, multiString, multiDn and raw. Unsupported value types such as binary values, SID/GUID values, FileTime-only values and password changes are intentionally rejected. Dangerous or dedicated attributes such as userAccountControl, memberOf, unicodePwd, pwdLastSet, lockoutTime and accountExpires are blocked intentionally.

Search results normalize AD binary identity fields such as objectGUID and objectSid to readable strings. This applies to normal output and raw search output returned by the shared LDAP client layer.

Example flows

Import the bundled JSON flows through Menu → Import → Examples → @hansolo72/node-red-activedirectory. All eight examples are included in the package:

Example What it demonstrates
01 — Object lookup User lookup by sAMAccountName, additional attributes and account status.
02 — Authenticate user Username/password input and separate accepted/rejected outputs.
03 — Group membership Direct, nested and primary-group membership with the resolved path.
04 — LDAP query LDAP filter, selected attributes and paged search.
05 — Safe write actions Account disable, direct group membership and a telephone attribute change, all as dry-runs.
06 — Attribute values and overrides title, telephoneNumber, employeeID, text employeeNumber with leading zeros, clear, carLicense arrays, newline-separated otherTelephone, numeric countryCode set/reset, mixed batches and invalid-input diagnostics.
07 — Resolve DN references Unique lookup of manager/secretary references before passing dn or multiDn values as arrays or newline lists. Failed lookups stop the write path.
08 — Read, edit, replace a list Read otherTelephone, add/remove an exact value and submit the complete replacement list.

User lookup example in the English Node-RED editor

Configure and run an example

  1. Import into a new flow. Open the configuration named Example Active Directory - CONFIGURE ME.
  2. Select LDAP/LDAPS (LDAPS is the default), replace dc.example.com, and set the optional port. Replace the example Base DN or leave it empty for RootDSE discovery. Enter bind credentials in AD Config and configure CA trust if required.
  3. Replace sample identities and attribute values with suitable test objects in your own directory. The authentication Inject contains a placeholder password; do not save production passwords there.
  4. Use Test connection, deploy, and press an Inject button manually. No example runs on deployment or on a schedule.
  5. Inspect the Debug output. Examples 06–08 distinguish planned/actual changes, already-matching values and errors, including msg.error.

All write nodes and their input messages use dryRun: true. A dry-run reads AD and describes the proposed change; it does not validate write permission or guarantee that AD will accept the modification. The message override takes precedence over the editor setting. Keep dry-run enabled while learning the flows.

Setting a multi-valued attribute replaces its entire list. It does not append. Example 08 is not atomic: concurrent changes between reading and writing may be overwritten. An unreadable attribute can appear absent, so verify read permissions before treating a missing value as an empty list.

For countryCode, use set/reset rather than clear. Before any actual change, independently read and save the original value and replace the reset placeholder 0 with that value. For DN lists, commas belong to individual DNs; use arrays or one DN per line.

Message-driven attribute changes need a matching msg.ad.valueType; the editor's automatic suggestion is not a live schema lookup. Batch entries take precedence over message fallbacks. Repeating a dry-run reports a no-op only if AD already contains the requested state.

Minimal message examples

Object lookup reads msg.ad.searchValue:

msg.ad = { searchValue: 'JohnSmith' };
return msg;

LDAP query reads msg.ad.query and supports selected attributes and paging:

msg.ad = {
  query: '(&(objectCategory=person)(objectClass=user)(sAMAccountName=JohnSmith))',
  scope: 'sub',
  attributes: ['displayName', 'mail', 'department'],
  paged: true,
  pageSize: 100
};
return msg;

LDAP query settings in the English Node-RED editor

The screenshots use an isolated English Node-RED 5.0.10 editor, placeholder configuration and no AD credentials. Other supported Node-RED versions may arrange the surrounding panels differently.

Testing

Run npm test for the Node.js test suite. It covers domain/value helpers, error classification, binary identity normalization, authentication, membership, write actions, message paths, secret cleanup, editor resources, translations and all eight packaged examples. LDAP transport uses test doubles; these tests do not access a real directory. Some hosting checks load real Node-RED flows with AD access blocked.

npm run validate additionally validates an npm package preview. It does not perform online name-collision checks or registry approval. There is no separate lint command.

The compatibility matrix covers Node.js 22.9.0 and 24.22.2, each with Node-RED 4.0.0, 4.1.18 and 5.0.10. All six combinations passed 304 tests on Windows, plus smoke checks for all eight registrations/examples, deploy/readback and the connection-test endpoint. GitHub CI also passed all six combinations on Ubuntu for the initial source snapshot. Documentation/example adjustments require their own local checks; those previous runs are not new live AD acceptance.

Recorded live acceptance

The following evidence comes from internal pre-release testing, not earlier public releases or a complete live run of this documentation candidate. Tests used approved directory fixtures; credentials, directory identifiers and infrastructure logs are excluded. Separate runs overlap and must not be added as unique test counts.

On 29 November 2026, Windows / Node.js 24.22.2 / Node-RED 5.0.10 with verified LDAPS and an administrative bind passed:

Run Result
Read-only suite 37 passed; no writes or blocked write attempts.
Initial write suite 42 dry-run cases passed, 4 skipped; 24 write cases passed before one countryCode-clear failure stopped the run.
Corrected follow-up 26 dry-run and 17 write cases passed using countryCode set/reset.
Attribute suggestions All 53 suggestions checked; 105 dry-run and 105 write checks passed, including independent reads and repeat/no-op checks.
multiDn on secretary 11 dry-run and 11 write-phase checks passed; six LDAP Modifies, with independent confirmation of restored state.

Account tests covered disable/enable while retaining other flags, and unlock/repeat where prerequisites were available. They did not establish unlocking an actively locked account. Membership tests covered direct add/remove and repeat/no-op behavior. Attribute tests covered string, number, boolean, generalized-time date, DN, multiString, multiDn, raw, mixed batches, clear and invalid inputs. All original values, flags and direct memberships were independently verified after restoration. Temporary helpers were removed and local settings/credentials preserved.

AD rejected removing countryCode; the corrected case sets and restores the numeric value. A dry-run cannot establish whether a server permits attribute removal. Attribute-suggestion testing used the candidate attribute implementation with the then-existing connection editor; the later multiDn run used the current connection fields. These runs do not cover every connection option or schema.

With a read-only bind, group and attribute writes returned INSUFFICIENT_ACCESS_RIGHTS (LDAP 50 / AD 0x2098), without successful modifications. Account actions stopped earlier with USER_ACCOUNT_CONTROL_UNAVAILABLE because prerequisite flags were unreadable; account-write denial after readable prerequisites remains open.

Earlier internal read checks also exercised primary-group paths, pagination and Windows native CA trust, including certificate/hostname negative controls. They are supporting evidence only. See Remaining work and limitations.

Error handling

Runtime errors are returned as machine-readable error objects where practical:

{
  "error": {
    "code": "INVALID_CREDENTIALS",
    "message": "Invalid username or password.",
    "hint": "Check the entered username and password.",
    "operation": "authenticateUser"
  }
}

Common codes include INVALID_CREDENTIALS, ACCOUNT_RESTRICTION, ACCOUNT_DISABLED, ACCOUNT_LOCKED, PASSWORD_EXPIRED, PASSWORD_MUST_CHANGE, GROUP_NOT_FOUND, AUTHENTICATED_NOT_AUTHORIZED, LDAP_TLS_CERTIFICATE_ERROR, BASE_DN_MISSING, AMBIGUOUS_GROUP_NAME and LDAP_REFERRAL_ERROR.

Technical raw error details are intentionally omitted by default. For troubleshooting, set:

{
  "ad": {
    "includeErrorDetails": true
  }
}

When enabled, the error object may include a raw property with LDAP library details and connection attempts. Passwords and credential fields are still removed from the message before output.

Internal AD client abstraction

The runtime uses ldapts. Operation nodes access common LDAP operations through nodes/ad-client.js; nodes/base-dn.js handles the RootDSE discovery connection.

This keeps the Node-RED nodes focused on flow behavior while the LDAP protocol details are encapsulated in one place.

Default message structure

The default input structure is msg.ad.

Base DN convention

All functional nodes use the same Base-DN precedence:

  1. msg.ad.baseDN for a per-message override
  2. the node-specific Base DN field
  3. the shared AD Config Base DN
  4. automatic RootDSE detection when all configured values are empty

LDAP query has no separate Base DN property setting. The fixed message override is always msg.ad.baseDN; no legacy Base-DN aliases are supported.

Editor layout and dependent settings

Related settings use subtle group boxes with theme colours. Checkboxes have a single label; detailed semantics are in the node help. User status and organization in Object lookup are collapsible and initially expand when their saved options are active. Input and output paths remain under Advanced settings.

Visibility follows the configuration currently selected in the editor, not the content of a future message. Hiding a field preserves its saved value. Per-message overrides continue to apply at runtime; to edit an inactive fallback, temporarily enable its controlling option, adjust the value and turn the option off again.

Configuration Visible dependent settings / effective behavior
Object lookup: User User status and organization groups; these are hidden for other object types
Password expiration Warning days; account status is already included, so its separate checkbox is replaced by a short notice
Resolve manager / direct reports The corresponding attribute list
User or Computer: inactivity status or summary Inactivity threshold; the summary also uses this threshold
Group view other than Group only Nested groups, member counts, empty status and nesting depth are included automatically; their redundant checkboxes are replaced by a notice, and the depth limit remains visible
Recursive members / All details Recursive members are already included; no separate opt-in is shown
A direct or recursive member list, or separately enabled recursive members Member-type filter; it does not filter counts, parent groups or nested-group-only results
Group only plus nesting depth Depth limit
Custom LDAP filter / custom search attribute Search-field controls are hidden for a raw filter; the custom attribute field appears only when that search-field option is selected
Require exactly one match Return first match only is hidden; exact-one validation runs before limiting results
LDAP query: paging Page size
Set user attribute: Set value Value type, static fallback and custom value path; these are hidden for Clear attribute
AD Config: custom TLS options Certificate verification, TLS name and CA fields
Custom input paths Custom input fields; the output path remains independent

These dependencies reflect the existing runtime behavior. Changing visibility does not rewrite configuration flags or change AD operations. Dry-run remains enabled by default, with its override notice visible in the Safety group.

Input property convention

The package uses msg.ad.* as its canonical namespace for Active Directory-specific message values. All seven operation nodes accept the standard inputs without filling in property-path fields.

Node Standard input paths
Object lookup msg.ad.searchValue
Authenticate user msg.ad.username, msg.ad.password
LDAP query msg.ad.query
User account action msg.ad.user
Group membership action msg.ad.user, msg.ad.group
Set user attribute msg.ad.user, msg.ad.value
Is user member of msg.ad.user, msg.ad.group

If an upstream node uses another message structure, open Advanced settings → Use custom input paths. Enter a path relative to msg, such as payload.username, rather than the username itself. An optional msg. prefix is accepted. Empty fields use the standard paths; malformed active paths are marked invalid. The compact path display shows the effective inputs and output. Set user attribute also offers an optional static fallback when the selected message value is missing; clearing an attribute needs no value.

The Output path is in the same advanced section, independent of the custom-input toggle. An empty output path means msg.payload. Use ad.result to preserve the existing payload. Options that control the result content, such as additional attributes and raw results, stay in the main form. Configuration explanations and per-message overrides are in the node help, accessible through Node-RED's help tab. AD Config has no message paths and keeps its connection-test button and result display.

Custom input paths are used only when Use custom input paths is enabled. Saved hidden paths do not affect standard inputs. The output path is independent of that toggle.

All control/options overrides use fixed canonical paths under msg.ad.*, for example msg.ad.baseDN, msg.ad.userSearchField, msg.ad.groupSearchField, msg.ad.action, msg.ad.desiredState, msg.ad.dryRun, msg.ad.scope and msg.ad.attributes. These control-property paths are not configurable in the editor.

For authentication:

{
  "ad": {
    "username": "[email protected]",
    "password": "secret"
  }
}

For object lookup:

{
  "ad": {
    "searchValue": "JohnSmith"
  }
}

For group membership checks:

{
  "ad": {
    "user": "[email protected]",
    "group": "GG_NodeRed_Admins"
  }
}

For raw LDAP queries:

{
  "ad": {
    "baseDN": "DC=example,DC=com",
    "query": "(objectClass=user)",
    "scope": "sub",
    "attributes": ["displayName", "mail", "department"]
  }
}

For user account write actions:

{
  "ad": {
    "user": "JohnSmith",
    "action": "disable",
    "dryRun": true
  }
}

For group membership write actions:

{
  "ad": {
    "user": "JohnSmith",
    "group": "VPN Users",
    "desiredState": "present",
    "dryRun": true
  }
}

For user attribute write actions:

{
  "ad": {
    "user": "JohnSmith",
    "attribute": "telephoneNumber",
    "attributeAction": "set",
    "value": "12345",
    "valueType": "string",
    "dryRun": true
  }
}

For multiple user attribute changes:

{
  "ad": {
    "user": "JohnSmith",
    "attributeChanges": [
      {
        "attribute": "telephoneNumber",
        "action": "set",
        "value": "12345",
        "type": "string"
      },
      {
        "attribute": "mobile",
        "action": "clear"
      }
    ],
    "dryRun": true
  }
}

Only the primary input paths listed in the input table are configurable; option override paths remain fixed. Property paths are relative to msg, so ad.username means msg.ad.username.

Object lookup

Object lookup result handling

LDAP search references/referrals are kept only in msg.payload.raw.searchReferences when raw output is enabled. They are not counted as lookup results and do not appear as empty objects in msg.payload.objects.

Object lookup sets msg.payload.object when exactly one object is returned. msg.payload.objects remains the stable array output for zero, one or many results.

Object lookup can return password expiration details for user objects using the Active Directory computed attribute msDS-UserPasswordExpiryTimeComputed.

Object lookup can resolve a user's manager and direct reports, and empty LDAP attributes are normalized to null in flow-friendly output.

Computer lookups accept sAMAccountName values with or without the trailing $, support dNSHostName as a guided search field, and return readable computer lastLogonTimestamp plus calculated enabled.

The configuration node includes a connection test and supports a server-side CA certificate path.

Object lookup can return stale user/computer status, compact summaries and extended group analysis. Membership checks include a group membership path for direct or nested membership.

Object lookup is the guided lookup node for common AD object searches.

Supported object types:

  • User
  • Group
  • Computer
  • Contact
  • Organizational Unit
  • Any object
  • Custom LDAP filter

Supported search fields:

  • sAMAccountName
  • userPrincipalName
  • cn
  • name
  • mail
  • displayName
  • distinguishedName
  • dNSHostName
  • Custom attribute

Default input:

{
  "ad": {
    "searchValue": "JohnSmith"
  }
}

Every important Object lookup setting can also be overridden per message:

{
  "ad": {
    "baseDN": "DC=example,DC=com",
    "objectType": "user",
    "searchField": "sAMAccountName",
    "searchValue": "JohnSmith",
    "additionalAttributes": ["department", "telephoneNumber"],
    "returnFirstOnly": true,
    "requireExactlyOne": true,
    "setAdDn": true,
    "returnAccountStatus": true,
    "returnPasswordExpiration": true,
    "passwordExpirationWarningDays": 14,
    "returnManager": true,
    "returnDirectReports": true,
    "returnRaw": false
  }
}

For computer lookups with Search field = sAMAccountName, the trailing $ is optional. A search value such as PC123 internally matches both PC123 and PC123$. Computer objects can also be searched by dNSHostName.

For a custom attribute search:

{
  "ad": {
    "objectType": "user",
    "searchField": "custom",
    "customSearchAttribute": "employeeID",
    "searchValue": "12345"
  }
}

As a convenience, a valid LDAP attribute name can also be passed directly as msg.ad.searchField:

{
  "ad": {
    "objectType": "user",
    "searchField": "employeeID",
    "searchValue": "12345"
  }
}

Resolve a distinguished name

Use Object lookup to resolve a DN with:

  • Require exactly one enabled
  • Set msg.ad.dn enabled

This makes the node fail clearly when the lookup returns no object or more than one object. If exactly one object with a distinguished name is found, the node also sets msg.ad.dn.

Equivalent message override:

{
  "ad": {
    "objectType": "user",
    "searchField": "sAMAccountName",
    "searchValue": "JohnSmith",
    "requireExactlyOne": true,
    "setAdDn": true
  }
}

Successful output keeps the normal msg.payload format and additionally sets:

{
  "ad": {
    "dn": "CN=John Smith,OU=Users,DC=example,DC=com"
  }
}

If no object is found or the lookup is ambiguous, msg.payload.error contains a clear message and msg.error is set.

For groups, additional detail options can also be overridden by message:

{
  "ad": {
    "objectType": "group",
    "searchField": "cn",
    "searchValue": "ExampleGroup",
    "groupDetails": "allDetails",
    "memberFilter": "users"
  }
}

Valid groupDetails values:

  • groupOnly
  • directMembers
  • recursiveMembers
  • memberOf
  • allDetails

Valid memberFilter values:

  • all
  • users
  • groups
  • computers

Example output:

{
  "success": true,
  "operation": "objectLookup",
  "objectType": "user",
  "searchField": "sAMAccountName",
  "searchValue": "JohnSmith",
  "count": 1,
  "object": {
    "dn": "CN=John Smith,OU=Users,DC=example,DC=com",
    "distinguishedName": "CN=John Smith,OU=Users,DC=example,DC=com",
    "sAMAccountName": "JohnSmith",
    "userPrincipalName": "[email protected]",
    "displayName": "John Smith",
    "mail": "[email protected]",
    "department": "IT",
    "accountStatus": {
      "enabled": true,
      "locked": false,
      "passwordNeverExpires": false,
      "accountExpires": false,
      "lastLogonTimestamp": "2026-06-19T08:15:00.000Z",
      "pwdLastSet": "2026-05-20T08:15:00.000Z"
    }
  },
  "objects": [
    {
      "dn": "CN=John Smith,OU=Users,DC=example,DC=com",
      "distinguishedName": "CN=John Smith,OU=Users,DC=example,DC=com",
      "sAMAccountName": "JohnSmith",
      "userPrincipalName": "[email protected]",
      "displayName": "John Smith",
      "mail": "[email protected]",
      "department": "IT",
      "accountStatus": {
        "enabled": true,
        "locked": false,
        "passwordNeverExpires": false,
        "accountExpires": false,
        "lastLogonTimestamp": "2026-06-19T08:15:00.000Z",
        "pwdLastSet": "2026-05-20T08:15:00.000Z"
      }
    }
  ]
}

Example output with no match:

{
  "success": true,
  "operation": "objectLookup",
  "objectType": "user",
  "searchField": "sAMAccountName",
  "searchValue": "NoSuchUser",
  "count": 0,
  "objects": []
}

msg.payload.object is set when exactly one object is returned. This makes the common unique-lookup case easier to use in later Function, Change or Template nodes while keeping msg.payload.objects available for multi-result searches.

If Return first only is enabled and more than one object was found, count contains the number of returned objects and totalCount contains the number of matches before truncation.

Computer object output

For Object type = Computer, the normalized output converts lastLogonTimestamp to ISO format and calculates enabled from userAccountControl. Raw output still contains the original LDAP values when Return raw data is enabled.

Example computer output:

{
  "objectType": "computer",
  "searchField": "sAMAccountName",
  "searchValue": "PC123",
  "count": 1,
  "object": {
    "dn": "CN=PC123,OU=Computers,DC=example,DC=com",
    "distinguishedName": "CN=PC123,OU=Computers,DC=example,DC=com",
    "cn": "PC123",
    "name": "PC123",
    "sAMAccountName": "PC123$",
    "dNSHostName": "PC123.example.com",
    "operatingSystem": "Windows 11 Pro",
    "operatingSystemVersion": "10.0 (22631)",
    "lastLogonTimestamp": "2026-06-19T08:15:00.000Z",
    "userAccountControl": "4096",
    "enabled": true
  }
}

Example group output:

{
  "success": true,
  "operation": "objectLookup",
  "objectType": "group",
  "searchField": "cn",
  "searchValue": "ExampleGroup",
  "count": 1,
  "objects": [
    {
      "group": {
        "cn": "ExampleGroup",
        "distinguishedName": "CN=ExampleGroup,OU=Groups,DC=example,DC=com"
      },
      "directMembers": [],
      "members": [],
      "effectiveMembers": [],
      "membersRecursive": [],
      "nestedGroups": [],
      "memberCount": 42,
      "directMemberCount": 12,
      "nestedMemberCount": 30,
      "empty": false,
      "nestingDepth": 2,
      "memberOf": []
    }
  ]
}

Account status

For Object type = User, enable Account status to add a calculated accountStatus object to each returned user. The node automatically requests the required attributes even when they are not listed in Additional attributes.

Returned fields:

  • enabled
  • locked
  • passwordNeverExpires
  • accountExpires
  • lastLogonTimestamp
  • pwdLastSet

locked is true when bit 0x0010 is set in msDS-User-Account-Control-Computed, and false when that bit is clear. If the computed value is missing or invalid, locked is null. Flows must treat this field as nullable. A positive lockoutTime does not mean the account is still locked, because Active Directory can leave that timestamp set after the lockout duration expires. accountStatus.locked and summary.locked use this same bit. The node requests msDS-User-Account-Control-Computed for users when it returns account status or the summary.

There is no separate passwordExpired boolean. Enable Password expiration to obtain accountStatus.passwordExpiration from the AD computed expiry attribute; see below. An unavailable expiry value is reported separately from a password that never expires.

Message override:

{
  "ad": {
    "objectType": "user",
    "searchValue": "JohnSmith",
    "returnAccountStatus": true
  }
}

Return raw data

Return raw data adds the internal LDAP result object as msg.payload.raw.

The normalized msg.payload.objects array is the recommended output for flows. In simple tests, raw and normalized data may look identical because the selected attributes are the same. The raw result is mainly intended for debugging library-specific output and is not needed for normal flows.

Password expiration

For Object type = User, Object lookup can add password expiration details to accountStatus:

{
  "accountStatus": {
    "enabled": true,
    "locked": false,
    "passwordNeverExpires": false,
    "accountExpires": false,
    "lastLogonTimestamp": "2026-06-19T08:15:00.000Z",
    "pwdLastSet": "2026-05-20T08:15:00.000Z",
    "passwordExpiration": {
      "expires": true,
      "passwordExpires": "2026-07-15T08:00:00.000Z",
      "passwordExpiresInDays": 26,
      "warning": false,
      "warningThresholdDays": 14
    }
  }
}

Enable it in the node settings with Password expiration or override it per message:

{
  "ad": {
    "returnPasswordExpiration": true,
    "passwordExpirationWarningDays": 14
  }
}

The node uses the AD computed attribute msDS-UserPasswordExpiryTimeComputed. Passwords that never expire return passwordExpires: false; accounts that must change the password at next logon return passwordExpires: "now".

Manager and direct reports

For Object type = User, Object lookup can resolve organizational relationships from the AD attributes manager and directReports.

Options:

  • Return manager
  • Manager attributes
  • Direct reports
  • Report attributes

Message overrides:

{
  "ad": {
    "returnManager": true,
    "managerAttributes": ["displayName", "mail", "sAMAccountName"],
    "returnDirectReports": true,
    "directReportAttributes": ["displayName", "mail", "sAMAccountName", "department"]
  }
}

Example output inside a user object:

{
  "manager": {
    "dn": "CN=Max Manager,OU=Users,DC=example,DC=com",
    "displayName": "Max Manager",
    "mail": "[email protected]",
    "sAMAccountName": "MaxManager"
  },
  "directReports": [
    {
      "dn": "CN=Alice Employee,OU=Users,DC=example,DC=com",
      "displayName": "Alice Employee",
      "mail": "[email protected]",
      "sAMAccountName": "AliceEmployee",
      "department": "IT"
    }
  ]
}

If a requested LDAP attribute is present as an empty value from the LDAP library, normalized output returns null instead of an empty array such as []. Raw output may still show library-specific details when Return raw data is enabled.

Stale status and object summary

For Object type = User and Object type = Computer, Object lookup can evaluate inactivity from lastLogonTimestamp. The default inactive threshold is 90 days and can be overridden with msg.ad.staleThresholdDays. For users, summary.locked is the same nullable lockout bit as accountStatus.locked.

{
  "staleStatus": {
    "stale": true,
    "lastLogonTimestamp": "2024-11-15T08:00:00.000Z",
    "inactiveDays": 220,
    "inactiveThresholdDays": 90
  },
  "summary": {
    "type": "user",
    "enabled": true,
    "locked": false,
    "stale": true,
    "passwordNeverExpires": false,
    "hasManager": true,
    "hasMail": true,
    "directGroupCount": 3,
    "groupCount": 12
  }
}

Group analysis

For Object type = Group, Object lookup can return nested groups, effective recursive members, direct/effective member counts, empty group status and child group nesting depth.

When Group return requests direct or recursive members, the flow-friendly fields are returned automatically:

  • directMembers for direct group members
  • effectiveMembers for recursive/effective group members
  • members and membersRecursive are also returned as aliases
  • memberCount, directMemberCount, nestedMemberCount, empty, nestedGroups and nestingDepth are included with group details
{
  "group": {
    "cn": "ExampleGroup",
    "distinguishedName": "CN=ExampleGroup,OU=Groups,DC=example,DC=com"
  },
  "directMembers": [],
  "effectiveMembers": [],
  "nestedGroups": [],
  "memberCount": 42,
  "directMemberCount": 12,
  "nestedMemberCount": 30,
  "empty": false,
  "nestingDepth": 2
}

LDAP query

LDAP query is the technical expert node for free LDAP filters. It keeps the generic query use case separate from the guided Object lookup node.

Supported options:

  • LDAP filter via msg.ad.query
  • Base-DN override via msg.ad.baseDN
  • Search scope via msg.ad.scope: base, one or sub
  • Attributes via msg.ad.attributes, as array or comma-separated string
  • configured Size Limit
  • configured Time Limit in seconds
  • optional paged search with configurable page size

Example input:

{
  "ad": {
    "baseDN": "DC=example,DC=com",
    "query": "(objectClass=user)",
    "scope": "sub",
    "attributes": ["displayName", "mail", "department"]
  }
}

The result is written to the configured output property. The default is msg.payload.

Primary groups and LDAP filter bytes

Membership checks and required-group authorization include the user primary group and its parent groups, using primaryGroupID together with the account domain SID. Returned paths include the primary-group edge. User summary group counts include the primary group and deduplicate group DNs. AD does not represent primary membership in memberOf/member links; raw group-object member lists continue to describe those explicit directory links. See the Microsoft primaryGroupID definition. A missing group returns GROUP_NOT_FOUND even when supplied as a DN.

LDAP query and custom lookup filters preserve RFC4515 escaped bytes for objectSid, objectGUID and UTF-8 values. The common search layer ensures SID/GUID attributes are read as bytes before normalization; it keeps ldapts filter grammar validation while avoiding UTF-8 re-encoding of escaped binary octets. See RFC4515.

Output

Node results are written to msg.payload by default.

All result-producing nodes support Advanced settings → Output path. This path is independent of Use custom input paths and is relative to msg; an empty value uses payload. Use a path such as ad.result, result, lookup or ad.object if the original msg.payload should be preserved.

Every result-producing node uses the same two base properties:

  • success - whether the node completed its technical/input/configuration operation successfully
  • operation - a stable machine-readable operation name

Result-specific state remains separate. For example, a completed membership check can return success: true together with member: false. Authentication uses authenticated and authorized; write nodes additionally use dryRun, changed and alreadyInDesiredState. Error results use success: false and include the structured error object. Expected negative authentication/authorization results are represented by their dedicated result fields and may still have success: true when the evaluation itself completed correctly.

This applies to the configured output property. Object lookup can additionally set msg.ad.dn when requested.

Example output from Authenticate user:

{
  "success": true,
  "operation": "authenticateUser",
  "authenticated": true,
  "authorized": true,
  "username": "[email protected]",
  "user": {
    "dn": "CN=John Smith,OU=Users,DC=example,DC=com",
    "sAMAccountName": "JohnSmith",
    "userPrincipalName": "[email protected]",
    "displayName": "John Smith",
    "mail": "[email protected]",
    "department": "IT"
  }
}

Example output from Is user member of:

{
  "success": true,
  "operation": "checkGroupMembership",
  "user": "[email protected]",
  "userSearchField": "auto",
  "group": "GG_NodeRed_Admins",
  "groupDn": "CN=GG_NodeRed_Admins,OU=Groups,DC=example,DC=com",
  "member": true,
  "path": [
    "CN=John Smith,OU=Users,DC=example,DC=com",
    "CN=IT,OU=Groups,DC=example,DC=com",
    "CN=GG_NodeRed_Admins,OU=Groups,DC=example,DC=com"
  ]
}

Active Directory configuration

The shared configuration node contains:

  • Protocol: LDAPS (default) or LDAP
  • Domain / DC: domain, hostname or IPv4 address without URL syntax
  • Port: optional integer 1–65535; empty uses 636 for LDAPS or 389 for LDAP
  • optional Base DN
  • bind username
  • bind password
  • optional custom TLS settings
  • optional CA certificate
  • optional CA certificate path on the Node-RED server
  • certificate verification setting
  • built-in connection test

Example: select LDAPS, enter dc01.example.com in Domain / DC, and leave Port empty to use 636. Select LDAP to use port 389 instead. Enter a port only when your server uses a different one. DNS names (including short names) and IPv4 addresses are supported; use DNS for certificate hostname validation. Do not enter a scheme, credentials, port, path or query in Domain / DC.

Bind credentials are stored in Node-RED's credential store. Operation nodes reference the shared configuration by its node ID.

A DNS domain can be entered instead of a specific DC. Automatic SRV discovery and transport failover continue to use the internally constructed LDAP/LDAPS URL. Keep TLS Name empty when discovered DC names match the certificates.

If Base DN is empty, the nodes try to detect it automatically from RootDSE by reading defaultNamingContext.

Bind usernames accept a UPN ([email protected]), a down-level name (EXAMPLE\alice) or a distinguished name. A short sAMAccountName such as alice is qualified before the first password bind as [email protected], using the discovery domain, the DNS domain components of Base DN or an anonymous RootDSE lookup. This is the implicit UPN form supported by AD DS; an explicit userPrincipalName match has precedence on the server. If anonymous RootDSE is restricted and the domain is otherwise unknown, enter a qualified name or configure Base DN. The same handling applies to the connection test, automatic Base DN detection and operation binds. No alternate identities are attempted after a password rejection.

The configuration node includes a Test connection button. It validates the connection fields and checks the resulting LDAP or LDAPS address, bind credentials, RootDSE lookup and effective Base DN. The result includes selected RootDSE attributes such as defaultNamingContext, dnsHostName and namingContexts. If automatic Domain Controller discovery is used, it also reports the selected discovered DC and connection attempts.

LDAPS and TLS

For production use, select LDAPS and enter the DC hostname (for example dc01.example.com) separately.

If Node.js does not trust the internal AD certificate authority, either paste the PEM encoded CA certificate into the configuration node or enter a server-side path in CA Cert Path. The file must be readable by the Node-RED process.

TLS Options enables custom TLS settings for LDAPS, such as certificate verification, TLS Name, inline CA certificate and CA certificate path. With custom TLS options disabled, LDAPS uses the Node.js TLS defaults and the active trust store.

TLS Name sets the server name used for TLS/SNI and certificate hostname validation. It does not change the LDAP server that is contacted. Use it only when Domain / DC uses an alias, short name or IP address and the certificate contains another DNS name, for example dc01.example.com. In most environments this can be left empty.

Verify Cert should remain enabled in production. Disabling certificate verification is useful only for temporary tests.

Example CA certificate paths:

/path/to/ad-root-ca.pem
/usr/local/share/ca-certificates/ad-root-ca.crt

Do not configure a private key in CA Cert or CA Cert Path.

Windows certificate store

Node.js can use Windows trusted CA certificates natively. On Node.js 22.15 and later, start Node-RED with the Node.js option --use-system-ca, for example:

$env:NODE_OPTIONS = '--use-system-ca'
node-red

If NODE_OPTIONS already contains other options, retain them and add this flag. Node.js 22.19 and later also support $env:NODE_USE_SYSTEM_CA = '1' before starting Node-RED. Restart the process after changing startup options. For Windows services, configure the service process environment: Current User certificates belong to the service account, while Local Machine roots are machine-wide. See the Node.js system CA documentation.

Native Windows CA trust was verified in internal tests under an interactive account. Service identities and Linux trust stores still require environment-specific acceptance.

Keep certificate verification enabled and leave CA fields empty when relying on the native store. An explicit ca setting (including the node's CA certificate fields) replaces Node.js's default CA list for that connection. The store provides CA trust; hostname and certificate validity checks still apply. A successful connection test with tls.verified: false and rejectUnauthorized: false confirms encrypted connectivity but does not validate the server certificate.

Security notes

The Authenticate user node receives the user password in clear text inside the Node-RED message. This is unavoidable for a form-based LDAP bind.

The node removes password fields before handing a failed message to node.error and before sending its output, including:

  • msg.ad.password
  • msg.payload.password
  • msg.password
  • the configured Password property and common submitted form fields in msg.req.body
  • known credentials fields
  • msg.tlsOptions

Authentication selects one login identity before binding. A rejected login is not retried with aliases or another DC. DC failover is limited to recognized transport failures; credential, account-state, certificate, permission and unknown errors stop the operation. This also applies to RootDSE discovery and the configuration connection test.

Still, every node before Authenticate user can theoretically read the password. For production login pages:

  • protect the Node-RED editor
  • do not place Debug nodes before authentication
  • do not log complete messages containing passwords
  • use HTTPS for browser-to-Node-RED traffic
  • use LDAPS for Node-RED-to-Domain-Controller traffic
  • prefer a reverse proxy / SSO architecture if Node-RED should never see passwords

Local test environment

See tools/local-test/README.md in the source checkout for the isolated Windows Node-RED test instance, runtime smoke checks and read-only AD readiness checks. Authenticated AD acceptance requires separately supplied test credentials.

Installation

Runtime requirements and compatibility policy

Component Requirement / target Verification status
Node.js Minimum 22.9.0; Node.js 24.x recommended for new installations Current suite and isolated loading verified on 22.9.0 and 24.22.2, each with all three Node-RED versions below
Node-RED Compatibility targets: 4.x and 5.x; package metadata declares >=4.0.0 Current offline Windows matrix passed on 4.0.0, 4.1.18 and 5.0.10; live AD runs remain version-specific
LDAP implementation ldapts ^8.1.8, as declared in package.json Test-double regression coverage and scoped internal live acceptance described under Testing; broader permissions and cross-domain cases remain open
ioBroker A Node-RED adapter instance using the Node.js and Node-RED versions above Installation example provided; the adapter version alone does not establish compatibility

The module's Node.js minimum applies even when Node-RED itself accepts an older Node.js version. Node.js 18/20 are outside this module's declared requirements. Open-ended package ranges do not mean that every newer major version has been tested.

Node-RED's supported Node.js versions recommends Node.js 24.x. The Node-RED 5 release notes specify Node.js 22.9.0 as its minimum. These upstream requirements are separate from this module's verification status. Check the Node.js version used by the actual Node-RED process, especially with ioBroker or a system service.

From a local package

Create a package on your development machine:

cd path/to/node-red-activedirectory
npm test
npm pack

This creates a file similar to:

hansolo72-node-red-activedirectory-0.9.1.tgz

Copy the .tgz file to the target system, for example to /tmp.

Example installation on ioBroker / Node-RED instance node-red.1

sudo iobroker stop node-red.1

sudo -u iobroker -H bash -lc '
cd /opt/iobroker/iobroker-data/node-red.1
npm install /tmp/hansolo72-node-red-activedirectory-0.9.1.tgz --no-audit --no-fund
'

sudo iobroker start node-red.1

Check installation:

sudo -u iobroker -H bash -lc '
cd /opt/iobroker/iobroker-data/node-red.1
npm ls @hansolo72/node-red-activedirectory
node -p "require(\"./node_modules/@hansolo72/node-red-activedirectory/package.json\").version"
'

View logs:

iobroker logs node-red.1 --lines 100

After node HTML changes, reload the Node-RED editor with a hard browser refresh.

Node-RED load check

The package exposes the following Node-RED node types in package.json:

{
  "ms-ad-config": "./nodes/config.js",
  "ms-ad-object-lookup": "./nodes/ms-ad-object-lookup.js",
  "ms-ad-authenticate-user": "./nodes/ms-ad-authenticate-user.js",
  "ms-ad-is-user-member-of": "./nodes/ms-ad-is-user-member-of.js",
  "ms-ad-ldap-query": "./nodes/ms-ad-ldap-query.js",
  "ms-ad-user-account-action": "./nodes/ms-ad-user-account-action.js",
  "ms-ad-group-membership-action": "./nodes/ms-ad-group-membership-action.js",
  "ms-ad-set-user-attribute": "./nodes/ms-ad-set-user-attribute.js"
}

Each JavaScript file has a matching HTML editor file in nodes/.

Remaining work and limitations

  • Active/automatically expired account locks and account-write denial after successful prerequisite reads still need live verification.
  • Other delegated permission models, lost Modify responses and actual DC failover need live acceptance.
  • Cross-domain memberships, large directories and related-lookup paging need broader testing.
  • Windows service identities and Linux live AD/trust-store behavior are not established by offline CI.
  • Object lookup exposes user group counts, not configurable complete user-group lists. Use LDAP query for explicit group queries.
  • Move/rename and password reset/change are not implemented. These are optional future extensions.
  • Some runtime status messages remain English; a separate lint command is not provided.

See ROADMAP.md for current priorities. Testing one schema or administrative account does not establish compatibility with every directory or least-privilege deployment.

License and origin

This package is distributed under the MIT License.

The project started from node-red-contrib-activedirectory by Noé Samaille. It has since been substantially redesigned and extended, including migration from activedirectory2 to ldapts. The original copyright and MIT license notice are retained; the redesign does not remove the upstream attribution.

See NOTICE.md for provenance details. Both LICENSE and NOTICE.md are included in the npm package.

Dynamic node label

The palette still shows the generic node name Object lookup. In the flow workspace, the node label changes automatically according to the selected object type if the optional Name field is empty:

  • User → User lookup
  • Group → Group lookup
  • Computer → Computer lookup
  • Contact → Contact lookup
  • Organizational Unit → OU lookup
  • Any object → Object lookup
  • Custom LDAP filter → LDAP filter lookup

If Name is set, the custom name has priority.

Attribute suggestions and value types

Set attribute offers 53 editable suggestions, including title, employeeID, employeeNumber, employeeType and carLicense. Type another LDAP attribute name when needed; server schema and access rights still apply. Selecting a known attribute prefills its suggested type. Opening a saved node preserves its type; manual edits and message overrides remain supported. Unknown names leave the type unchanged.

employeeNumber remains string to preserve leading zeros; countryCode uses number; manager/assistant use dn; multi-valued text uses multiString; secretary uses multiDn. multiDn accepts DN string arrays or one DN per line. Commas are not list separators.

msg.ad.attribute overrides the editor attribute. msg.ad.attributeAction, msg.ad.valueType and msg.ad.value override action/type/value fallbacks. An msg.ad.attributeChanges array selects batch mode: entry fields (attribute, action, type, value) take precedence over message fields and editor fallbacks. The English and German Input help provides the full precedence rules. See examples 06–08 for working flows.

Set attribute with secretary and multiDn in the English editor

Message overrides and TLS

TLS comes only from AD Config. With custom TLS settings disabled, Node.js defaults apply. msg.tlsOptions is not a supported override and is removed before forwarding messages.

Object lookup accepts msg.ad.returnFirstOnly and msg.ad.returnRaw. All seven operation nodes accept msg.ad.includeErrorDetails (default false); on failures they set the fixed msg.error path as well as the error in the configured output (default msg.payload.error). Technical details can expose infrastructure information; inspect them before sharing logs.

Node Info

Version: 0.9.1
Updated 6 days ago
License: MIT
Rating: not yet rated

Categories

Actions

Rate:

Downloads

0 in the last week

Nodes

  • ms-ad-config
  • ms-ad-object-lookup
  • ms-ad-authenticate-user
  • ms-ad-is-user-member-of
  • ms-ad-ldap-query
  • ms-ad-user-account-action
  • ms-ad-group-membership-action
  • ms-ad-set-user-attribute

Keywords

  • node-red
  • node-red-node
  • active-directory
  • activedirectory
  • ad
  • ldap
  • ldaps
  • tls
  • authentication
  • microsoft

Maintainers