ldap-verifyuser
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -5,3 +5,3 @@ #!/usr/bin/env node | ||
* | ||
* Copyright (C) 2015 Hendrik 'Xendo' Meyer | ||
* Copyright (C) 2015-2016 Hendrik 'T4cC0re' Meyer | ||
* | ||
@@ -14,45 +14,79 @@ * This software may be modified and distributed under the terms | ||
verifyUser: function (config, username, password, callback){ | ||
verifyUser: function (config, username, password, callback) { | ||
var client = require("ldapjs-hotfix").createClient({url: config.server, tlsOptions: config.tlsOptions || {}}); | ||
config = config || {}; | ||
client.bind(config.adrdn + username, password, function(err) { | ||
if(!err){ | ||
if(config.debug){console.log("bound with user's credentials");} | ||
var opts = { | ||
filter: '(&(sAMAccountName=' + username + '))', | ||
scope: 'sub' | ||
} | ||
client.search(config.adquery, opts, function(err, res){ | ||
var data = { | ||
raw: null, | ||
valid: false, | ||
locked: true | ||
} | ||
res.on('searchEntry', function(entry) { | ||
data.raw = entry.object; | ||
data.valid = true; | ||
if (Number(entry.object.lockoutTime) == 0){ | ||
if(config.debug){console.log("account not locked and valid!");} | ||
data.locked = false; | ||
} | ||
}); | ||
res.on('error', function(err) { | ||
if(config.debug){console.error(error, err.message);} | ||
callback(err, {status: 1}); | ||
}); | ||
res.on('end', function(result) { | ||
if(config.debug){console.log('status: ' + result.status);} | ||
callback(null, data); | ||
}); | ||
if(err){ | ||
callback(err, {status: 1}); | ||
} | ||
}); | ||
} else { | ||
if(config.debug){console.error(error, err.message);} | ||
callback(err, {status: 1}); | ||
} | ||
}); | ||
var client = require("ldapjs-hotfix") | ||
.createClient( | ||
{ | ||
url : config.server, | ||
tlsOptions: config.tlsOptions || {} | ||
} | ||
); | ||
var bindAdrdn = config.adrdn + username; | ||
if (config.rawAdrdn) { | ||
bindAdrdn = config.adrdn; | ||
} | ||
client.bind( | ||
bindAdrdn, password, function (err) { | ||
if (!err) { | ||
if (config.debug) { | ||
console.log( | ||
"bound with " + config.rawAdrdn | ||
? "with raw adrdn" | ||
: "user credentials" | ||
); | ||
} | ||
var opts = { | ||
filter: '(&(sAMAccountName=' + username + '))', | ||
scope : 'sub' | ||
}; | ||
client.search( | ||
config.adquery, opts, function (err, res) { | ||
var data = { | ||
raw : null, | ||
valid : false, | ||
locked: true | ||
}; | ||
res.on( | ||
'searchEntry', function (entry) { | ||
data.raw = entry.object; | ||
data.valid = true; | ||
if (Number(entry.object.lockoutTime) == 0) { | ||
if (config.debug) { | ||
console.log( | ||
"account not locked and valid!" | ||
); | ||
} | ||
data.locked = false; | ||
} | ||
} | ||
); | ||
res.on( | ||
'error', function (err) { | ||
if (config.debug) {console.error("error", err.message);} | ||
callback(err, {status: 1}); | ||
} | ||
); | ||
res.on( | ||
'end', function (result) { | ||
if (config.debug) {console.log('status: ' + result.status);} | ||
callback(null, data); | ||
} | ||
); | ||
if (err) { | ||
callback(err, {status: 1}); | ||
} | ||
} | ||
); | ||
} else { | ||
if (config.debug) {console.error("error", err.message);} | ||
callback(err, {status: 1}); | ||
} | ||
} | ||
); | ||
} | ||
} | ||
}; |
{ | ||
"name": "ldap-verifyuser", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "ldap-verifyuser is a node.js library based on ldapjs, that authenticates a user against a LDAP or AD without requiring an configured administrator account.", | ||
"author": "Hendrik 'Xendo' Meyer <mail@xendo.red>", | ||
"author": "Hendrik 'T4cC0re' Meyer <mail@t4cc0.re>", | ||
"contributors": [{ | ||
"name": "Hendrik 'Xendo' Meyer", | ||
"email": "mail@xendo.red" | ||
"name": "Hendrik 'T4cC0re' Meyer", | ||
"email": "mail@t4cc0.re" | ||
}], | ||
@@ -13,6 +13,6 @@ "main": "lib/verifyUser.js", | ||
"type": "git", | ||
"url": "https://github.com/butterkekstorte/ldap-verifyuser" | ||
"url": "https://github.com/T4cC0re/ldap-verifyuser" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/butterkekstorte/ldap-verifyuser/issues" | ||
"url": "https://github.com/T4cC0re/ldap-verifyuser/issues" | ||
}, | ||
@@ -19,0 +19,0 @@ "keywords": [ |
@@ -17,3 +17,4 @@ # ldap-verifyuser | ||
adquery: 'dc=MYCORP,dc=LOCAL', | ||
debug: false | ||
debug: false, | ||
rawAdrdn: false | ||
}, | ||
@@ -35,2 +36,4 @@ username = 'myacc', | ||
Set `config.rawAdrdn` to `true` to use the supplied `adrdn` without modifications/appending the username. | ||
## Installation | ||
@@ -37,0 +40,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32265
16
82
53