2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
var util = require('util');
|
|
|
|
|
2011-11-19 00:39:37 +00:00
|
|
|
var dtrace = require('../dtrace');
|
|
|
|
|
2011-08-04 20:32:01 +00:00
|
|
|
var LDAPMessage = require('./result');
|
|
|
|
var Protocol = require('../protocol');
|
|
|
|
|
|
|
|
|
|
|
|
///--- API
|
|
|
|
// Ok, so there's really no such thing as an unbind 'response', but to make
|
|
|
|
// the framework not suck, I just made this up, and have it stubbed so it's
|
|
|
|
// not such a one-off.
|
|
|
|
|
|
|
|
function UnbindResponse(options) {
|
|
|
|
if (!options)
|
|
|
|
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');
|
|
|
|
|
|
|
|
options.protocolOp = 0;
|
|
|
|
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);
|
|
|
|
module.exports = UnbindResponse;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Special override that just ends the connection, if present.
|
|
|
|
*
|
|
|
|
* @param {Number} status completely ignored.
|
|
|
|
*/
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindResponse.prototype.end = function (status) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(this.connection);
|
|
|
|
|
|
|
|
if (this.log.isTraceEnabled())
|
|
|
|
this.log.trace('%s: unbinding!', this.connection.ldap.id);
|
|
|
|
|
|
|
|
this.connection.end();
|
2011-11-19 00:39:37 +00:00
|
|
|
|
|
|
|
var self = this;
|
|
|
|
if (self._dtraceOp && self._dtraceId) {
|
2012-02-18 08:15:52 +00:00
|
|
|
dtrace.fire('server-' + self._dtraceOp + '-done', function () {
|
2011-11-19 00:39:37 +00:00
|
|
|
var c = self.connection || {ldap: {}};
|
|
|
|
return [
|
|
|
|
self._dtraceId || 0,
|
|
|
|
(c.remoteAddress || ''),
|
|
|
|
c.ldap.bindDN ? c.ldap.bindDN.toString() : '',
|
|
|
|
(self.requestDN ? self.requestDN.toString() : ''),
|
|
|
|
0,
|
|
|
|
''
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2011-08-04 20:32:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
UnbindResponse.prototype._json = function (j) {
|
2011-08-04 20:32:01 +00:00
|
|
|
return j;
|
|
|
|
};
|