2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
var util = require('util');
|
|
|
|
|
|
|
|
var LDAPMessage = require('./message');
|
2011-08-30 18:12:34 +00:00
|
|
|
var dn = require('../dn');
|
2011-08-04 20:32:01 +00:00
|
|
|
var Protocol = require('../protocol');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///--- Globals
|
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
var DN = dn.DN;
|
|
|
|
var RDN = dn.RDN;
|
2011-08-04 20:32:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
///--- API
|
|
|
|
|
|
|
|
function UnbindRequest(options) {
|
|
|
|
if (options) {
|
2012-02-18 08:15:52 +00:00
|
|
|
if (typeof (options) !== 'object')
|
2011-08-04 20:32:01 +00:00
|
|
|
throw new TypeError('options must be an object');
|
|
|
|
} else {
|
|
|
|
options = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
options.protocolOp = Protocol.LDAP_REQ_UNBIND;
|
|
|
|
LDAPMessage.call(this, options);
|
|
|
|
|
2011-08-30 18:12:34 +00:00
|
|
|
var self = this;
|
2012-02-18 08:15:52 +00:00
|
|
|
this.__defineGetter__('type', function () { return 'UnbindRequest'; });
|
|
|
|
this.__defineGetter__('_dn', function () {
|
2011-08-30 18:12:34 +00:00
|
|
|
if (self.connection)
|
|
|
|
return self.connection.ldap.bindDN;
|
|
|
|
|
|
|
|
return new DN([new RDN({cn: 'anonymous'})]);
|
|
|
|
});
|
2011-08-04 20:32:01 +00:00
|
|
|
}
|
|
|
|
util.inherits(UnbindRequest, LDAPMessage);
|
|
|
|
module.exports = UnbindRequest;
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindRequest.prototype.newResult = function () {
|
2011-08-04 20:32:01 +00:00
|
|
|
// This one is special, so just hack up the result object
|
|
|
|
function UnbindResponse(options) {
|
|
|
|
LDAPMessage.call(this, options);
|
2012-02-18 08:15:52 +00:00
|
|
|
this.__defineGetter__('type', function () { return 'UnbindResponse'; });
|
2011-08-04 20:32:01 +00:00
|
|
|
}
|
|
|
|
util.inherits(UnbindResponse, LDAPMessage);
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindResponse.prototype.end = function (status) {
|
2012-02-18 08:54:22 +00:00
|
|
|
this.log.trace('%s: unbinding!', this.connection.ldap.id);
|
2011-08-04 20:32:01 +00:00
|
|
|
this.connection.end();
|
|
|
|
};
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindResponse.prototype._json = function (j) { return j; };
|
2011-08-04 20:32:01 +00:00
|
|
|
|
|
|
|
return new UnbindResponse({
|
|
|
|
messageID: 0,
|
|
|
|
protocolOp: 0,
|
|
|
|
status: 0 // Success
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindRequest.prototype._parse = function (ber) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(ber);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindRequest.prototype._toBer = function (ber) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(ber);
|
|
|
|
|
|
|
|
return ber;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindRequest.prototype._json = function (j) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(j);
|
|
|
|
|
|
|
|
return j;
|
|
|
|
};
|