support for client controls

This commit is contained in:
Mark Cavage 2011-09-16 09:06:07 -07:00
parent fcec8d626f
commit 73b14ea8ad
3 changed files with 25 additions and 4 deletions

View File

@ -564,7 +564,7 @@ Client.prototype.search = function(base, options, controls, callback) {
callback = controls;
controls = [];
} else {
control = validateControls(controls);
controls = validateControls(controls);
}
if (typeof(callback) !== 'function')
throw new TypeError('callback (function) required');
@ -577,7 +577,8 @@ Client.prototype.search = function(base, options, controls, callback) {
sizeLimit: options.sizeLimit || 0,
timeLimit: options.timeLimit || 10,
typesOnly: options.typesOnly || false,
attributes: options.attributes || []
attributes: options.attributes || [],
controls: controls
});
var res = new EventEmitter();

View File

@ -72,3 +72,15 @@ Control.prototype.parse = function(ber) {
return true;
};
Control.prototype.toBer = function(ber) {
assert.ok(ber);
ber.startSequence();
ber.writeString(this.type || '');
ber.writeBoolean(this.criticality);
if (this.value)
ber.writeString(this.value);
ber.endSequence();
};

View File

@ -95,12 +95,20 @@ LDAPMessage.prototype.toBer = function() {
var writer = new BerWriter();
writer.startSequence();
writer.writeInt(this.messageID);
writer.startSequence(this.protocolOp);
writer.startSequence(this.protocolOp);
if (this._toBer)
writer = this._toBer(writer);
writer.endSequence();
if (this.controls && this.controls.length) {
writer.startSequence(0xa0);
this.controls.forEach(function(c) {
c.toBer(writer);
});
writer.endSequence();
}
writer.endSequence();
return writer.buffer;
};