diff --git a/lib/messages/search_response.js b/lib/messages/search_response.js index 55fc5fe..c387276 100644 --- a/lib/messages/search_response.js +++ b/lib/messages/search_response.js @@ -34,10 +34,14 @@ module.exports = SearchResponse; * Allows you to send a SearchEntry back to the client. * * @param {Object} entry an instance of SearchEntry. + * @param {Boolean} nofiltering skip filtering notAttributes and '_' attributes. + * Defaults to 'false'. */ -SearchResponse.prototype.send = function(entry) { +SearchResponse.prototype.send = function(entry, nofiltering) { if (!entry || typeof(entry) !== 'object') throw new TypeError('entry (SearchEntry) required'); + if (nofiltering === undefined) + nofiltering = false; var self = this; @@ -51,14 +55,17 @@ SearchResponse.prototype.send = function(entry) { // Rip out anything that either the client didn't ask for, the server // wants to strip, or 'private' vars that are prefixed with '_' - Object.keys(entry.attributes).forEach(function(a) { - if ((self.attributes.length && self.attributes.indexOf(a) === -1) || - (self.notAttributes.length && self.notAttributes.indexOf(a) !== -1) || - (a.length && a.charAt(0) === '_')) { - delete entry.attributes[a]; - } - }); - + if (!nofiltering) { + Object.keys(entry.attributes).forEach(function(a) { + if ((self.attributes.length && + self.attributes.indexOf(a) === -1) || + (self.notAttributes.length && + self.notAttributes.indexOf(a) !== -1) || + (a.length && a.charAt(0) === '_')) { + delete entry.attributes[a]; + } + }); + } entry = new SearchEntry({ objectName: typeof(save.dn) === 'string' ? parseDN(save.dn) : save.dn, messageID: self.messageID,