🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more
Socket
Book a DemoInstallSign in
Socket

@cityssm/activedirectory-authenticate

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cityssm/activedirectory-authenticate

Just Active Directory authentication and nothing more!

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Active Directory Authenticate for Node

Just Active Directory authentication and nothing more!

npm (scoped) DeepSource Code Smells

Based on the work in the deprecated packages activedirectory2 and ldapjs.

Installation

npm install @cityssm/activedirectory-authenticate

Usage

import ActiveDirectoryAuthenticate from '@cityssm/activedirectory-authenticate'

const authenticator = new ActiveDirectoryAuthenticate(
  {
    url: 'ldap://example.com'
  },
  {
    // The base distinguished name (DN) for the LDAP search.
    baseDN: 'DC=example,DC=com',

    // The DN of the user to bind to for searching the directory.
    bindUserDN: 'CN=administrator,DC=example,DC=com',
    bindUserPassword: 'p@ssword',

    // Temporarily cache user bind DNs to reduce LDAP lookups on immediate retries,
    // like typoed passwords.
    cacheUserBindDNs: true
  }
)

const loginResult = await authenticator.authenticate(
  'example\\userName',
  'pass123'
)

if (loginResult.success) {
  // Credentials validated, log the user in!
} else {
  console.log(loginResult.errorType)
  // => "ACCOUNT_NOT_FOUND"
}

Options

import ActiveDirectoryAuthenticate from '@cityssm/activedirectory-authenticate'

const authenticator = new ActiveDirectoryAuthenticate(
  ldapClientUrlOrOptions,
  activeDirectoryAuthenticateOptions
)

ldapClientUrlOrOptions

In most situations, passing an LDAP URL should be sufficient.

If additional configuration is required, like timeout adjustments and TLS settings, see the available ldapts initialization options.

activeDirectoryAuthenticateOptions

OptionDescriptionRequired
baseDNThe base distinguished name (DN) for the LDAP search.
bindUserDNThe DN for the user to bind to for searching the directory.
bindUserPasswordThe password for the bindUserDN.
cacheUserBindDNsWhether or not to temporarily cache user bind DNs, reducing lookups.Default: false

Error Types

Active Directory Authenticate provides descriptive error types, and translates the codes for common Active Directory errors. See the errorType value in the result object.

Error TypeDescriptionActive Directory Code
CONFIGURATION_ERRORConfiguration error.
EMPTY_USER_NAMEUser name empty.
EMPTY_PASSWORDPassword empty.
ACCOUNT_NOT_FOUNDUnable to find the user via LDAP search.
LDAP_SEARCH_FAILEDUnknown error searching LDAP for the user.
AUTHENTICATION_FAILEDUnknown authentication error.
NO_SUCH_USERUser not found.525
LOGON_FAILUREInvalid credentials.52e
INVALID_LOGIN_HOURSUser not permitted to logon at current time.530
INVALID_WORKSTATIONUser not permitted to logon from workstation.531
PASSWORD_EXPIREDPassword expired.532
ACCOUNT_DISABLEDAccount disabled.533
INVALID_LOGIN_TYPEUser not granted the requested logon type.534
ACCOUNT_EXPIREDAccount expired.701
PASSWORD_MUST_CHANGEUser must reset password.773
ACCOUNT_LOCKED_OUTUser account locked.775

Keywords

active-directory

FAQs

Package last updated on 22 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts