{"id":18489,"library":"ldap-filter","title":"ldap-filter","description":"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.","status":"active","version":"0.3.3","language":"javascript","source_language":"en","source_url":"git://github.com/pfmooney/node-ldap-filter","tags":["javascript"],"install":[{"cmd":"npm install ldap-filter","lang":"bash","label":"npm"},{"cmd":"yarn add ldap-filter","lang":"bash","label":"yarn"},{"cmd":"pnpm add ldap-filter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only. CommonJS require will fail. Use dynamic import() if needed.","wrong":"const { parseString } = require('ldap-filter')","symbol":"parseString","correct":"import { parseString } from 'ldap-filter'"},{"note":"Filter is a base class, also a named export.","wrong":"const Filter = require('ldap-filter').Filter","symbol":"Filter","correct":"import { Filter } from 'ldap-filter'"},{"note":"Also available: PresenceFilter, SubstringFilter, GreaterOrEqualFilter, LessOrEqualFilter, AndFilter, OrFilter, NotFilter, ApproxFilter.","wrong":"const EqualityFilter = require('ldap-filter').EqualityFilter","symbol":"EqualityFilter","correct":"import { EqualityFilter } from 'ldap-filter'"}],"quickstart":{"code":"import { parseString, EqualityFilter } from 'ldap-filter';\n\n// Parse an LDAP filter string\nconst filter = parseString('(cn=John Doe)');\nconsole.log(filter.constructor.name); // EqualityFilter\nconsole.log(filter.attribute); // 'cn'\nconsole.log(filter.value); // 'John Doe'\nconsole.log(filter.toString()); // '(cn=John Doe)'\n\n// Or build a filter programmatically\nconst eqFilter = new EqualityFilter({\n  attribute: 'uid',\n  value: 'jdoe'\n});\nconsole.log(eqFilter.toString()); // '(uid=jdoe)'\n\n// Chain filters with boolean combinators\nimport { AndFilter, OrFilter } from 'ldap-filter';\nconst andFilter = new AndFilter({\n  filters: [\n    new EqualityFilter({ attribute: 'sn', value: 'Doe' }),\n    new EqualityFilter({ attribute: 'givenName', value: 'John' })\n  ]\n});\nconsole.log(andFilter.toString()); // '(&(sn=Doe)(givenName=John))'","lang":"typescript","description":"Parses an LDAP filter string and builds filters programmatically, demonstrating EqualityFilter and boolean combinators."},"warnings":[{"fix":"Upgrade Node.js to >=0.8 or stick with older version 0.2.x","message":"Version 0.3.x drops support for Node.js < 0.8","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Check future releases for migration guides; currently parseString still works.","message":"The parseString function may be deprecated in future versions in favor of a class method.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Use `filter.attribute` and `filter.value` directly; consider encoding with encodeURIComponent if required.","message":"Filter values are not escaped by default; manual escaping may be needed for special characters.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Validate input before parsing; use try-catch to handle potential parse errors.","message":"The package does not validate filter string syntax; invalid filters may return unexpected objects.","severity":"gotcha","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install ldap-filter and use import { parseString } from 'ldap-filter'","cause":"Package not installed or import path incorrect.","error":"Cannot find module 'ldap-filter'"},{"fix":"Use import { parseString } from 'ldap-filter' or const { parseString } = await import('ldap-filter')","cause":"Using require('ldap-filter') which returns a module with default export instead of named exports.","error":"TypeError: ldap_filter_1.parseString is not a function"},{"fix":"Add 'type': 'module' to package.json or use dynamic import().","cause":"Project is not configured for ESM (e.g., CommonJS only).","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}