Registry / auth-security / ldap-filter

ldap-filter

JSON →
library1.0.1jsnpmunverified

API for handling LDAP-style filters, originally derived from filter code in LDAPjs. Version 0.3.3 is the latest stable release. This package provides utilities to parse, serialize, and manipulate LDAP filter strings (e.g., RFC 4515). It is minimal and focused, suitable for server-side Node.js applications that need to handle LDAP filter syntax without the full LDAPjs library. Release cadence is low; no major updates since 2019.

npm install ldap-filter
INSTALL
IMPORT
SIG · LDAP-FILTER
L
ldap-filter
auth-securityjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parseString
import { parseString } from 'ldap-filter'
const { parseString } = require('ldap-filter')
Package is ESM-only. CommonJS require will fail. Use dynamic import() if needed.
Filter
import { Filter } from 'ldap-filter'
const Filter = require('ldap-filter').Filter
Filter is a base class, also a named export.
EqualityFilter
import { EqualityFilter } from 'ldap-filter'
const EqualityFilter = require('ldap-filter').EqualityFilter
Also available: PresenceFilter, SubstringFilter, GreaterOrEqualFilter, LessOrEqualFilter, AndFilter, OrFilter, NotFilter, ApproxFilter.

Parses an LDAP filter string and builds filters programmatically, demonstrating EqualityFilter and boolean combinators.

import { parseString, EqualityFilter } from 'ldap-filter'; // Parse an LDAP filter string const filter = parseString('(cn=John Doe)'); console.log(filter.constructor.name); // EqualityFilter console.log(filter.attribute); // 'cn' console.log(filter.value); // 'John Doe' console.log(filter.toString()); // '(cn=John Doe)' // Or build a filter programmatically const eqFilter = new EqualityFilter({ attribute: 'uid', value: 'jdoe' }); console.log(eqFilter.toString()); // '(uid=jdoe)' // Chain filters with boolean combinators import { AndFilter, OrFilter } from 'ldap-filter'; const andFilter = new AndFilter({ filters: [ new EqualityFilter({ attribute: 'sn', value: 'Doe' }), new EqualityFilter({ attribute: 'givenName', value: 'John' }) ] }); console.log(andFilter.toString()); // '(&(sn=Doe)(givenName=John))'
Debug
Known issues
breakingVersion 0.3.x drops support for Node.js < 0.8
fix
Upgrade Node.js to >=0.8 or stick with older version 0.2.x
affects: >=0.3.0
deprecatedThe parseString function may be deprecated in future versions in favor of a class method.
fix
Check future releases for migration guides; currently parseString still works.
affects: >=0.3.0
gotchaFilter values are not escaped by default; manual escaping may be needed for special characters.
fix
Use `filter.attribute` and `filter.value` directly; consider encoding with encodeURIComponent if required.
affects: >=0.3.0
gotchaThe package does not validate filter string syntax; invalid filters may return unexpected objects.
fix
Validate input before parsing; use try-catch to handle potential parse errors.
affects: >=0.3.0
Errors
Common errors & fixes
Cannot find module 'ldap-filter'
Package not installed or import path incorrect.
fix
npm install ldap-filter and use import { parseString } from 'ldap-filter'
TypeError: ldap_filter_1.parseString is not a function
Using require('ldap-filter') which returns a module with default export instead of named exports.
fix
Use import { parseString } from 'ldap-filter' or const { parseString } = await import('ldap-filter')
SyntaxError: Unexpected token 'export'
Project is not configured for ESM (e.g., CommonJS only).
fix
Add 'type': 'module' to package.json or use dynamic import().
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
ldap-filter — npm install ldap-filter · libregistry