node-ldapjs/lib/messages/unbind_request.js

84 lines
1.7 KiB
JavaScript
Raw Normal View History

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');
var dn = require('../dn');
2011-08-04 20:32:01 +00:00
var Protocol = require('../protocol');
///--- Globals
var DN = dn.DN;
var RDN = dn.RDN;
2011-08-04 20:32:01 +00:00
///--- API
function UnbindRequest(options) {
if (options) {
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);
var self = this;
this.__defineGetter__('type', function () { return 'UnbindRequest'; });
this.__defineGetter__('_dn', function () {
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;
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);
this.__defineGetter__('type', function () { return 'UnbindResponse'; });
2011-08-04 20:32:01 +00:00
}
util.inherits(UnbindResponse, LDAPMessage);
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();
};
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
});
};
UnbindRequest.prototype._parse = function (ber) {
2011-08-04 20:32:01 +00:00
assert.ok(ber);
return true;
};
UnbindRequest.prototype._toBer = function (ber) {
2011-08-04 20:32:01 +00:00
assert.ok(ber);
return ber;
};
UnbindRequest.prototype._json = function (j) {
2011-08-04 20:32:01 +00:00
assert.ok(j);
return j;
};