diff --git a/ldapAuth.js b/ldapAuth.js index 06fc7ff24942bb2b9172afdac96d2c969b08bd78..232f0b2229a987a4628a481dd091cccdce05b535 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());