mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 22:10:22 +00:00
Add extra logging in ldap
This commit is contained in:
parent
6eb2af1bd8
commit
7da036bf34
1 changed files with 12 additions and 5 deletions
|
@ -18,12 +18,18 @@ function ldapAuthCommon(user, bindDN, password, callback) {
|
||||||
|
|
||||||
ldapclient.on("error", function(err) {
|
ldapclient.on("error", function(err) {
|
||||||
log.error(`Unable to connect to LDAP server: ${err}`);
|
log.error(`Unable to connect to LDAP server: ${err}`);
|
||||||
callback(!err);
|
callback(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
ldapclient.bind(bindDN, password, function(err) {
|
ldapclient.bind(bindDN, password, function(err) {
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
callback(!err);
|
|
||||||
|
if (err) {
|
||||||
|
log.error(`LDAP bind failed: ${err}`);
|
||||||
|
callback(false);
|
||||||
|
} else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +73,7 @@ function advancedLdapAuth(user, password, callback) {
|
||||||
|
|
||||||
ldapclient.on("error", function(err) {
|
ldapclient.on("error", function(err) {
|
||||||
log.error(`Unable to connect to LDAP server: ${err}`);
|
log.error(`Unable to connect to LDAP server: ${err}`);
|
||||||
callback(!err);
|
callback(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
ldapclient.bind(config.ldap.searchDN.rootDN, config.ldap.searchDN.rootPassword, function(err) {
|
ldapclient.bind(config.ldap.searchDN.rootDN, config.ldap.searchDN.rootPassword, function(err) {
|
||||||
|
@ -78,7 +84,7 @@ function advancedLdapAuth(user, password, callback) {
|
||||||
} else {
|
} else {
|
||||||
ldapclient.search(base, searchOptions, function(err2, res) {
|
ldapclient.search(base, searchOptions, function(err2, res) {
|
||||||
if (err2) {
|
if (err2) {
|
||||||
log.warn(`User not found: ${userDN}`);
|
log.warn(`LDAP User not found: ${userDN}`);
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
callback(false);
|
callback(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,10 +101,11 @@ function advancedLdapAuth(user, password, callback) {
|
||||||
log.error(`LDAP error: ${err3}`);
|
log.error(`LDAP error: ${err3}`);
|
||||||
callback(false);
|
callback(false);
|
||||||
});
|
});
|
||||||
res.on("end", function() {
|
res.on("end", function(result) {
|
||||||
ldapclient.unbind();
|
ldapclient.unbind();
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
log.warn(`LDAP Search did not find anything for: ${userDN} (${result.status})`);
|
||||||
callback(false);
|
callback(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue