Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Last active July 6, 2017 00:18
Show Gist options
  • Save nomoney4me/988e929a9eed13ac967b676a7710a975 to your computer and use it in GitHub Desktop.
Save nomoney4me/988e929a9eed13ac967b676a7710a975 to your computer and use it in GitHub Desktop.
require('dotenv').config()
var ldap = require('ldapjs')
, Promise = require('bluebird')
process.env.NOD_TLS_REJECT_UNAUTHORIZED = "0";
var client = ldap.createClient({
url: process.env.ldaphost
});
client.bind(process.env.ldapuser, process.env.ldappass, function(err) {
if(err) {
console.log(err)
}
console.log('binded')
var opts = {
filter: '(sAMAccountName='+process.env.ldapuser+')',
scope: 'sub'
}
const clientSearch = Promise.promisify(
client.search('dc=example, dc=org', opts, function(err, res) {
if(err) {
console.log('search err: '+err)
}
res.on('searchEntry', function(entry) {
console.log('entry: ' + entry.object.entry);
});
})
)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment