Last active
July 6, 2017 00:18
-
-
Save nomoney4me/988e929a9eed13ac967b676a7710a975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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