My company has a ldap server, I try to test the ldap connection using nodejs with ldapjs module, I just want to test the connection at the first place, so no search function is included.
here is the code:
exports.authenticate = function(req, res){
var ldap = require('ldapjs');
var username = req.body.username;
var password = req.body.password;
var client = ldap.createClient({
url: 'LDAP://192.168.3.220/'
});
client.bind(username, password, function (err) {
if(err){
res.send(err);
}else{
res.send('login');
});
};
when I input correct username and password, it sends back "login", which is expected. when I input correct username but wrong password, it sends back the err object, which is also expected.
here is the problem: when I input valid username or invalid username (such as "fjdkfjdklsjfsjd") without password, it also sends back "login", which is abnormal.
I am new to ldap and ldapjs, so it might be just a simple mistake but I could not figure it out. Please help....