UNPKG

1.59 kBJavaScriptView Raw
1// Copyright 2011 Mark Cavage, Inc. All rights reserved.
2
3const assert = require('assert-plus')
4const util = require('util')
5
6const dtrace = require('../dtrace')
7
8const LDAPMessage = require('./result')
9// var Protocol = require('../protocol')
10
11/// --- API
12// Ok, so there's really no such thing as an unbind 'response', but to make
13// the framework not suck, I just made this up, and have it stubbed so it's
14// not such a one-off.
15
16function UnbindResponse (options) {
17 options = options || {}
18 assert.object(options)
19
20 options.protocolOp = 0
21 LDAPMessage.call(this, options)
22}
23util.inherits(UnbindResponse, LDAPMessage)
24Object.defineProperties(UnbindResponse.prototype, {
25 type: {
26 get: function getType () { return 'UnbindResponse' },
27 configurable: false
28 }
29})
30
31/**
32 * Special override that just ends the connection, if present.
33 *
34 * @param {Number} status completely ignored.
35 */
36UnbindResponse.prototype.end = function (status) {
37 assert.ok(this.connection)
38
39 this.log.trace('%s: unbinding!', this.connection.ldap.id)
40
41 this.connection.end()
42
43 const self = this
44 if (self._dtraceOp && self._dtraceId) {
45 dtrace.fire('server-' + self._dtraceOp + '-done', function () {
46 const c = self.connection || { ldap: {} }
47 return [
48 self._dtraceId || 0,
49 (c.remoteAddress || ''),
50 c.ldap.bindDN ? c.ldap.bindDN.toString() : '',
51 (self.requestDN ? self.requestDN.toString() : ''),
52 0,
53 ''
54 ]
55 })
56 }
57}
58
59UnbindResponse.prototype._json = function (j) {
60 return j
61}
62
63/// --- Exports
64
65module.exports = UnbindResponse