I have saslauthd
service installed on my Ubuntu (sudo apt-get install sasl2-bin
). I configured saslauth to use LDAP
for user authentication and /etc/default/saslauthd
now looks like this:
# /etc/default/saslauthd
START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="ldap"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/run/saslauthd"
Next I configured LDAP binding in /etc/saslauthd.conf
.
# /etc/saslauthd.conf
ldap_servers: ldap://192.168.1.100:1389
ldap_filter: (mail=%u)
ldap_search_base: o=users
I would like to write a simple nodejs-based LDAP server that would authenticate user based on the (mail=%u)
filter. For start it would be great to always say success
. I decided to use ldapjs
for this (here) - no decurity is needed because the ldap service will run on localhost.
var ldap = require('ldapjs');
var server = ldap.createServer();
server.search('o=users', function(req, res, next) {
console.log("I see this log!");
// The idea is to look for a user in mongodb
res.end();
return next();
});
server.listen(1389, function() {
console.log('LDAP server up at: %s', server.url);
});
I work with LDAP for the first time and I guess I don't have all the attributes for this server to work :). The server always fails to authenticate. The log file says
Sep 2 12:33:14 ubuntu saslauthd[19907]: Entry not found ((mail=user1)).
Sep 2 12:33:14 ubuntu saslauthd[19907]: Authentication failed for user1: User not found (-6)
Sep 2 12:33:14 ubuntu saslauthd[19907]: do_auth : auth failure: [user=user1] [service=] [realm=] [mech=ldap] [reason=Unknown]
The res.end();
call should always return success
but it seems that the server should respond differently or smth.
The question is how to write such server that would working with saslauthd
. Thanks!s