@spurreiter/ldapjs-dn
v1.3.1
Published
API for handling LDAP distinguished name strings
Readme
dn
🚨 Fork from https://github.com/ldapjs/dn
🚨 ESM export
Provides objects for representing and working with LDAP distinguished name strings as defined by RFC 4514.
Usage
npm i @spurreiter/ldapjs-dn
npm i git+ssh://[email protected]:spurreiter/ldapjs-dn#semver:^1Get DN from object, string:
import { DN } from '@spurreiter/ldapjs-dn'
const dn = DN.fromString('cn=foo,st=nice,dn=example,dn=com')
console.log(dn.normalize().toString())
//> 'cn=foo,dn=example,dn=com,st=nice'
const dn2 = DN.fromObject({
cn: 'foo',
st: 'nice',
dn: ['example', 'com'],
})
console.log(dn.toString())
//> 'cn=foo,st=nice,dn=example,dn=com'RFC 4514 escaping/ unescaping:
import { escapeValue, unescapeValue } from '@spurreiter/ldapjs-dn'
console.log(escapeValue('😀'))
//> '\\f0\\9f\\98\\80'
console.log(unescapeValue('\\20\\f0\\9f\\98\\80'))
//> ' 😀'License
MIT.
