Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Ldapjs Client
https://github.com/zont/ldapjs-client
Admin
LDAP Client API for node.js
Tokens:
819
Snippets:
9
Trust Score:
7.6
License:
MIT
Update:
1 year ago
Context
Chat
Benchmark
59.29
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Initializing LdapClient in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Creates a new LdapClient instance with the specified URL. The URL specifies the LDAP server address. Other options such as timeout and TLS options can also be configured. ```javascript var LdapClient = require('ldapjs-client'); var client = new LdapClient({ url: 'ldap://127.0.0.1:389' }); ``` -------------------------------- ### Adding an Entry to LDAP Directory in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Adds a new entry to the LDAP directory. The entry is a JavaScript object containing the attributes to be added. Error handling is included to catch potential exceptions during the add operation. ```javascript try { const entry = { cn: 'foo', sn: 'bar', email: ['foo@bar.com', 'foo1@bar.com'], objectclass: 'fooPerson' }; await client.add('cn=foo, o=example', entry); } catch (e) { console.log('Add failed'); } ``` -------------------------------- ### Searching the LDAP Directory in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Searches the LDAP directory for entries matching the specified criteria. The options object specifies the search filter, scope, and attributes to be returned. Error handling is included to catch potential exceptions during the search operation. ```javascript try { const options = { filter: '(&(l=Seattle)(email=*@foo.com))', scope: 'sub', attributes: ['dn', 'sn', 'cn'] }; const entries = await client.search('o=example', options); } catch (e) { console.log(e); } ``` -------------------------------- ### Binding to LDAP Server in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Authenticates to the LDAP server using a username and password. Error handling is included to catch potential exceptions during the bind operation. ```javascript try { await client.bind('username', 'password'); } catch (e) { console.log('Bind failed'); } ``` -------------------------------- ### Modifying an LDAP Entry in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Modifies an existing entry in the LDAP directory. The change object specifies the operation (add, delete, or replace) and the modification to be applied. Error handling is included to catch potential exceptions during the modify operation. ```javascript try { const change = { operation: 'add', // add, delete, replace modification: { pets: ['cat', 'dog'] } }; await client.modify('cn=foo, o=example', change); } catch (e) { console.log(e); } ``` -------------------------------- ### Unbinding from LDAP Server in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Unbinds from the LDAP server, closing the connection. Error handling is included to catch potential exceptions during the unbind operation. ```javascript try { await client.unbind(); } catch (e) { console.log(e); } ``` -------------------------------- ### Destroying the LDAP Client in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Destroys the LDAP client, closing the connection and releasing resources. Error handling is included to catch potential exceptions during the destroy operation. ```javascript try { await client.destroy(); } catch (e) { console.log(e); } ``` -------------------------------- ### Deleting an Entry from LDAP Directory in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Deletes an entry from the LDAP directory. The distinguished name (DN) of the entry to be deleted is specified. Error handling is included to catch potential exceptions during the delete operation. ```javascript try { await client.del('cn=foo, o=example'); } catch (e) { console.log(e); } ``` -------------------------------- ### Modifying an LDAP Entry's DN in JavaScript Source: https://github.com/zont/ldapjs-client/blob/master/README.md Modifies the distinguished name (DN) of an existing entry in the LDAP directory. Error handling is included to catch potential exceptions during the modifyDN operation. ```javascript try { await client.modifyDN('cn=foo, o=example', 'cn=bar'); } catch (e) { console.log(e); } ```