From d5a35f44ed445458751fd0dcd2262dfd4bd21567 Mon Sep 17 00:00:00 2001 From: Cracker <rofl256@googlemail.com> Date: Tue, 27 Feb 2018 00:35:21 +0100 Subject: [PATCH] Update ldapAuth.js --- ldapAuth.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ldapAuth.js b/ldapAuth.js index 06fc7ff..232f0b2 100644 --- a/ldapAuth.js +++ b/ldapAuth.js @@ -55,7 +55,7 @@ function loadServer() { }); //2. Searching for user (We just save it for now and return a success) - server.search('ou=Users', function(req, res, next) { + server.search('ou=user', function(req, res, next) { var cId = req["connection"]["ldap"]["id"]; if(!req["filter"] || !req["filter"]["filters"] || !req["filter"]["filters"][0] || !req["filter"]["filters"][0]["raw"]) { if(errorCallback) { @@ -67,16 +67,23 @@ function loadServer() { cids[cId] = userName; var dn = req.dn.toString(); - res.send({ - dn: dn, - status : 0, - attributes: {status:0} - }); + var obj = { + dn: 'cn=auth, ou=user', + status : 0, //Success + attributes: { + "cn" : "user", + status:0, + "username" : userName.split("@")[0], + "mail" : userName + } + } + res.send(obj); res.end(); + return next(); }); //3. Getting password. Then check user an password combination... - server.bind('ou=Users', function(req, res, next) { + server.bind('ou=user', function(req, res, next) { var dn = req.dn.toString(); var cId = req["connection"]["ldap"]["id"]; var userPassword = req["credentials"]; @@ -88,6 +95,7 @@ function loadServer() { if(checkPassword) { checkPassword({"userName" : userName, "userPassword": userPassword}, function(isCorrectPw) { if(isCorrectPw) { + console.log("Vaild LOGIN") return res.end(); } else { return next(new ldap.InvalidCredentialsError()); -- GitLab