Minor cleanup of server handling and null DNs
This commit is contained in:
parent
75aba691f1
commit
28ddaaad69
|
@ -239,7 +239,7 @@ DN.prototype.parentOf = function(dn) {
|
||||||
if (typeof(dn) !== 'object')
|
if (typeof(dn) !== 'object')
|
||||||
dn = parse(dn);
|
dn = parse(dn);
|
||||||
|
|
||||||
if (this.rdns.length >= dn.rdns.length)
|
if (!this.rdns.length || this.rdns.length >= dn.rdns.length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var diff = dn.rdns.length - this.rdns.length;
|
var diff = dn.rdns.length - this.rdns.length;
|
||||||
|
|
|
@ -367,6 +367,7 @@ function Server(options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
log.trace('%s sending error: %s', req.logId, err.stack || err);
|
||||||
sendError(err);
|
sendError(err);
|
||||||
return after();
|
return after();
|
||||||
}
|
}
|
||||||
|
@ -444,7 +445,7 @@ function Server(options) {
|
||||||
});
|
});
|
||||||
this.__defineGetter__('url', function() {
|
this.__defineGetter__('url', function() {
|
||||||
var str;
|
var str;
|
||||||
if (options.certificate && options.key) {
|
if (this.server instanceof tls.Server) {
|
||||||
str = 'ldaps://';
|
str = 'ldaps://';
|
||||||
} else {
|
} else {
|
||||||
str = 'ldap://';
|
str = 'ldap://';
|
||||||
|
@ -745,9 +746,11 @@ Server.prototype._getHandlerChain = function(req) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var routes = this.routes;
|
var routes = this.routes;
|
||||||
for (var r in routes) {
|
var keys = Object.keys(routes);
|
||||||
if (routes.hasOwnProperty(r)) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
var r = keys[i];
|
||||||
var route = routes[r];
|
var route = routes[r];
|
||||||
|
|
||||||
// Special cases are abandons, exops and unbinds, handle those first.
|
// Special cases are abandons, exops and unbinds, handle those first.
|
||||||
if (req.protocolOp === Protocol.LDAP_REQ_EXTENSION) {
|
if (req.protocolOp === Protocol.LDAP_REQ_EXTENSION) {
|
||||||
if (r !== req.requestName)
|
if (r !== req.requestName)
|
||||||
|
@ -783,7 +786,8 @@ Server.prototype._getHandlerChain = function(req) {
|
||||||
// Otherwise, match via DN rules
|
// Otherwise, match via DN rules
|
||||||
assert.ok(req.dn);
|
assert.ok(req.dn);
|
||||||
assert.ok(route.dn);
|
assert.ok(route.dn);
|
||||||
if (r !== req.dn.toString() && (!route.dn.parentOf(req.dn)))
|
|
||||||
|
if (!route.dn.equals(req.dn) && !route.dn.parentOf(req.dn))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// We should be good to go.
|
// We should be good to go.
|
||||||
|
@ -793,7 +797,6 @@ Server.prototype._getHandlerChain = function(req) {
|
||||||
handlers: route[op] || [defaultHandler]
|
handlers: route[op] || [defaultHandler]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// We're here, so nothing matched.
|
// We're here, so nothing matched.
|
||||||
return {
|
return {
|
||||||
|
@ -801,7 +804,7 @@ Server.prototype._getHandlerChain = function(req) {
|
||||||
handlers: [(req.protocolOp !== Protocol.LDAP_REQ_EXTENSION ?
|
handlers: [(req.protocolOp !== Protocol.LDAP_REQ_EXTENSION ?
|
||||||
noSuffixHandler : noExOpHandler)]
|
noSuffixHandler : noExOpHandler)]
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
Server.prototype._mount = function(op, name, argv, notDN) {
|
Server.prototype._mount = function(op, name, argv, notDN) {
|
||||||
|
|
Loading…
Reference in New Issue