search.send option to not filter out any attributes
This commit is contained in:
parent
73b14ea8ad
commit
ed1ae29054
|
@ -34,10 +34,14 @@ module.exports = SearchResponse;
|
||||||
* Allows you to send a SearchEntry back to the client.
|
* Allows you to send a SearchEntry back to the client.
|
||||||
*
|
*
|
||||||
* @param {Object} entry an instance of SearchEntry.
|
* @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')
|
if (!entry || typeof(entry) !== 'object')
|
||||||
throw new TypeError('entry (SearchEntry) required');
|
throw new TypeError('entry (SearchEntry) required');
|
||||||
|
if (nofiltering === undefined)
|
||||||
|
nofiltering = false;
|
||||||
|
|
||||||
var self = this;
|
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
|
// Rip out anything that either the client didn't ask for, the server
|
||||||
// wants to strip, or 'private' vars that are prefixed with '_'
|
// wants to strip, or 'private' vars that are prefixed with '_'
|
||||||
Object.keys(entry.attributes).forEach(function(a) {
|
if (!nofiltering) {
|
||||||
if ((self.attributes.length && self.attributes.indexOf(a) === -1) ||
|
Object.keys(entry.attributes).forEach(function(a) {
|
||||||
(self.notAttributes.length && self.notAttributes.indexOf(a) !== -1) ||
|
if ((self.attributes.length &&
|
||||||
(a.length && a.charAt(0) === '_')) {
|
self.attributes.indexOf(a) === -1) ||
|
||||||
delete entry.attributes[a];
|
(self.notAttributes.length &&
|
||||||
}
|
self.notAttributes.indexOf(a) !== -1) ||
|
||||||
});
|
(a.length && a.charAt(0) === '_')) {
|
||||||
|
delete entry.attributes[a];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
entry = new SearchEntry({
|
entry = new SearchEntry({
|
||||||
objectName: typeof(save.dn) === 'string' ? parseDN(save.dn) : save.dn,
|
objectName: typeof(save.dn) === 'string' ? parseDN(save.dn) : save.dn,
|
||||||
messageID: self.messageID,
|
messageID: self.messageID,
|
||||||
|
|
Loading…
Reference in New Issue