mcavage/node-ldapjs — pull request #197 by geirha (2014-06-06 18:27:34+00:00)
Title: server.unbind fails to trigger

A short reproducer:

#!/usr/bin/env node
var server = require("./lib/index").createServer();
server.bind('o=foo', function(req, res, next) {
console.log("bind");
res.end();
return next();
});
server.search("o=foo", function(req, res, next) {
console.log("search");
res.end();
return next();
});
server.unbind(function(req, res, next) {
console.log("unbind");
return next();
});
server.listen(1389);

When you run this server and run a search with a bind, like so:

ldapsearch -x -h localhost:1389 -D o=foo -w x -b o=foo

it should've output `bind`, `search` and `unbind`, but it only outputs `bind` and `search`.

I've tracked it down deep into the depths of the server code where the code determining what to do with the unbind request returns "a function that returns a handler" instead of returning the handler. See my commit. I'm fairly new with javascript and not sure if this is good practice or not.