openldapjs
v1.1.1
Published
A ldap client nodejs
Downloads
6
Readme
OpenLDAP.JS
Node.js wrapper for OpenLDAP. This library allows you to interact through Node.js with a LDAP backend.
Getting Started
- Clone or download repository.
- Install dependencies.
- V8 Embedder's guide Useful documentation + examples if you want a deeper look at how embedding is done.
- Nan Nan examples, documentation and source.
- LDAP & OpenLDAP documentation and resources.
Prerequisites
Why a new library?
Previous implementations lacked certain details such as extended operations' post/pre read which is something we needed dearly. Additionally, other libraries re-implemented the entire protocol (or rather chunks of it) and held the door open for various errors. Relying on the standard openldap C libraries should allow us to be more compatible with openldap servers than other libraries. Adding missing function calls to the interface should be easy due to pre-existing examples and not having to worry about the implementation on the protocol.
Building
OpenLDAP.js requires OpenLDAP development libraries.
Debian/Ubuntu
- OpenLDAP development libraries : sudo apt-get install libldap2-dev currently built with Openldap 2.4.45.
- Make sure you have python2.7 and node-gyp installed. Run
npm install
, it should install dependencies and build the c++ source files.
MacOs
- N/a yet.
Windows
- N/a yet.
Testing
For the tests to run, you'll need some sample test data. In order to do this manually edit the ldapAuthentication
section of the config file and configure your local ldap data :
host: address of your ldap server, E.g:
ldap://localhost:389
userDn: LDAP login Dn, this will be used for authentication. E.g:
cn=admin,dc=demoApp,dc=com
userPassword: Password for your userDn
Also, configure the ldapTestEntries
section in order to tell it where to put the test data:
- entryDn: Entry point for your test data, E.g:
cn=newPoint,o=myhost,dc=demoApp,dc=com
Make sure the user you're providing has sufficient rights (read/write).
After you're done configuring, run npm run addData
, this should add 10k test entries to your ldap Server.
After the sample data is ready, run npm test and the tests should run.
npm test
Test breakdown
The tests are mainly designed for testing all ldap routines (add,delete,search,modify, initialize,bind, unbind, start tls, etc.). Test suite is composed of integration + unit tests.
Deployment
Clone or download the repository.
Get all required packages with npm and build the addon files :
npm install
The Node.JS wrapper for the library is libs/ldap_async_wrap.js, require it in your software like :
const LdapClient = require('openldapjs').Client;
A normal workflow would be :
const ldapClientInstance = new LdapClient('ldap://your_ldap_server:PORT');
ldapClientInstance.initialize()
.then(() => {
return ldapClientInstance.bind(userDn,userPassword)
})
.then( () => {
ldapClientInstance.search(...);
ldapClientInstance.add(...);
ldapClientInstance.delete(...);
ldapClientInstance.modify(...);
});
For more in depth examples please consult Tests and Samples.
Built With
Contributing
This project follows the airbnb lint rules for javascript and Clang google style for the C/C++ addon files. For easier collaboration, please ensure that your code is properly linted/formated before submitting a pull request.
Any pull requests or issue reports are appreciated.
Authors
Reviewers:
Developers:
See also the list of contributors who participated in this project.
License
- This Project is published under the MIT License
- All references: Licenses in use
Acknowledgments
- Hat tip to anyone who's code was used
- node-ldapjs
- Nan and v8
- OpenLDAP