diff --git a/lib/dtrace.js b/lib/dtrace.js index 087bbf1..3b1728a 100644 --- a/lib/dtrace.js +++ b/lib/dtrace.js @@ -37,14 +37,16 @@ var SERVER_PROBES = { 'server-bind-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], // 4: attribute, 5: value - 'server-compare-start': ['int', 'char *', 'char *', 'char *', 'char *', 'char *'], + 'server-compare-start': ['int', 'char *', 'char *', 'char *', + 'char *', 'char *'], 'server-compare-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], 'server-delete-start': ['int', 'char *', 'char *', 'char *'], 'server-delete-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], // 4: requestName, 5: requestValue - 'server-exop-start': ['int', 'char *', 'char *', 'char *', 'char *', 'char *'], + 'server-exop-start': ['int', 'char *', 'char *', 'char *', 'char *', + 'char *'], 'server-exop-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], // 4: changes.length @@ -52,11 +54,14 @@ var SERVER_PROBES = { 'server-modify-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], // 4: newRdn, 5: newSuperior - 'server-modifydn-start': ['int', 'char *', 'char *', 'char *', 'char *', 'char *'], - 'server-modifydn-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], + 'server-modifydn-start': ['int', 'char *', 'char *', 'char *', 'char *', + 'char *'], + 'server-modifydn-done': ['int', 'char *', 'char *', 'char *', 'int', + 'char *'], // 4: scope, 5: filter - 'server-search-start': ['int', 'char *', 'char *', 'char *', 'char *', 'char *'], + 'server-search-start': ['int', 'char *', 'char *', 'char *', 'char *', + 'char *'], 'server-search-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], // Last two are searchEntry.DN and seachEntry.attributes.length 'server-search-entry': ['int', 'char *', 'char *', 'char *', 'char *', 'int'], @@ -65,7 +70,7 @@ var SERVER_PROBES = { 'server-unbind-done': ['int', 'char *', 'char *', 'char *', 'int', 'char *'], // remote IP - 'server-connection': ['char *'], + 'server-connection': ['char *'] }; diff --git a/lib/messages/search_response.js b/lib/messages/search_response.js index e2e83a0..0fa4ce8 100644 --- a/lib/messages/search_response.js +++ b/lib/messages/search_response.js @@ -59,16 +59,20 @@ SearchResponse.prototype.send = function(entry, nofiltering) { if (!entry.attributes) throw new Error('entry.attributes required'); + var savedAttrs = {}; var all = (self.attributes.indexOf('*') !== -1); Object.keys(entry.attributes).forEach(function(a) { var _a = a.toLowerCase(); if (!nofiltering && _a.length && _a[0] === '_') { + savedAttrs[a] = entry.attributes[a]; delete entry.attributes[a]; } else if (!nofiltering && self.notAttributes.indexOf(_a) !== -1) { + savedAttrs[a] = entry.attributes[a]; delete entry.attributes[a]; } else if (all) { // noop } else if (self.attributes.length && self.attributes.indexOf(_a) === -1) { + savedAttrs[a] = entry.attributes[a]; delete entry.attributes[a]; } }); @@ -98,10 +102,16 @@ SearchResponse.prototype.send = function(entry, nofiltering) { c.ldap.bindDN ? c.ldap.bindDN.toString() : '', (self.requestDN ? self.requestDN.toString() : ''), entry.objectName.toString(), - entry.attributes.length, + entry.attributes.length ]; }); } + + // Restore attributes + Object.keys(savedAttrs).forEach(function(k) { + save.attributes[k] = savedAttrs[k]; + }); + } catch (e) { this.log.warn('%s failure to write message %j: %s', this.connection.ldap.id, this.json, e.toString()); diff --git a/lib/server.js b/lib/server.js index 2b42f70..d0eecb1 100644 --- a/lib/server.js +++ b/lib/server.js @@ -175,7 +175,7 @@ function fireDTraceProbe(req, res) { req._dtraceId, req.connection.remoteAddress || 'localhost', req.connection.ldap.bindDN.toString(), - req.dn.toString(), + req.dn.toString() ]; var op;