Trivial server side extensible search filter support

This commit is contained in:
Mark Cavage 2011-12-27 12:12:40 -08:00
parent b8885d7793
commit 13978d5303
1 changed files with 38 additions and 1 deletions

View File

@ -82,12 +82,49 @@ ExtensibleFilter.prototype.matches = function(target) {
if (typeof(target) !== 'object')
throw new TypeError('target (object) required');
if (this.dnAttribute)
throw new Error('ExtensibleMatch dnAttributes not supported');
if (!this.value)
return false;
var self = this;
if (this.matchType && target.hasOwnProperty(this.matchType)) {
return Filter.multi_test(function(v) {
if (self.rule === '2.5.13.2')
return self.value.toLowerCase() === v.toLowerCase();
return self.value === v;
}, target[this.matchType]);
}
return false;
};
ExtensibleFilter.prototype.parse = function(ber) {
throw new Error('ExtensibleFilter not supported');
var end = ber.offset + ber.length;
while (ber.offset < end) {
var tag = ber.peek();
switch (tag) {
case 0x81:
this.rule = ber.readString(tag);
break;
case 0x82:
this.matchType = ber.readString(tag);
break;
case 0x83:
this.value = ber.readString(tag);
break;
case 0x84:
this.dnAttributes = ber.readBoolean(tag);
break;
default:
throw new Error('Invalid ext_match filter type: 0x' + tag.toString(16));
}
}
return true;
};