I'm trying to write a custom ldap server, using the ldapjs library, acting as proxy to active directory. All the requests different from "bind" should be forwarded to an Active Directory instance.
This is my code:
const ldap = require('ldapjs');
console.log("Launching ldapjs-proxy");
const server = ldap.createServer();
server.bind('', function(req, res, next) {
console.log("-> Inside bind <-");
//Authenticate user based on other mechanisms
if (req.credentials !== 'secret') {
console.log("Invalid credentials for user "+req.dn);
return next(new ldap.InvalidCredentialsError(req.dn.toString()));
}
console.log("Auth successfull "+req.dn);
res.end();
return next();
});
server.listen(1389, () => {
console.log('/etc/passwd LDAP server up at: %s', server.url);
});
The custom bind is working, but I don't know how to forward the other requests to Active Directory.
Any help would be appreciated
Thank you