update devdependency standard to v16
This commit is contained in:
parent
b796afea64
commit
c6fa25985b
|
@ -1,10 +1,10 @@
|
|||
var ldap = require('../lib/index')
|
||||
const ldap = require('../lib/index')
|
||||
|
||||
/// --- Shared handlers
|
||||
|
||||
function authorize (req, res, next) {
|
||||
/* Any user may search after bind, only cn=root has full power */
|
||||
var isSearch = (req instanceof ldap.SearchRequest)
|
||||
const isSearch = (req instanceof ldap.SearchRequest)
|
||||
if (!req.connection.ldap.bindDN.equals('cn=root') && !isSearch) { return next(new ldap.InsufficientAccessRightsError()) }
|
||||
|
||||
return next()
|
||||
|
@ -12,9 +12,9 @@ function authorize (req, res, next) {
|
|||
|
||||
/// --- Globals
|
||||
|
||||
var SUFFIX = 'o=smartdc'
|
||||
var db = {}
|
||||
var server = ldap.createServer()
|
||||
const SUFFIX = 'o=smartdc'
|
||||
const db = {}
|
||||
const server = ldap.createServer()
|
||||
|
||||
server.bind('cn=root', function (req, res, next) {
|
||||
if (req.dn.toString() !== 'cn=root' || req.credentials !== 'secret') { return next(new ldap.InvalidCredentialsError()) }
|
||||
|
@ -24,7 +24,7 @@ server.bind('cn=root', function (req, res, next) {
|
|||
})
|
||||
|
||||
server.add(SUFFIX, authorize, function (req, res, next) {
|
||||
var dn = req.dn.toString()
|
||||
const dn = req.dn.toString()
|
||||
|
||||
if (db[dn]) { return next(new ldap.EntryAlreadyExistsError(dn)) }
|
||||
|
||||
|
@ -34,7 +34,7 @@ server.add(SUFFIX, authorize, function (req, res, next) {
|
|||
})
|
||||
|
||||
server.bind(SUFFIX, function (req, res, next) {
|
||||
var dn = req.dn.toString()
|
||||
const dn = req.dn.toString()
|
||||
if (!db[dn]) { return next(new ldap.NoSuchObjectError(dn)) }
|
||||
|
||||
if (!db[dn].userpassword) { return next(new ldap.NoSuchAttributeError('userPassword')) }
|
||||
|
@ -46,14 +46,14 @@ server.bind(SUFFIX, function (req, res, next) {
|
|||
})
|
||||
|
||||
server.compare(SUFFIX, authorize, function (req, res, next) {
|
||||
var dn = req.dn.toString()
|
||||
const dn = req.dn.toString()
|
||||
if (!db[dn]) { return next(new ldap.NoSuchObjectError(dn)) }
|
||||
|
||||
if (!db[dn][req.attribute]) { return next(new ldap.NoSuchAttributeError(req.attribute)) }
|
||||
|
||||
var matches = false
|
||||
var vals = db[dn][req.attribute]
|
||||
for (var i = 0; i < vals.length; i++) {
|
||||
let matches = false
|
||||
const vals = db[dn][req.attribute]
|
||||
for (let i = 0; i < vals.length; i++) {
|
||||
if (vals[i] === req.value) {
|
||||
matches = true
|
||||
break
|
||||
|
@ -65,7 +65,7 @@ server.compare(SUFFIX, authorize, function (req, res, next) {
|
|||
})
|
||||
|
||||
server.del(SUFFIX, authorize, function (req, res, next) {
|
||||
var dn = req.dn.toString()
|
||||
const dn = req.dn.toString()
|
||||
if (!db[dn]) { return next(new ldap.NoSuchObjectError(dn)) }
|
||||
|
||||
delete db[dn]
|
||||
|
@ -75,14 +75,14 @@ server.del(SUFFIX, authorize, function (req, res, next) {
|
|||
})
|
||||
|
||||
server.modify(SUFFIX, authorize, function (req, res, next) {
|
||||
var dn = req.dn.toString()
|
||||
const dn = req.dn.toString()
|
||||
if (!req.changes.length) { return next(new ldap.ProtocolError('changes required')) }
|
||||
if (!db[dn]) { return next(new ldap.NoSuchObjectError(dn)) }
|
||||
|
||||
var entry = db[dn]
|
||||
const entry = db[dn]
|
||||
|
||||
let mod
|
||||
for (var i = 0; i < req.changes.length; i++) {
|
||||
for (let i = 0; i < req.changes.length; i++) {
|
||||
mod = req.changes[i].modification
|
||||
switch (req.changes[i].operation) {
|
||||
case 'replace':
|
||||
|
@ -121,10 +121,10 @@ server.modify(SUFFIX, authorize, function (req, res, next) {
|
|||
})
|
||||
|
||||
server.search(SUFFIX, authorize, function (req, res, next) {
|
||||
var dn = req.dn.toString()
|
||||
const dn = req.dn.toString()
|
||||
if (!db[dn]) { return next(new ldap.NoSuchObjectError(dn)) }
|
||||
|
||||
var scopeCheck
|
||||
let scopeCheck
|
||||
|
||||
switch (req.scope) {
|
||||
case 'base':
|
||||
|
@ -142,7 +142,7 @@ server.search(SUFFIX, authorize, function (req, res, next) {
|
|||
scopeCheck = function (k) {
|
||||
if (req.dn.equals(k)) { return true }
|
||||
|
||||
var parent = ldap.parseDN(k).parent()
|
||||
const parent = ldap.parseDN(k).parent()
|
||||
return (parent ? parent.equals(req.dn) : false)
|
||||
}
|
||||
break
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2015 Joyent, Inc.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var isDN = require('./dn').DN.isDN
|
||||
var isAttribute = require('./attribute').isAttribute
|
||||
const isDN = require('./dn').DN.isDN
|
||||
const isAttribute = require('./attribute').isAttribute
|
||||
|
||||
/// --- Helpers
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
const assert = require('assert')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Protocol = require('./protocol')
|
||||
const Protocol = require('./protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -42,13 +42,13 @@ Object.defineProperties(Attribute.prototype, {
|
|||
},
|
||||
vals: {
|
||||
get: function getVals () {
|
||||
var eType = _bufferEncoding(this.type)
|
||||
const eType = _bufferEncoding(this.type)
|
||||
return this._vals.map(function (v) {
|
||||
return v.toString(eType)
|
||||
})
|
||||
},
|
||||
set: function setVals (vals) {
|
||||
var self = this
|
||||
const self = this
|
||||
this._vals = []
|
||||
if (Array.isArray(vals)) {
|
||||
vals.forEach(function (v) {
|
||||
|
@ -81,7 +81,7 @@ Attribute.compare = function compare (a, b) {
|
|||
if (a.vals.length < b.vals.length) return -1
|
||||
if (a.vals.length > b.vals.length) return 1
|
||||
|
||||
for (var i = 0; i < a.vals.length; i++) {
|
||||
for (let i = 0; i < a.vals.length; i++) {
|
||||
if (a.vals[i] < b.vals[i]) return -1
|
||||
if (a.vals[i] > b.vals[i]) return 1
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ Attribute.prototype.parse = function parse (ber) {
|
|||
|
||||
if (ber.peek() === Protocol.LBER_SET) {
|
||||
if (ber.readSequence(Protocol.LBER_SET)) {
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) { this._vals.push(ber.readString(asn1.Ber.OctetString, true)) }
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ Attribute.prototype.toBer = function toBer (ber) {
|
|||
this._vals.forEach(function (b) {
|
||||
ber.writeByte(asn1.Ber.OctetString)
|
||||
ber.writeLength(b.length)
|
||||
for (var i = 0; i < b.length; i++) { ber.writeByte(b[i]) }
|
||||
for (let i = 0; i < b.length; i++) { ber.writeByte(b[i]) }
|
||||
})
|
||||
} else {
|
||||
ber.writeStringArray([])
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
const assert = require('assert-plus')
|
||||
|
||||
var Attribute = require('./attribute')
|
||||
const Attribute = require('./attribute')
|
||||
// var Protocol = require('./protocol')
|
||||
|
||||
/// --- API
|
||||
|
@ -68,15 +68,15 @@ Object.defineProperties(Change.prototype, {
|
|||
return
|
||||
}
|
||||
|
||||
var keys = Object.keys(val)
|
||||
const keys = Object.keys(val)
|
||||
if (keys.length > 1) {
|
||||
throw new Error('Only one attribute per Change allowed')
|
||||
} else if (keys.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
var k = keys[0]
|
||||
var _attr = new Attribute({ type: k })
|
||||
const k = keys[0]
|
||||
const _attr = new Attribute({ type: k })
|
||||
if (Array.isArray(val[k])) {
|
||||
val[k].forEach(function (v) {
|
||||
_attr.addValue(v.toString())
|
||||
|
@ -136,9 +136,9 @@ Change.apply = function apply (change, obj, scalar) {
|
|||
assert.ok(Array.isArray(change.modification.vals))
|
||||
assert.object(obj)
|
||||
|
||||
var type = change.modification.type
|
||||
var vals = change.modification.vals
|
||||
var data = obj[type]
|
||||
const type = change.modification.type
|
||||
const vals = change.modification.vals
|
||||
let data = obj[type]
|
||||
if (data !== undefined) {
|
||||
if (!Array.isArray(data)) {
|
||||
data = [data]
|
||||
|
@ -156,13 +156,14 @@ Change.apply = function apply (change, obj, scalar) {
|
|||
data = vals
|
||||
}
|
||||
break
|
||||
case 'add':
|
||||
case 'add': {
|
||||
// add only new unique entries
|
||||
var newValues = vals.filter(function (entry) {
|
||||
const newValues = vals.filter(function (entry) {
|
||||
return (data.indexOf(entry) === -1)
|
||||
})
|
||||
data = data.concat(newValues)
|
||||
break
|
||||
}
|
||||
case 'delete':
|
||||
data = data.filter(function (entry) {
|
||||
return (vals.indexOf(entry) === -1)
|
||||
|
|
|
@ -4,57 +4,57 @@ const requestQueueFactory = require('./request-queue')
|
|||
const messageTrackerFactory = require('./message-tracker')
|
||||
const { MAX_MSGID } = require('./constants')
|
||||
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var net = require('net')
|
||||
var tls = require('tls')
|
||||
var util = require('util')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const net = require('net')
|
||||
const tls = require('tls')
|
||||
const util = require('util')
|
||||
|
||||
var once = require('once')
|
||||
var backoff = require('backoff')
|
||||
var vasync = require('vasync')
|
||||
var assert = require('assert-plus')
|
||||
var VError = require('verror').VError
|
||||
const once = require('once')
|
||||
const backoff = require('backoff')
|
||||
const vasync = require('vasync')
|
||||
const assert = require('assert-plus')
|
||||
const VError = require('verror').VError
|
||||
|
||||
var Attribute = require('../attribute')
|
||||
var Change = require('../change')
|
||||
var Control = require('../controls/index').Control
|
||||
var SearchPager = require('./search_pager')
|
||||
var Protocol = require('../protocol')
|
||||
var dn = require('../dn')
|
||||
var errors = require('../errors')
|
||||
var filters = require('../filters')
|
||||
var messages = require('../messages')
|
||||
var url = require('../url')
|
||||
var CorkedEmitter = require('../corked_emitter')
|
||||
const Attribute = require('../attribute')
|
||||
const Change = require('../change')
|
||||
const Control = require('../controls/index').Control
|
||||
const SearchPager = require('./search_pager')
|
||||
const Protocol = require('../protocol')
|
||||
const dn = require('../dn')
|
||||
const errors = require('../errors')
|
||||
const filters = require('../filters')
|
||||
const messages = require('../messages')
|
||||
const url = require('../url')
|
||||
const CorkedEmitter = require('../corked_emitter')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var AbandonRequest = messages.AbandonRequest
|
||||
var AddRequest = messages.AddRequest
|
||||
var BindRequest = messages.BindRequest
|
||||
var CompareRequest = messages.CompareRequest
|
||||
var DeleteRequest = messages.DeleteRequest
|
||||
var ExtendedRequest = messages.ExtendedRequest
|
||||
var ModifyRequest = messages.ModifyRequest
|
||||
var ModifyDNRequest = messages.ModifyDNRequest
|
||||
var SearchRequest = messages.SearchRequest
|
||||
var UnbindRequest = messages.UnbindRequest
|
||||
var UnbindResponse = messages.UnbindResponse
|
||||
const AbandonRequest = messages.AbandonRequest
|
||||
const AddRequest = messages.AddRequest
|
||||
const BindRequest = messages.BindRequest
|
||||
const CompareRequest = messages.CompareRequest
|
||||
const DeleteRequest = messages.DeleteRequest
|
||||
const ExtendedRequest = messages.ExtendedRequest
|
||||
const ModifyRequest = messages.ModifyRequest
|
||||
const ModifyDNRequest = messages.ModifyDNRequest
|
||||
const SearchRequest = messages.SearchRequest
|
||||
const UnbindRequest = messages.UnbindRequest
|
||||
const UnbindResponse = messages.UnbindResponse
|
||||
|
||||
var LDAPResult = messages.LDAPResult
|
||||
var SearchEntry = messages.SearchEntry
|
||||
var SearchReference = messages.SearchReference
|
||||
const LDAPResult = messages.LDAPResult
|
||||
const SearchEntry = messages.SearchEntry
|
||||
const SearchReference = messages.SearchReference
|
||||
// var SearchResponse = messages.SearchResponse
|
||||
var Parser = messages.Parser
|
||||
const Parser = messages.Parser
|
||||
|
||||
var PresenceFilter = filters.PresenceFilter
|
||||
const PresenceFilter = filters.PresenceFilter
|
||||
|
||||
var ConnectionError = errors.ConnectionError
|
||||
const ConnectionError = errors.ConnectionError
|
||||
|
||||
var CMP_EXPECT = [errors.LDAP_COMPARE_TRUE, errors.LDAP_COMPARE_FALSE]
|
||||
const CMP_EXPECT = [errors.LDAP_COMPARE_TRUE, errors.LDAP_COMPARE_FALSE]
|
||||
|
||||
// node 0.6 got rid of FDs, so make up a client id for logging
|
||||
var CLIENT_ID = 0
|
||||
let CLIENT_ID = 0
|
||||
|
||||
/// --- Internal Helpers
|
||||
|
||||
|
@ -109,7 +109,7 @@ function Client (options) {
|
|||
|
||||
EventEmitter.call(this, options)
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
this.urls = options.url ? [].concat(options.url).map(url.parse) : []
|
||||
this._nextServer = 0
|
||||
// updated in connectSocket() after each connect
|
||||
|
@ -127,7 +127,7 @@ function Client (options) {
|
|||
this.idleTimeout = parseInt((options.idleTimeout || 0), 10)
|
||||
if (options.reconnect) {
|
||||
// Fall back to defaults if options.reconnect === true
|
||||
var rOpts = (typeof (options.reconnect) === 'object')
|
||||
const rOpts = (typeof (options.reconnect) === 'object')
|
||||
? options.reconnect
|
||||
: {}
|
||||
this.reconnect = {
|
||||
|
@ -192,7 +192,7 @@ Client.prototype.abandon = function abandon (messageID, controls, callback) {
|
|||
}
|
||||
assert.func(callback, 'callback')
|
||||
|
||||
var req = new AbandonRequest({
|
||||
const req = new AbandonRequest({
|
||||
abandonID: messageID,
|
||||
controls: controls
|
||||
})
|
||||
|
@ -229,11 +229,11 @@ Client.prototype.add = function add (name, entry, controls, callback) {
|
|||
if (!Attribute.isAttribute(a)) { throw new TypeError('entry must be an Array of Attributes') }
|
||||
})
|
||||
} else {
|
||||
var save = entry
|
||||
const save = entry
|
||||
|
||||
entry = []
|
||||
Object.keys(save).forEach(function (k) {
|
||||
var attr = new Attribute({ type: k })
|
||||
const attr = new Attribute({ type: k })
|
||||
if (Array.isArray(save[k])) {
|
||||
save[k].forEach(function (v) {
|
||||
attr.addValue(v.toString())
|
||||
|
@ -245,7 +245,7 @@ Client.prototype.add = function add (name, entry, controls, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
var req = new AddRequest({
|
||||
const req = new AddRequest({
|
||||
entry: ensureDN(name, this.strictDN),
|
||||
attributes: entry,
|
||||
controls: controls
|
||||
|
@ -278,7 +278,7 @@ Client.prototype.bind = function bind (name,
|
|||
}
|
||||
assert.func(callback, 'callback')
|
||||
|
||||
var req = new BindRequest({
|
||||
const req = new BindRequest({
|
||||
name: name || '',
|
||||
authentication: 'Simple',
|
||||
credentials: credentials || '',
|
||||
|
@ -286,7 +286,7 @@ Client.prototype.bind = function bind (name,
|
|||
})
|
||||
|
||||
// Connection errors will be reported to the bind callback too (useful when the LDAP server is not available)
|
||||
var self = this
|
||||
const self = this
|
||||
function callbackWrapper (err, ret) {
|
||||
self.removeListener('connectError', callbackWrapper)
|
||||
callback(err, ret)
|
||||
|
@ -322,7 +322,7 @@ Client.prototype.compare = function compare (name,
|
|||
}
|
||||
assert.func(callback, 'callback')
|
||||
|
||||
var req = new CompareRequest({
|
||||
const req = new CompareRequest({
|
||||
entry: ensureDN(name, this.strictDN),
|
||||
attribute: attr,
|
||||
value: value,
|
||||
|
@ -354,7 +354,7 @@ Client.prototype.del = function del (name, controls, callback) {
|
|||
}
|
||||
assert.func(callback, 'callback')
|
||||
|
||||
var req = new DeleteRequest({
|
||||
const req = new DeleteRequest({
|
||||
entry: ensureDN(name, this.strictDN),
|
||||
controls: controls
|
||||
})
|
||||
|
@ -390,7 +390,7 @@ Client.prototype.exop = function exop (name, value, controls, callback) {
|
|||
}
|
||||
assert.func(callback, 'callback')
|
||||
|
||||
var req = new ExtendedRequest({
|
||||
const req = new ExtendedRequest({
|
||||
requestName: name,
|
||||
requestValue: value,
|
||||
controls: controls
|
||||
|
@ -416,7 +416,7 @@ Client.prototype.modify = function modify (name, change, controls, callback) {
|
|||
assert.ok(name !== undefined, 'name')
|
||||
assert.object(change, 'change')
|
||||
|
||||
var changes = []
|
||||
const changes = []
|
||||
|
||||
function changeFromObject (change) {
|
||||
if (!change.operation && !change.type) { throw new Error('change.operation required') }
|
||||
|
@ -433,7 +433,7 @@ Client.prototype.modify = function modify (name, change, controls, callback) {
|
|||
} else {
|
||||
// Normalize the modification object
|
||||
Object.keys(change.modification).forEach(function (k) {
|
||||
var mod = {}
|
||||
const mod = {}
|
||||
mod[k] = change.modification[k]
|
||||
changes.push(new Change({
|
||||
operation: change.operation || change.type,
|
||||
|
@ -465,7 +465,7 @@ Client.prototype.modify = function modify (name, change, controls, callback) {
|
|||
}
|
||||
assert.func(callback, 'callback')
|
||||
|
||||
var req = new ModifyRequest({
|
||||
const req = new ModifyRequest({
|
||||
object: ensureDN(name, this.strictDN),
|
||||
changes: changes,
|
||||
controls: controls
|
||||
|
@ -502,11 +502,11 @@ Client.prototype.modifyDN = function modifyDN (name,
|
|||
}
|
||||
assert.func(callback)
|
||||
|
||||
var DN = ensureDN(name)
|
||||
const DN = ensureDN(name)
|
||||
// TODO: is non-strict handling desired here?
|
||||
var newDN = dn.parse(newName)
|
||||
const newDN = dn.parse(newName)
|
||||
|
||||
var req = new ModifyDNRequest({
|
||||
const req = new ModifyDNRequest({
|
||||
entry: DN,
|
||||
deleteOldRdn: true,
|
||||
controls: controls
|
||||
|
@ -590,11 +590,11 @@ Client.prototype.search = function search (base,
|
|||
}
|
||||
}
|
||||
|
||||
var self = this
|
||||
var baseDN = ensureDN(base, this.strictDN)
|
||||
const self = this
|
||||
const baseDN = ensureDN(base, this.strictDN)
|
||||
|
||||
function sendRequest (ctrls, emitter, cb) {
|
||||
var req = new SearchRequest({
|
||||
const req = new SearchRequest({
|
||||
baseObject: baseDN,
|
||||
scope: options.scope || 'base',
|
||||
filter: options.filter,
|
||||
|
@ -615,8 +615,8 @@ Client.prototype.search = function search (base,
|
|||
|
||||
if (options.paged) {
|
||||
// Perform automated search paging
|
||||
var pageOpts = typeof (options.paged) === 'object' ? options.paged : {}
|
||||
var size = 100 // Default page size
|
||||
const pageOpts = typeof (options.paged) === 'object' ? options.paged : {}
|
||||
let size = 100 // Default page size
|
||||
if (pageOpts.pageSize > 0) {
|
||||
size = pageOpts.pageSize
|
||||
} else if (options.sizeLimit > 1) {
|
||||
|
@ -626,7 +626,7 @@ Client.prototype.search = function search (base,
|
|||
size = options.sizeLimit - 1
|
||||
}
|
||||
|
||||
var pager = new SearchPager({
|
||||
const pager = new SearchPager({
|
||||
callback: callback,
|
||||
controls: controls,
|
||||
pageSize: size,
|
||||
|
@ -659,7 +659,7 @@ Client.prototype.unbind = function unbind (callback) {
|
|||
|
||||
if (!this._socket) { return callback() }
|
||||
|
||||
var req = new UnbindRequest()
|
||||
const req = new UnbindRequest()
|
||||
return this._send(req, 'unbind', null, callback)
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ Client.prototype.starttls = function starttls (options,
|
|||
assert.optionalObject(options)
|
||||
options = options || {}
|
||||
callback = once(callback)
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
if (this._starttls) {
|
||||
return callback(new Error('STARTTLS already in progress or active'))
|
||||
|
@ -698,7 +698,7 @@ Client.prototype.starttls = function starttls (options,
|
|||
callback(err)
|
||||
})
|
||||
emitter.on('end', function (res) {
|
||||
var sock = self._socket
|
||||
const sock = self._socket
|
||||
/*
|
||||
* Unplumb socket data during SSL negotiation.
|
||||
* This will prevent the LDAP parser from stumbling over the TLS
|
||||
|
@ -707,7 +707,7 @@ Client.prototype.starttls = function starttls (options,
|
|||
sock.removeAllListeners('data')
|
||||
|
||||
options.socket = sock
|
||||
var secure = tls.connect(options)
|
||||
const secure = tls.connect(options)
|
||||
secure.once('secureConnect', function () {
|
||||
/*
|
||||
* Wire up 'data' and 'error' handlers like the normal socket.
|
||||
|
@ -739,7 +739,7 @@ Client.prototype.starttls = function starttls (options,
|
|||
})
|
||||
}
|
||||
|
||||
var req = new ExtendedRequest({
|
||||
const req = new ExtendedRequest({
|
||||
requestName: '1.3.6.1.4.1.1466.20037',
|
||||
requestValue: null,
|
||||
controls: controls
|
||||
|
@ -787,14 +787,14 @@ Client.prototype.connect = function connect () {
|
|||
if (this.connecting || this.connected) {
|
||||
return
|
||||
}
|
||||
var self = this
|
||||
var log = this.log
|
||||
var socket
|
||||
var tracker
|
||||
const self = this
|
||||
const log = this.log
|
||||
let socket
|
||||
let tracker
|
||||
|
||||
// Establish basic socket connection
|
||||
function connectSocket (cb) {
|
||||
var server = self.urls[self._nextServer]
|
||||
const server = self.urls[self._nextServer]
|
||||
self._nextServer = (self._nextServer + 1) % self.urls.length
|
||||
|
||||
cb = once(cb)
|
||||
|
@ -825,8 +825,8 @@ Client.prototype.connect = function connect () {
|
|||
setupClient(cb)
|
||||
}
|
||||
|
||||
var port = (server && server.port) || self.socketPath
|
||||
var host = server && server.hostname
|
||||
const port = (server && server.port) || self.socketPath
|
||||
const host = server && server.hostname
|
||||
if (server && server.secure) {
|
||||
socket = tls.connect(port, host, self.tlsOptions)
|
||||
socket.once('secureConnect', onConnect)
|
||||
|
@ -874,7 +874,7 @@ Client.prototype.connect = function connect () {
|
|||
// The "router"
|
||||
tracker.parser.on('message', function onMessage (message) {
|
||||
message.connection = self._socket
|
||||
var callback = tracker.fetch(message.messageID)
|
||||
const callback = tracker.fetch(message.messageID)
|
||||
|
||||
if (!callback) {
|
||||
log.error({ message: message.json }, 'unsolicited message')
|
||||
|
@ -921,7 +921,7 @@ Client.prototype.connect = function connect () {
|
|||
// This setup needs to bypass the request queue since all other activity is
|
||||
// blocked until the connection is considered fully established post-setup.
|
||||
// Only allow bind/search/starttls for now.
|
||||
var basicClient = {
|
||||
const basicClient = {
|
||||
bind: function bindBypass (name, credentials, controls, callback) {
|
||||
return self.bind(name, credentials, controls, callback, true)
|
||||
},
|
||||
|
@ -973,7 +973,7 @@ Client.prototype.connect = function connect () {
|
|||
socket.end()
|
||||
})
|
||||
|
||||
var server = self.urls[self._nextServer]
|
||||
const server = self.urls[self._nextServer]
|
||||
if (server) {
|
||||
self.host = server.hostname
|
||||
self.port = server.port
|
||||
|
@ -981,8 +981,8 @@ Client.prototype.connect = function connect () {
|
|||
}
|
||||
}
|
||||
|
||||
var retry
|
||||
var failAfter
|
||||
let retry
|
||||
let failAfter
|
||||
if (this.reconnect) {
|
||||
retry = backoff.exponential({
|
||||
initialDelay: this.reconnect.initialDelay,
|
||||
|
@ -1056,8 +1056,8 @@ Client.prototype._flushQueue = function _flushQueue () {
|
|||
* Clean up socket/parser resources after socket close.
|
||||
*/
|
||||
Client.prototype._onClose = function _onClose (closeError) {
|
||||
var socket = this._socket
|
||||
var tracker = this._tracker
|
||||
const socket = this._socket
|
||||
const tracker = this._tracker
|
||||
socket.removeAllListeners('connect')
|
||||
.removeAllListeners('data')
|
||||
.removeAllListeners('drain')
|
||||
|
@ -1079,7 +1079,7 @@ Client.prototype._onClose = function _onClose (closeError) {
|
|||
return cb(new ConnectionError(tracker.id + ' closed'))
|
||||
} else {
|
||||
// Unbinds will be communicated as a success since we're closed
|
||||
var unbind = new UnbindResponse({ messageID: msgid })
|
||||
const unbind = new UnbindResponse({ messageID: msgid })
|
||||
unbind.status = 'unbind'
|
||||
return cb(unbind)
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ Client.prototype._updateIdle = function _updateIdle (override) {
|
|||
return
|
||||
}
|
||||
// Client must be connected but not waiting on any request data
|
||||
var self = this
|
||||
const self = this
|
||||
function isIdle (disable) {
|
||||
return ((disable !== true) &&
|
||||
(self._socket && self.connected) &&
|
||||
|
@ -1170,12 +1170,12 @@ Client.prototype._sendSocket = function _sendSocket (message,
|
|||
expect,
|
||||
emitter,
|
||||
callback) {
|
||||
var conn = this._socket
|
||||
var tracker = this._tracker
|
||||
var log = this.log
|
||||
var self = this
|
||||
var timer = false
|
||||
var sentEmitter = false
|
||||
const conn = this._socket
|
||||
const tracker = this._tracker
|
||||
const log = this.log
|
||||
const self = this
|
||||
let timer = false
|
||||
let sentEmitter = false
|
||||
|
||||
function sendResult (event, obj) {
|
||||
if (event === 'error') {
|
||||
|
@ -1203,7 +1203,7 @@ Client.prototype._sendSocket = function _sendSocket (message,
|
|||
if (expect === 'abandon') { return sendResult('end', null) }
|
||||
|
||||
if (msg instanceof SearchEntry || msg instanceof SearchReference) {
|
||||
var event = msg.constructor.name
|
||||
let event = msg.constructor.name
|
||||
event = event[0].toLowerCase() + event.slice(1)
|
||||
return sendResult(event, msg)
|
||||
} else {
|
||||
|
@ -1226,7 +1226,7 @@ Client.prototype._sendSocket = function _sendSocket (message,
|
|||
|
||||
function onRequestTimeout () {
|
||||
self.emit('timeout', message)
|
||||
var cb = tracker.fetch(message.messageID)
|
||||
const cb = tracker.fetch(message.messageID)
|
||||
if (cb) {
|
||||
// FIXME: the timed-out request should be abandoned
|
||||
cb(new errors.TimeoutError('request timeout (client interrupt)'))
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
'use strict'
|
||||
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var util = require('util')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const util = require('util')
|
||||
|
||||
var assert = require('assert-plus')
|
||||
const assert = require('assert-plus')
|
||||
|
||||
// var dn = require('../dn')
|
||||
// var messages = require('../messages/index')
|
||||
// var Protocol = require('../protocol')
|
||||
var PagedControl = require('../controls/paged_results_control.js')
|
||||
const PagedControl = require('../controls/paged_results_control.js')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -54,7 +54,7 @@ function SearchPager (opts) {
|
|||
this.finished = false
|
||||
this.started = false
|
||||
|
||||
var emitter = new EventEmitter()
|
||||
const emitter = new EventEmitter()
|
||||
emitter.on('searchEntry', this.emit.bind(this, 'searchEntry'))
|
||||
emitter.on('end', this._onEnd.bind(this))
|
||||
emitter.on('error', this._onError.bind(this))
|
||||
|
@ -72,21 +72,21 @@ SearchPager.prototype.begin = function begin () {
|
|||
}
|
||||
|
||||
SearchPager.prototype._onEnd = function _onEnd (res) {
|
||||
var self = this
|
||||
var cookie = null
|
||||
const self = this
|
||||
let cookie = null
|
||||
res.controls.forEach(function (control) {
|
||||
if (control.type === PagedControl.OID) {
|
||||
cookie = control.value.cookie
|
||||
}
|
||||
})
|
||||
// Pass a noop callback by default for page events
|
||||
var nullCb = function () { }
|
||||
const nullCb = function () { }
|
||||
|
||||
if (cookie === null) {
|
||||
// paged search not supported
|
||||
this.finished = true
|
||||
this.emit('page', res, nullCb)
|
||||
var err = new Error('missing paged control')
|
||||
const err = new Error('missing paged control')
|
||||
err.name = 'PagedError'
|
||||
if (this.listeners('pageError').length > 0) {
|
||||
this.emit('pageError', err)
|
||||
|
@ -135,7 +135,7 @@ SearchPager.prototype._onError = function _onError (err) {
|
|||
* Initiate a search for the next page using the returned cookie value.
|
||||
*/
|
||||
SearchPager.prototype._nextPage = function _nextPage (cookie) {
|
||||
var controls = this.controls.slice(0)
|
||||
const controls = this.controls.slice(0)
|
||||
controls.push(new PagedControl({
|
||||
value: {
|
||||
size: this.pageSize,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
const assert = require('assert-plus')
|
||||
|
||||
// var asn1 = require('asn1')
|
||||
|
||||
|
@ -28,7 +28,7 @@ function Control (options) {
|
|||
Object.defineProperties(Control.prototype, {
|
||||
json: {
|
||||
get: function getJson () {
|
||||
var obj = {
|
||||
const obj = {
|
||||
controlType: this.type,
|
||||
criticality: this.criticality,
|
||||
controlValue: this.value
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
const Control = require('./control')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -39,7 +39,7 @@ Object.defineProperties(EntryChangeNotificationControl.prototype, {
|
|||
EntryChangeNotificationControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
|
||||
var ber = new BerReader(buffer)
|
||||
const ber = new BerReader(buffer)
|
||||
if (ber.readSequence()) {
|
||||
this._value = {
|
||||
changeType: ber.readInt()
|
||||
|
@ -61,7 +61,7 @@ EntryChangeNotificationControl.prototype._toBer = function (ber) {
|
|||
|
||||
if (!this._value) { return }
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence()
|
||||
writer.writeInt(this.value.changeType)
|
||||
if (this.value.previousDN) { writer.writeString(this.value.previousDN) }
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var Ber = require('asn1').Ber
|
||||
const assert = require('assert')
|
||||
const Ber = require('asn1').Ber
|
||||
|
||||
var Control = require('./control')
|
||||
var EntryChangeNotificationControl =
|
||||
const Control = require('./control')
|
||||
const EntryChangeNotificationControl =
|
||||
require('./entry_change_notification_control')
|
||||
var PersistentSearchControl = require('./persistent_search_control')
|
||||
var PagedResultsControl = require('./paged_results_control')
|
||||
var ServerSideSortingRequestControl =
|
||||
const PersistentSearchControl = require('./persistent_search_control')
|
||||
const PagedResultsControl = require('./paged_results_control')
|
||||
const ServerSideSortingRequestControl =
|
||||
require('./server_side_sorting_request_control.js')
|
||||
var ServerSideSortingResponseControl =
|
||||
const ServerSideSortingResponseControl =
|
||||
require('./server_side_sorting_response_control.js')
|
||||
var VirtualListViewRequestControl =
|
||||
const VirtualListViewRequestControl =
|
||||
require('./virtual_list_view_request_control.js')
|
||||
var VirtualListViewResponseControl =
|
||||
const VirtualListViewResponseControl =
|
||||
require('./virtual_list_view_response_control.js')
|
||||
|
||||
/// --- API
|
||||
|
@ -26,14 +26,14 @@ module.exports = {
|
|||
|
||||
if (ber.readSequence() === null) { return null }
|
||||
|
||||
var type
|
||||
var opts = {
|
||||
let type
|
||||
const opts = {
|
||||
criticality: false,
|
||||
value: null
|
||||
}
|
||||
|
||||
if (ber.length) {
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
|
||||
type = ber.readString()
|
||||
if (ber.offset < end) {
|
||||
|
@ -43,7 +43,7 @@ module.exports = {
|
|||
if (ber.offset < end) { opts.value = ber.readString(Ber.OctetString, true) }
|
||||
}
|
||||
|
||||
var control
|
||||
let control
|
||||
switch (type) {
|
||||
case PersistentSearchControl.OID:
|
||||
control = new PersistentSearchControl(opts)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
const Control = require('./control')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -39,7 +39,7 @@ Object.defineProperties(PagedResultsControl.prototype, {
|
|||
PagedResultsControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
|
||||
var ber = new BerReader(buffer)
|
||||
const ber = new BerReader(buffer)
|
||||
if (ber.readSequence()) {
|
||||
this._value = {}
|
||||
this._value.size = ber.readInt()
|
||||
|
@ -58,7 +58,7 @@ PagedResultsControl.prototype._toBer = function (ber) {
|
|||
|
||||
if (!this._value) { return }
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence()
|
||||
writer.writeInt(this.value.size)
|
||||
if (this.value.cookie && this.value.cookie.length > 0) {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
const Control = require('./control')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -42,7 +42,7 @@ Object.defineProperties(PersistentSearchControl.prototype, {
|
|||
PersistentSearchControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
|
||||
var ber = new BerReader(buffer)
|
||||
const ber = new BerReader(buffer)
|
||||
if (ber.readSequence()) {
|
||||
this._value = {
|
||||
changeTypes: ber.readInt(),
|
||||
|
@ -61,7 +61,7 @@ PersistentSearchControl.prototype._toBer = function (ber) {
|
|||
|
||||
if (!this._value) { return }
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence()
|
||||
writer.writeInt(this.value.changeTypes)
|
||||
writer.writeBoolean(this.value.changesOnly)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
const Control = require('./control')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -21,7 +21,7 @@ function ServerSideSortingRequestControl (options) {
|
|||
this.parse(options.value)
|
||||
} else if (Array.isArray(options.value)) {
|
||||
assert.arrayOfObject(options.value, 'options.value must be Objects')
|
||||
for (var i = 0; i < options.value.length; i++) {
|
||||
for (let i = 0; i < options.value.length; i++) {
|
||||
if (Object.prototype.hasOwnProperty.call(options.value[i], 'attributeType') === false) {
|
||||
throw new Error('Missing required key: attributeType')
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ Object.defineProperties(ServerSideSortingRequestControl.prototype, {
|
|||
ServerSideSortingRequestControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
|
||||
var ber = new BerReader(buffer)
|
||||
var item
|
||||
const ber = new BerReader(buffer)
|
||||
let item
|
||||
if (ber.readSequence(0x30)) {
|
||||
this._value = []
|
||||
|
||||
|
@ -76,10 +76,10 @@ ServerSideSortingRequestControl.prototype._toBer = function (ber) {
|
|||
|
||||
if (!this._value || this.value.length === 0) { return }
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence(0x30)
|
||||
for (var i = 0; i < this.value.length; i++) {
|
||||
var item = this.value[i]
|
||||
for (let i = 0; i < this.value.length; i++) {
|
||||
const item = this.value[i]
|
||||
writer.startSequence(0x30)
|
||||
if (item.attributeType) {
|
||||
writer.writeString(item.attributeType, asn1.Ber.OctetString)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
var CODES = require('../errors/codes')
|
||||
const Control = require('./control')
|
||||
const CODES = require('../errors/codes')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
var VALID_CODES = [
|
||||
const VALID_CODES = [
|
||||
CODES.LDAP_SUCCESS,
|
||||
CODES.LDAP_OPERATIONS_ERROR,
|
||||
CODES.LDAP_TIME_LIMIT_EXCEEDED,
|
||||
|
@ -62,7 +62,7 @@ Object.defineProperties(ServerSideSortingResponseControl.prototype, {
|
|||
ServerSideSortingResponseControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
|
||||
var ber = new BerReader(buffer)
|
||||
const ber = new BerReader(buffer)
|
||||
if (ber.readSequence(0x30)) {
|
||||
this._value = {}
|
||||
this._value.result = ber.readEnumeration()
|
||||
|
@ -79,7 +79,7 @@ ServerSideSortingResponseControl.prototype._toBer = function (ber) {
|
|||
|
||||
if (!this._value || this.value.length === 0) { return }
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence(0x30)
|
||||
writer.writeEnumeration(this.value.result)
|
||||
if (this.value.result !== CODES.LDAP_SUCCESS && this.value.failedAttribute) {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
const Control = require('./control')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -44,7 +44,7 @@ Object.defineProperties(VirtualListViewControl.prototype, {
|
|||
|
||||
VirtualListViewControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
var ber = new BerReader(buffer)
|
||||
const ber = new BerReader(buffer)
|
||||
if (ber.readSequence()) {
|
||||
this._value = {}
|
||||
this._value.beforeCount = ber.readInt()
|
||||
|
@ -68,7 +68,7 @@ VirtualListViewControl.prototype._toBer = function (ber) {
|
|||
if (!this._value || this.value.length === 0) {
|
||||
return
|
||||
}
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence(0x30)
|
||||
writer.writeInt(this.value.beforeCount)
|
||||
writer.writeInt(this.value.afterCount)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var Control = require('./control')
|
||||
var CODES = require('../errors/codes')
|
||||
const Control = require('./control')
|
||||
const CODES = require('../errors/codes')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
|
||||
var VALID_CODES = [
|
||||
const VALID_CODES = [
|
||||
CODES.LDAP_SUCCESS,
|
||||
CODES.LDAP_OPERATIONS_ERROR,
|
||||
CODES.LDAP_UNWILLING_TO_PERFORM,
|
||||
|
@ -56,7 +56,7 @@ Object.defineProperties(VirtualListViewResponseControl.prototype, {
|
|||
|
||||
VirtualListViewResponseControl.prototype.parse = function parse (buffer) {
|
||||
assert.ok(buffer)
|
||||
var ber = new BerReader(buffer)
|
||||
const ber = new BerReader(buffer)
|
||||
if (ber.readSequence()) {
|
||||
this._value = {}
|
||||
if (ber.peek(0x02)) {
|
||||
|
@ -83,7 +83,7 @@ VirtualListViewResponseControl.prototype._toBer = function (ber) {
|
|||
return
|
||||
}
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
writer.startSequence()
|
||||
if (this.value.targetPosition !== undefined) {
|
||||
writer.writeInt(this.value.targetPosition)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
|
||||
/**
|
||||
* A CorkedEmitter is a variant of an EventEmitter where events emitted
|
||||
|
@ -16,7 +16,7 @@ var EventEmitter = require('events').EventEmitter
|
|||
* re-ordering emits - either everything is being buffered, or nothing.
|
||||
*/
|
||||
function CorkedEmitter () {
|
||||
var self = this
|
||||
const self = this
|
||||
EventEmitter.call(self)
|
||||
/**
|
||||
* An array of arguments objects (array-likes) to emit on open.
|
||||
|
|
100
lib/dn.js
100
lib/dn.js
|
@ -1,37 +1,37 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
const assert = require('assert-plus')
|
||||
|
||||
/// --- Helpers
|
||||
|
||||
function invalidDN (name) {
|
||||
var e = new Error()
|
||||
const e = new Error()
|
||||
e.name = 'InvalidDistinguishedNameError'
|
||||
e.message = name
|
||||
return e
|
||||
}
|
||||
|
||||
function isAlphaNumeric (c) {
|
||||
var re = /[A-Za-z0-9]/
|
||||
const re = /[A-Za-z0-9]/
|
||||
return re.test(c)
|
||||
}
|
||||
|
||||
function isWhitespace (c) {
|
||||
var re = /\s/
|
||||
const re = /\s/
|
||||
return re.test(c)
|
||||
}
|
||||
|
||||
function repeatChar (c, n) {
|
||||
var out = ''
|
||||
var max = n || 0
|
||||
for (var i = 0; i < max; i++) { out += c }
|
||||
let out = ''
|
||||
const max = n || 0
|
||||
for (let i = 0; i < max; i++) { out += c }
|
||||
return out
|
||||
}
|
||||
|
||||
/// --- API
|
||||
|
||||
function RDN (obj) {
|
||||
var self = this
|
||||
const self = this
|
||||
this.attrs = {}
|
||||
|
||||
if (obj) {
|
||||
|
@ -45,8 +45,8 @@ RDN.prototype.set = function rdnSet (name, value, opts) {
|
|||
assert.string(name, 'name (string) required')
|
||||
assert.string(value, 'value (string) required')
|
||||
|
||||
var self = this
|
||||
var lname = name.toLowerCase()
|
||||
const self = this
|
||||
const lname = name.toLowerCase()
|
||||
this.attrs[lname] = {
|
||||
value: value,
|
||||
name: name
|
||||
|
@ -61,14 +61,14 @@ RDN.prototype.set = function rdnSet (name, value, opts) {
|
|||
RDN.prototype.equals = function rdnEquals (rdn) {
|
||||
if (typeof (rdn) !== 'object') { return false }
|
||||
|
||||
var ourKeys = Object.keys(this.attrs)
|
||||
var theirKeys = Object.keys(rdn.attrs)
|
||||
const ourKeys = Object.keys(this.attrs)
|
||||
const theirKeys = Object.keys(rdn.attrs)
|
||||
if (ourKeys.length !== theirKeys.length) { return false }
|
||||
|
||||
ourKeys.sort()
|
||||
theirKeys.sort()
|
||||
|
||||
for (var i = 0; i < ourKeys.length; i++) {
|
||||
for (let i = 0; i < ourKeys.length; i++) {
|
||||
if (ourKeys[i] !== theirKeys[i]) { return false }
|
||||
if (this.attrs[ourKeys[i]].value !== rdn.attrs[ourKeys[i]].value) { return false }
|
||||
}
|
||||
|
@ -83,20 +83,20 @@ RDN.prototype.format = function rdnFormat (options) {
|
|||
assert.optionalObject(options, 'options must be an object')
|
||||
options = options || {}
|
||||
|
||||
var self = this
|
||||
var str = ''
|
||||
const self = this
|
||||
let str = ''
|
||||
|
||||
function escapeValue (val, forceQuote) {
|
||||
var out = ''
|
||||
var cur = 0
|
||||
var len = val.length
|
||||
var quoted = false
|
||||
let out = ''
|
||||
let cur = 0
|
||||
const len = val.length
|
||||
let quoted = false
|
||||
/* BEGIN JSSTYLED */
|
||||
// TODO: figure out what this regex is actually trying to test for and
|
||||
// fix it to appease the linter.
|
||||
/* eslint-disable-next-line no-useless-escape */
|
||||
var escaped = /[\\\"]/
|
||||
var special = /[,=+<>#;]/
|
||||
const escaped = /[\\\"]/
|
||||
const special = /[,=+<>#;]/
|
||||
/* END JSSTYLED */
|
||||
|
||||
if (len > 0) {
|
||||
|
@ -117,7 +117,7 @@ RDN.prototype.format = function rdnFormat (options) {
|
|||
return self.attrs[a].order - self.attrs[b].order
|
||||
}
|
||||
function sortStandard (a, b) {
|
||||
var nameCompare = a.localeCompare(b)
|
||||
const nameCompare = a.localeCompare(b)
|
||||
if (nameCompare === 0) {
|
||||
// TODO: Handle binary values
|
||||
return self.attrs[a].value.localeCompare(self.attrs[b].value)
|
||||
|
@ -126,7 +126,7 @@ RDN.prototype.format = function rdnFormat (options) {
|
|||
}
|
||||
}
|
||||
|
||||
var keys = Object.keys(this.attrs)
|
||||
const keys = Object.keys(this.attrs)
|
||||
if (options.keepOrder) {
|
||||
keys.sort(sortParsed)
|
||||
} else {
|
||||
|
@ -134,7 +134,7 @@ RDN.prototype.format = function rdnFormat (options) {
|
|||
}
|
||||
|
||||
keys.forEach(function (key) {
|
||||
var attr = self.attrs[key]
|
||||
const attr = self.attrs[key]
|
||||
if (str.length) { str += '+' }
|
||||
|
||||
if (options.keepCase) {
|
||||
|
@ -157,24 +157,24 @@ RDN.prototype.toString = function rdnToString () {
|
|||
function parse (name) {
|
||||
if (typeof (name) !== 'string') { throw new TypeError('name (string) required') }
|
||||
|
||||
var cur = 0
|
||||
var len = name.length
|
||||
let cur = 0
|
||||
const len = name.length
|
||||
|
||||
function parseRdn () {
|
||||
var rdn = new RDN()
|
||||
var order = 0
|
||||
const rdn = new RDN()
|
||||
let order = 0
|
||||
rdn.spLead = trim()
|
||||
while (cur < len) {
|
||||
var opts = {
|
||||
const opts = {
|
||||
order: order
|
||||
}
|
||||
var attr = parseAttrType()
|
||||
const attr = parseAttrType()
|
||||
trim()
|
||||
if (cur >= len || name[cur++] !== '=') { throw invalidDN(name) }
|
||||
|
||||
trim()
|
||||
// Parameters about RDN value are set in 'opts' by parseAttrValue
|
||||
var value = parseAttrValue(opts)
|
||||
const value = parseAttrValue(opts)
|
||||
rdn.set(attr, value, opts)
|
||||
rdn.spTrail = trim()
|
||||
if (cur >= len || name[cur] !== '+') { break }
|
||||
|
@ -185,7 +185,7 @@ function parse (name) {
|
|||
}
|
||||
|
||||
function trim () {
|
||||
var count = 0
|
||||
let count = 0
|
||||
while ((cur < len) && isWhitespace(name[cur])) {
|
||||
++cur
|
||||
count++
|
||||
|
@ -194,9 +194,9 @@ function parse (name) {
|
|||
}
|
||||
|
||||
function parseAttrType () {
|
||||
var beg = cur
|
||||
const beg = cur
|
||||
while (cur < len) {
|
||||
var c = name[cur]
|
||||
const c = name[cur]
|
||||
if (isAlphaNumeric(c) ||
|
||||
c === '.' ||
|
||||
c === '-' ||
|
||||
|
@ -227,14 +227,14 @@ function parse (name) {
|
|||
}
|
||||
|
||||
function parseBinaryAttrValue () {
|
||||
var beg = cur++
|
||||
const beg = cur++
|
||||
while (cur < len && isAlphaNumeric(name[cur])) { ++cur }
|
||||
|
||||
return name.slice(beg, cur)
|
||||
}
|
||||
|
||||
function parseQuotedAttrValue () {
|
||||
var str = ''
|
||||
let str = ''
|
||||
++cur // Consume the first quote
|
||||
|
||||
while ((cur < len) && name[cur] !== '"') {
|
||||
|
@ -250,9 +250,9 @@ function parse (name) {
|
|||
}
|
||||
|
||||
function parseStringAttrValue () {
|
||||
var beg = cur
|
||||
var str = ''
|
||||
var esc = -1
|
||||
const beg = cur
|
||||
let str = ''
|
||||
let esc = -1
|
||||
|
||||
while ((cur < len) && !atTerminator()) {
|
||||
if (name[cur] === '\\') {
|
||||
|
@ -282,7 +282,7 @@ function parse (name) {
|
|||
name[cur] === '+'))
|
||||
}
|
||||
|
||||
var rdns = []
|
||||
const rdns = []
|
||||
|
||||
// Short-circuit for empty DNs
|
||||
if (len === 0) { return new DN(rdns) }
|
||||
|
@ -340,9 +340,9 @@ DN.prototype.format = function dnFormat (options) {
|
|||
assert.optionalObject(options, 'options must be an object')
|
||||
options = options || this._format
|
||||
|
||||
var str = ''
|
||||
let str = ''
|
||||
this.rdns.forEach(function (rdn) {
|
||||
var rdnString = rdn.format(options)
|
||||
const rdnString = rdn.format(options)
|
||||
if (str.length !== 0) {
|
||||
str += ','
|
||||
}
|
||||
|
@ -376,10 +376,10 @@ DN.prototype.parentOf = function parentOf (dn) {
|
|||
|
||||
if (this.rdns.length >= dn.rdns.length) { return false }
|
||||
|
||||
var diff = dn.rdns.length - this.rdns.length
|
||||
for (var i = this.rdns.length - 1; i >= 0; i--) {
|
||||
var myRDN = this.rdns[i]
|
||||
var theirRDN = dn.rdns[i + diff]
|
||||
const diff = dn.rdns.length - this.rdns.length
|
||||
for (let i = this.rdns.length - 1; i >= 0; i--) {
|
||||
const myRDN = this.rdns[i]
|
||||
const theirRDN = dn.rdns[i + diff]
|
||||
|
||||
if (!myRDN.equals(theirRDN)) { return false }
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ DN.prototype.equals = function dnEquals (dn) {
|
|||
|
||||
if (this.rdns.length !== dn.rdns.length) { return false }
|
||||
|
||||
for (var i = 0; i < this.rdns.length; i++) {
|
||||
for (let i = 0; i < this.rdns.length; i++) {
|
||||
if (!this.rdns[i].equals(dn.rdns[i])) { return false }
|
||||
}
|
||||
|
||||
|
@ -410,8 +410,8 @@ DN.prototype.equals = function dnEquals (dn) {
|
|||
|
||||
DN.prototype.parent = function dnParent () {
|
||||
if (this.rdns.length !== 0) {
|
||||
var save = this.rdns.shift()
|
||||
var dn = new DN(this.rdns)
|
||||
const save = this.rdns.shift()
|
||||
const dn = new DN(this.rdns)
|
||||
this.rdns.unshift(save)
|
||||
return dn
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ DN.prototype.parent = function dnParent () {
|
|||
}
|
||||
|
||||
DN.prototype.clone = function dnClone () {
|
||||
var dn = new DN(this.rdns)
|
||||
const dn = new DN(this.rdns)
|
||||
dn._format = this._format
|
||||
return dn
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
/// --- Globals
|
||||
|
||||
var SERVER_PROVIDER
|
||||
var DTRACE_ID = 0
|
||||
var MAX_INT = 4294967295
|
||||
let SERVER_PROVIDER
|
||||
let DTRACE_ID = 0
|
||||
const MAX_INT = 4294967295
|
||||
|
||||
/*
|
||||
* Args:
|
||||
|
@ -24,7 +24,7 @@ var MAX_INT = 4294967295
|
|||
* 5 -> errorMessage
|
||||
*
|
||||
*/
|
||||
var SERVER_PROBES = {
|
||||
const SERVER_PROBES = {
|
||||
|
||||
// 4: attributes.length
|
||||
'server-add-start': ['int', 'char *', 'char *', 'char *', 'int'],
|
||||
|
@ -78,11 +78,11 @@ var SERVER_PROBES = {
|
|||
module.exports = (function () {
|
||||
if (!SERVER_PROVIDER) {
|
||||
try {
|
||||
var dtrace = require('dtrace-provider')
|
||||
const dtrace = require('dtrace-provider')
|
||||
SERVER_PROVIDER = dtrace.createDTraceProvider('ldapjs')
|
||||
|
||||
Object.keys(SERVER_PROBES).forEach(function (p) {
|
||||
var args = SERVER_PROBES[p].splice(0)
|
||||
const args = SERVER_PROBES[p].splice(0)
|
||||
args.unshift(p)
|
||||
|
||||
dtrace.DTraceProvider.prototype.addProbe.apply(SERVER_PROVIDER, args)
|
||||
|
@ -94,7 +94,7 @@ module.exports = (function () {
|
|||
enable: function () {
|
||||
},
|
||||
addProbe: function () {
|
||||
var p = {
|
||||
const p = {
|
||||
fire: function () {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
'use strict'
|
||||
|
||||
var util = require('util')
|
||||
var assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
|
||||
var LDAPResult = require('../messages').LDAPResult
|
||||
const LDAPResult = require('../messages').LDAPResult
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var CODES = require('./codes')
|
||||
var ERRORS = []
|
||||
const CODES = require('./codes')
|
||||
const ERRORS = []
|
||||
|
||||
/// --- Error Base class
|
||||
|
||||
|
@ -52,12 +52,12 @@ Object.keys(CODES).forEach(function (code) {
|
|||
module.exports[code] = CODES[code]
|
||||
if (code === 'LDAP_SUCCESS') { return }
|
||||
|
||||
var err = ''
|
||||
var msg = ''
|
||||
var pieces = code.split('_').slice(1)
|
||||
for (var i = 0; i < pieces.length; i++) {
|
||||
var lc = pieces[i].toLowerCase()
|
||||
var key = lc.charAt(0).toUpperCase() + lc.slice(1)
|
||||
let err = ''
|
||||
let msg = ''
|
||||
const pieces = code.split('_').slice(1)
|
||||
for (let i = 0; i < pieces.length; i++) {
|
||||
const lc = pieces[i].toLowerCase()
|
||||
const key = lc.charAt(0).toUpperCase() + lc.slice(1)
|
||||
err += key
|
||||
msg += key + ((i + 1) < pieces.length ? ' ' : '')
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ Object.keys(CODES).forEach(function (code) {
|
|||
module.exports.getError = function (res) {
|
||||
assert.ok(res instanceof LDAPResult, 'res (LDAPResult) required')
|
||||
|
||||
var errObj = ERRORS[res.status]
|
||||
var E = module.exports[errObj.err]
|
||||
const errObj = ERRORS[res.status]
|
||||
const E = module.exports[errObj.err]
|
||||
return new E(res.errorMessage || errObj.message,
|
||||
res.matchedDN || null,
|
||||
module.exports.getError)
|
||||
|
@ -101,7 +101,7 @@ module.exports.getError = function (res) {
|
|||
module.exports.getMessage = function (code) {
|
||||
assert.number(code, 'code (number) required')
|
||||
|
||||
var errObj = ERRORS[code]
|
||||
const errObj = ERRORS[code]
|
||||
return (errObj && errObj.message ? errObj.message : '')
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var ASN1 = require('asn1').Ber
|
||||
var parents = require('ldap-filter')
|
||||
const ASN1 = require('asn1').Ber
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -20,8 +20,8 @@ module.exports = EqualityFilter
|
|||
EqualityFilter.prototype.matches = function (target, strictAttrCase) {
|
||||
assert.object(target, 'target')
|
||||
|
||||
var tv = parents.getAttrValue(target, this.attribute, strictAttrCase)
|
||||
var value = this.value
|
||||
const tv = parents.getAttrValue(target, this.attribute, strictAttrCase)
|
||||
let value = this.value
|
||||
|
||||
if (this.attribute.toLowerCase() === 'objectclass') {
|
||||
/*
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
exports.escape = function (inp) {
|
||||
if (typeof (inp) === 'string') {
|
||||
var esc = ''
|
||||
for (var i = 0; i < inp.length; i++) {
|
||||
let esc = ''
|
||||
for (let i = 0; i < inp.length; i++) {
|
||||
switch (inp[i]) {
|
||||
case '*':
|
||||
esc += '\\2a'
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
// THIS IS A STUB!
|
||||
//
|
||||
|
@ -22,9 +22,9 @@ Filter.mixin(ExtensibleFilter)
|
|||
module.exports = ExtensibleFilter
|
||||
|
||||
ExtensibleFilter.prototype.parse = function (ber) {
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) {
|
||||
var tag = ber.peek()
|
||||
const tag = ber.peek()
|
||||
switch (tag) {
|
||||
case 0x81:
|
||||
this.rule = ber.readString(tag)
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
// var assert = require('assert')
|
||||
|
||||
var Protocol = require('../protocol')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var TYPES = {
|
||||
const TYPES = {
|
||||
and: Protocol.FILTER_AND,
|
||||
or: Protocol.FILTER_OR,
|
||||
not: Protocol.FILTER_NOT,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
const assert = require('assert')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Protocol = require('../protocol')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
var Filter = require('./filter')
|
||||
var AndFilter = require('./and_filter')
|
||||
var ApproximateFilter = require('./approx_filter')
|
||||
var EqualityFilter = require('./equality_filter')
|
||||
var ExtensibleFilter = require('./ext_filter')
|
||||
var GreaterThanEqualsFilter = require('./ge_filter')
|
||||
var LessThanEqualsFilter = require('./le_filter')
|
||||
var NotFilter = require('./not_filter')
|
||||
var OrFilter = require('./or_filter')
|
||||
var PresenceFilter = require('./presence_filter')
|
||||
var SubstringFilter = require('./substr_filter')
|
||||
const Filter = require('./filter')
|
||||
const AndFilter = require('./and_filter')
|
||||
const ApproximateFilter = require('./approx_filter')
|
||||
const EqualityFilter = require('./equality_filter')
|
||||
const ExtensibleFilter = require('./ext_filter')
|
||||
const GreaterThanEqualsFilter = require('./ge_filter')
|
||||
const LessThanEqualsFilter = require('./le_filter')
|
||||
const NotFilter = require('./not_filter')
|
||||
const OrFilter = require('./or_filter')
|
||||
const PresenceFilter = require('./presence_filter')
|
||||
const SubstringFilter = require('./substr_filter')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
const BerReader = asn1.BerReader
|
||||
|
||||
/// --- Internal Parsers
|
||||
|
||||
|
@ -63,13 +63,13 @@ function _parse (ber) {
|
|||
assert.ok(ber)
|
||||
|
||||
function parseSet (f) {
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) { f.addFilter(_parse(ber)) }
|
||||
}
|
||||
|
||||
var f
|
||||
let f
|
||||
|
||||
var type = ber.readSequence()
|
||||
const type = ber.readSequence()
|
||||
switch (type) {
|
||||
case Protocol.FILTER_AND:
|
||||
f = new AndFilter()
|
||||
|
@ -102,9 +102,8 @@ function _parse (ber) {
|
|||
return f
|
||||
|
||||
case Protocol.FILTER_NOT:
|
||||
var _f = _parse(ber)
|
||||
f = new NotFilter({
|
||||
filter: _f
|
||||
filter: _parse(ber)
|
||||
})
|
||||
break
|
||||
|
||||
|
@ -132,7 +131,7 @@ function _parse (ber) {
|
|||
}
|
||||
|
||||
function cloneFilter (input) {
|
||||
var child
|
||||
let child
|
||||
if (input.type === 'and' || input.type === 'or') {
|
||||
child = input.filters.map(cloneFilter)
|
||||
} else if (input.type === 'not') {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -30,7 +30,7 @@ PresenceFilter.prototype.parse = function (ber) {
|
|||
PresenceFilter.prototype._toBer = function (ber) {
|
||||
assert.ok(ber)
|
||||
|
||||
for (var i = 0; i < this.attribute.length; i++) { ber.writeByte(this.attribute.charCodeAt(i)) }
|
||||
for (let i = 0; i < this.attribute.length; i++) { ber.writeByte(this.attribute.charCodeAt(i)) }
|
||||
|
||||
return ber
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const util = require('util')
|
||||
|
||||
var parents = require('ldap-filter')
|
||||
const parents = require('ldap-filter')
|
||||
|
||||
var Filter = require('./filter')
|
||||
const Filter = require('./filter')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -21,20 +21,21 @@ SubstringFilter.prototype.parse = function (ber) {
|
|||
|
||||
this.attribute = ber.readString().toLowerCase()
|
||||
ber.readSequence()
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
|
||||
while (ber.offset < end) {
|
||||
var tag = ber.peek()
|
||||
const tag = ber.peek()
|
||||
switch (tag) {
|
||||
case 0x80: // Initial
|
||||
this.initial = ber.readString(tag)
|
||||
if (this.attribute === 'objectclass') { this.initial = this.initial.toLowerCase() }
|
||||
break
|
||||
case 0x81: // Any
|
||||
var anyVal = ber.readString(tag)
|
||||
case 0x81: { // Any
|
||||
let anyVal = ber.readString(tag)
|
||||
if (this.attribute === 'objectclass') { anyVal = anyVal.toLowerCase() }
|
||||
this.any.push(anyVal)
|
||||
break
|
||||
}
|
||||
case 0x82: // Final
|
||||
this.final = ber.readString(tag)
|
||||
if (this.attribute === 'objectclass') { this.final = this.final.toLowerCase() }
|
||||
|
|
28
lib/index.js
28
lib/index.js
|
@ -1,20 +1,20 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var logger = require('./logger')
|
||||
const logger = require('./logger')
|
||||
|
||||
var client = require('./client')
|
||||
var Attribute = require('./attribute')
|
||||
var Change = require('./change')
|
||||
var Protocol = require('./protocol')
|
||||
var Server = require('./server')
|
||||
const client = require('./client')
|
||||
const Attribute = require('./attribute')
|
||||
const Change = require('./change')
|
||||
const Protocol = require('./protocol')
|
||||
const Server = require('./server')
|
||||
|
||||
var controls = require('./controls')
|
||||
var persistentSearch = require('./persistent_search')
|
||||
var dn = require('./dn')
|
||||
var errors = require('./errors')
|
||||
var filters = require('./filters')
|
||||
var messages = require('./messages')
|
||||
var url = require('./url')
|
||||
const controls = require('./controls')
|
||||
const persistentSearch = require('./persistent_search')
|
||||
const dn = require('./dn')
|
||||
const errors = require('./errors')
|
||||
const filters = require('./filters')
|
||||
const messages = require('./messages')
|
||||
const url = require('./url')
|
||||
|
||||
const hasOwnProperty = (target, val) => Object.prototype.hasOwnProperty.call(target, val)
|
||||
|
||||
|
@ -57,7 +57,7 @@ module.exports = {
|
|||
|
||||
/// --- Export all the childrenz
|
||||
|
||||
var k
|
||||
let k
|
||||
|
||||
for (k in Protocol) {
|
||||
if (hasOwnProperty(Protocol, k)) { module.exports[k] = Protocol[k] }
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -34,13 +34,13 @@ AbandonRequest.prototype._parse = function (ber, length) {
|
|||
// way abandon is encoded and the way ldapjs framework handles "normal"
|
||||
// messages
|
||||
|
||||
var buf = ber.buffer
|
||||
var offset = 0
|
||||
var value = 0
|
||||
const buf = ber.buffer
|
||||
let offset = 0
|
||||
let value = 0
|
||||
|
||||
var fb = buf[offset++]
|
||||
const fb = buf[offset++]
|
||||
value = fb & 0x7F
|
||||
for (var i = 1; i < length; i++) {
|
||||
for (let i = 1; i < length; i++) {
|
||||
value <<= 8
|
||||
value |= (buf[offset++] & 0xff)
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ AbandonRequest.prototype._parse = function (ber, length) {
|
|||
AbandonRequest.prototype._toBer = function (ber) {
|
||||
assert.ok(ber)
|
||||
|
||||
var i = this.abandonID
|
||||
var sz = 4
|
||||
let i = this.abandonID
|
||||
let sz = 4
|
||||
|
||||
while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000)) &&
|
||||
(sz > 1)) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./result')
|
||||
const LDAPMessage = require('./result')
|
||||
// var Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Attribute = require('../attribute')
|
||||
var Protocol = require('../protocol')
|
||||
var lassert = require('../assert')
|
||||
const LDAPMessage = require('./message')
|
||||
const Attribute = require('../attribute')
|
||||
const Protocol = require('../protocol')
|
||||
const lassert = require('../assert')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -41,13 +41,13 @@ AddRequest.prototype._parse = function (ber) {
|
|||
|
||||
ber.readSequence()
|
||||
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) {
|
||||
var a = new Attribute()
|
||||
const a = new Attribute()
|
||||
a.parse(ber)
|
||||
a.type = a.type.toLowerCase()
|
||||
if (a.type === 'objectclass') {
|
||||
for (var i = 0; i < a.vals.length; i++) { a.vals[i] = a.vals[i].toLowerCase() }
|
||||
for (let i = 0; i < a.vals.length; i++) { a.vals[i] = a.vals[i].toLowerCase() }
|
||||
}
|
||||
this.attributes.push(a)
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ AddRequest.prototype._json = function (j) {
|
|||
AddRequest.prototype.indexOf = function (attr) {
|
||||
if (!attr || typeof (attr) !== 'string') { throw new TypeError('attr (string) required') }
|
||||
|
||||
for (var i = 0; i < this.attributes.length; i++) {
|
||||
for (let i = 0; i < this.attributes.length; i++) {
|
||||
if (this.attributes[i].type === attr) { return i }
|
||||
}
|
||||
|
||||
|
@ -93,9 +93,9 @@ AddRequest.prototype.indexOf = function (attr) {
|
|||
}
|
||||
|
||||
AddRequest.prototype.attributeNames = function () {
|
||||
var attrs = []
|
||||
const attrs = []
|
||||
|
||||
for (var i = 0; i < this.attributes.length; i++) { attrs.push(this.attributes[i].type.toLowerCase()) }
|
||||
for (let i = 0; i < this.attributes.length; i++) { attrs.push(this.attributes[i].type.toLowerCase()) }
|
||||
|
||||
return attrs
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ AddRequest.prototype.getAttribute = function (name) {
|
|||
|
||||
name = name.toLowerCase()
|
||||
|
||||
for (var i = 0; i < this.attributes.length; i++) {
|
||||
for (let i = 0; i < this.attributes.length; i++) {
|
||||
if (this.attributes[i].type === name) { return this.attributes[i] }
|
||||
}
|
||||
|
||||
|
@ -134,9 +134,9 @@ AddRequest.prototype.addAttribute = function (attr) {
|
|||
* @return {Object} that looks like the above.
|
||||
*/
|
||||
AddRequest.prototype.toObject = function () {
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
var obj = {
|
||||
const obj = {
|
||||
dn: self.entry ? self.entry.toString() : '',
|
||||
attributes: {}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var Ber = asn1.Ber
|
||||
var LDAP_BIND_SIMPLE = 'simple'
|
||||
const Ber = asn1.Ber
|
||||
const LDAP_BIND_SIMPLE = 'simple'
|
||||
// var LDAP_BIND_SASL = 'sasl'
|
||||
|
||||
/// --- API
|
||||
|
@ -46,7 +46,7 @@ BindRequest.prototype._parse = function (ber) {
|
|||
this.version = ber.readInt()
|
||||
this.name = ber.readString()
|
||||
|
||||
var t = ber.peek()
|
||||
const t = ber.peek()
|
||||
|
||||
// TODO add support for SASL et al
|
||||
if (t !== Ber.Context) { throw new Error('authentication 0x' + t.toString(16) + ' not supported') }
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
var lassert = require('../assert')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
const lassert = require('../assert')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -18,7 +18,7 @@ function CompareResponse (options) {
|
|||
util.inherits(CompareResponse, LDAPResult)
|
||||
|
||||
CompareResponse.prototype.end = function (matches) {
|
||||
var status = 0x06
|
||||
let status = 0x06
|
||||
if (typeof (matches) === 'boolean') {
|
||||
if (!matches) { status = 0x05 } // Compare false
|
||||
} else {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
var lassert = require('../assert')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
const lassert = require('../assert')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -43,8 +43,8 @@ DeleteRequest.prototype._parse = function (ber, length) {
|
|||
DeleteRequest.prototype._toBer = function (ber) {
|
||||
assert.ok(ber)
|
||||
|
||||
var buf = Buffer.from(this.entry.toString())
|
||||
for (var i = 0; i < buf.length; i++) { ber.writeByte(buf[i]) }
|
||||
const buf = Buffer.from(this.entry.toString())
|
||||
for (let i = 0; i < buf.length; i++) { ber.writeByte(buf[i]) }
|
||||
|
||||
return ber
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var LDAPResult = require('./result')
|
||||
var Parser = require('./parser')
|
||||
const LDAPMessage = require('./message')
|
||||
const LDAPResult = require('./result')
|
||||
const Parser = require('./parser')
|
||||
|
||||
var AbandonRequest = require('./abandon_request')
|
||||
var AbandonResponse = require('./abandon_response')
|
||||
var AddRequest = require('./add_request')
|
||||
var AddResponse = require('./add_response')
|
||||
var BindRequest = require('./bind_request')
|
||||
var BindResponse = require('./bind_response')
|
||||
var CompareRequest = require('./compare_request')
|
||||
var CompareResponse = require('./compare_response')
|
||||
var DeleteRequest = require('./del_request')
|
||||
var DeleteResponse = require('./del_response')
|
||||
var ExtendedRequest = require('./ext_request')
|
||||
var ExtendedResponse = require('./ext_response')
|
||||
var ModifyRequest = require('./modify_request')
|
||||
var ModifyResponse = require('./modify_response')
|
||||
var ModifyDNRequest = require('./moddn_request')
|
||||
var ModifyDNResponse = require('./moddn_response')
|
||||
var SearchRequest = require('./search_request')
|
||||
var SearchEntry = require('./search_entry')
|
||||
var SearchReference = require('./search_reference')
|
||||
var SearchResponse = require('./search_response')
|
||||
var UnbindRequest = require('./unbind_request')
|
||||
var UnbindResponse = require('./unbind_response')
|
||||
const AbandonRequest = require('./abandon_request')
|
||||
const AbandonResponse = require('./abandon_response')
|
||||
const AddRequest = require('./add_request')
|
||||
const AddResponse = require('./add_response')
|
||||
const BindRequest = require('./bind_request')
|
||||
const BindResponse = require('./bind_response')
|
||||
const CompareRequest = require('./compare_request')
|
||||
const CompareResponse = require('./compare_response')
|
||||
const DeleteRequest = require('./del_request')
|
||||
const DeleteResponse = require('./del_response')
|
||||
const ExtendedRequest = require('./ext_request')
|
||||
const ExtendedResponse = require('./ext_response')
|
||||
const ModifyRequest = require('./modify_request')
|
||||
const ModifyResponse = require('./modify_response')
|
||||
const ModifyDNRequest = require('./moddn_request')
|
||||
const ModifyDNResponse = require('./moddn_response')
|
||||
const SearchRequest = require('./search_request')
|
||||
const SearchEntry = require('./search_entry')
|
||||
const SearchReference = require('./search_reference')
|
||||
const SearchResponse = require('./search_response')
|
||||
const UnbindRequest = require('./unbind_request')
|
||||
const UnbindResponse = require('./unbind_response')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var logger = require('../logger')
|
||||
const logger = require('../logger')
|
||||
// var Control = require('../controls').Control
|
||||
// var Protocol = require('../protocol')
|
||||
|
||||
|
@ -13,8 +13,8 @@ var logger = require('../logger')
|
|||
|
||||
// var Ber = asn1.Ber
|
||||
// var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
var getControl = require('../controls').getControl
|
||||
const BerWriter = asn1.BerWriter
|
||||
const getControl = require('../controls').getControl
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -47,7 +47,7 @@ Object.defineProperties(LDAPMessage.prototype, {
|
|||
},
|
||||
json: {
|
||||
get: function () {
|
||||
var out = this._json({
|
||||
const out = this._json({
|
||||
messageID: this.messageID,
|
||||
protocolOp: this.type
|
||||
})
|
||||
|
@ -73,9 +73,9 @@ LDAPMessage.prototype.parse = function (ber) {
|
|||
// Look for controls
|
||||
if (ber.peek() === 0xa0) {
|
||||
ber.readSequence()
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) {
|
||||
var c = getControl(ber)
|
||||
const c = getControl(ber)
|
||||
if (c) { this.controls.push(c) }
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ LDAPMessage.prototype.parse = function (ber) {
|
|||
}
|
||||
|
||||
LDAPMessage.prototype.toBer = function () {
|
||||
var writer = new BerWriter()
|
||||
let writer = new BerWriter()
|
||||
writer.startSequence()
|
||||
writer.writeInt(this.messageID)
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
var dn = require('../dn')
|
||||
var lassert = require('../assert')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
const dn = require('../dn')
|
||||
const lassert = require('../assert')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -56,8 +56,8 @@ ModifyDNRequest.prototype._toBer = function (ber) {
|
|||
ber.writeString(this.newRdn.toString())
|
||||
ber.writeBoolean(this.deleteOldRdn)
|
||||
if (this.newSuperior) {
|
||||
var s = this.newSuperior.toString()
|
||||
var len = Buffer.byteLength(s)
|
||||
const s = this.newSuperior.toString()
|
||||
const len = Buffer.byteLength(s)
|
||||
|
||||
ber.writeByte(0x80) // MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG
|
||||
ber.writeByte(len)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Change = require('../change')
|
||||
var Protocol = require('../protocol')
|
||||
var lassert = require('../assert')
|
||||
const LDAPMessage = require('./message')
|
||||
const Change = require('../change')
|
||||
const Protocol = require('../protocol')
|
||||
const lassert = require('../assert')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -40,9 +40,9 @@ ModifyRequest.prototype._parse = function (ber) {
|
|||
this.object = ber.readString()
|
||||
|
||||
ber.readSequence()
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) {
|
||||
var c = new Change()
|
||||
const c = new Change()
|
||||
c.parse(ber)
|
||||
c.modification.type = c.modification.type.toLowerCase()
|
||||
this.changes.push(c)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPResult = require('./result')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var util = require('util')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const util = require('util')
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var asn1 = require('asn1')
|
||||
const assert = require('assert-plus')
|
||||
const asn1 = require('asn1')
|
||||
// var VError = require('verror').VError
|
||||
var logger = require('../logger')
|
||||
const logger = require('../logger')
|
||||
|
||||
var AbandonRequest = require('./abandon_request')
|
||||
var AddRequest = require('./add_request')
|
||||
var AddResponse = require('./add_response')
|
||||
var BindRequest = require('./bind_request')
|
||||
var BindResponse = require('./bind_response')
|
||||
var CompareRequest = require('./compare_request')
|
||||
var CompareResponse = require('./compare_response')
|
||||
var DeleteRequest = require('./del_request')
|
||||
var DeleteResponse = require('./del_response')
|
||||
var ExtendedRequest = require('./ext_request')
|
||||
var ExtendedResponse = require('./ext_response')
|
||||
var ModifyRequest = require('./modify_request')
|
||||
var ModifyResponse = require('./modify_response')
|
||||
var ModifyDNRequest = require('./moddn_request')
|
||||
var ModifyDNResponse = require('./moddn_response')
|
||||
var SearchRequest = require('./search_request')
|
||||
var SearchEntry = require('./search_entry')
|
||||
var SearchReference = require('./search_reference')
|
||||
var SearchResponse = require('./search_response')
|
||||
var UnbindRequest = require('./unbind_request')
|
||||
const AbandonRequest = require('./abandon_request')
|
||||
const AddRequest = require('./add_request')
|
||||
const AddResponse = require('./add_response')
|
||||
const BindRequest = require('./bind_request')
|
||||
const BindResponse = require('./bind_response')
|
||||
const CompareRequest = require('./compare_request')
|
||||
const CompareResponse = require('./compare_response')
|
||||
const DeleteRequest = require('./del_request')
|
||||
const DeleteResponse = require('./del_response')
|
||||
const ExtendedRequest = require('./ext_request')
|
||||
const ExtendedResponse = require('./ext_response')
|
||||
const ModifyRequest = require('./modify_request')
|
||||
const ModifyResponse = require('./modify_response')
|
||||
const ModifyDNRequest = require('./moddn_request')
|
||||
const ModifyDNResponse = require('./moddn_response')
|
||||
const SearchRequest = require('./search_request')
|
||||
const SearchEntry = require('./search_entry')
|
||||
const SearchReference = require('./search_reference')
|
||||
const SearchResponse = require('./search_response')
|
||||
const UnbindRequest = require('./unbind_request')
|
||||
// var UnbindResponse = require('./unbind_response')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
const LDAPResult = require('./result')
|
||||
// var Message = require('./message')
|
||||
|
||||
var Protocol = require('../protocol')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
// var Ber = asn1.Ber
|
||||
var BerReader = asn1.BerReader
|
||||
const BerReader = asn1.BerReader
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -55,8 +55,8 @@ util.inherits(Parser, EventEmitter)
|
|||
Parser.prototype.write = function (data) {
|
||||
if (!data || !Buffer.isBuffer(data)) { throw new TypeError('data (buffer) required') }
|
||||
|
||||
var nextMessage = null
|
||||
var self = this
|
||||
let nextMessage = null
|
||||
const self = this
|
||||
|
||||
function end () {
|
||||
if (nextMessage) { return self.write(nextMessage) }
|
||||
|
@ -66,9 +66,9 @@ Parser.prototype.write = function (data) {
|
|||
|
||||
self.buffer = (self.buffer ? Buffer.concat([self.buffer, data]) : data)
|
||||
|
||||
var ber = new BerReader(self.buffer)
|
||||
const ber = new BerReader(self.buffer)
|
||||
|
||||
var foundSeq = false
|
||||
let foundSeq = false
|
||||
try {
|
||||
foundSeq = ber.readSequence()
|
||||
} catch (e) {
|
||||
|
@ -90,7 +90,7 @@ Parser.prototype.write = function (data) {
|
|||
// pointing at the next sequence of data (if it exists)
|
||||
self.buffer = null
|
||||
|
||||
var message
|
||||
let message
|
||||
try {
|
||||
// Bail here if peer isn't speaking protocol at all
|
||||
message = this.getMessage(ber)
|
||||
|
@ -111,12 +111,12 @@ Parser.prototype.write = function (data) {
|
|||
Parser.prototype.getMessage = function (ber) {
|
||||
assert.ok(ber)
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
var messageID = ber.readInt()
|
||||
var type = ber.readSequence()
|
||||
const messageID = ber.readInt()
|
||||
const type = ber.readSequence()
|
||||
|
||||
var Message
|
||||
let Message
|
||||
switch (type) {
|
||||
case Protocol.LDAP_REQ_ABANDON:
|
||||
Message = AbandonRequest
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
// var asn1 = require('asn1')
|
||||
|
||||
var dtrace = require('../dtrace')
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
const dtrace = require('../dtrace')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
|
@ -46,16 +46,16 @@ LDAPResult.prototype.end = function (status) {
|
|||
|
||||
if (typeof (status) === 'number') { this.status = status }
|
||||
|
||||
var ber = this.toBer()
|
||||
const ber = this.toBer()
|
||||
if (this.log.debug()) { this.log.debug('%s: sending: %j', this.connection.ldap.id, this.json) }
|
||||
|
||||
try {
|
||||
var self = this
|
||||
const self = this
|
||||
this.connection.write(ber)
|
||||
|
||||
if (self._dtraceOp && self._dtraceId) {
|
||||
dtrace.fire('server-' + self._dtraceOp + '-done', function () {
|
||||
var c = self.connection || { ldap: {} }
|
||||
const c = self.connection || { ldap: {} }
|
||||
return [
|
||||
self._dtraceId || 0,
|
||||
(c.remoteAddress || ''),
|
||||
|
@ -79,10 +79,10 @@ LDAPResult.prototype._parse = function (ber) {
|
|||
this.matchedDN = ber.readString()
|
||||
this.errorMessage = ber.readString()
|
||||
|
||||
var t = ber.peek()
|
||||
const t = ber.peek()
|
||||
|
||||
if (t === Protocol.LDAP_REP_REFERRAL) {
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) { this.referrals.push(ber.readString()) }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
// var asn1 = require('asn1')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Attribute = require('../attribute')
|
||||
var Protocol = require('../protocol')
|
||||
var lassert = require('../assert')
|
||||
const LDAPMessage = require('./message')
|
||||
const Attribute = require('../attribute')
|
||||
const Protocol = require('../protocol')
|
||||
const lassert = require('../assert')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
|
@ -39,7 +39,7 @@ Object.defineProperties(SearchEntry.prototype, {
|
|||
},
|
||||
object: {
|
||||
get: function getObject () {
|
||||
var obj = {
|
||||
const obj = {
|
||||
dn: this.dn.toString(),
|
||||
controls: []
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ Object.defineProperties(SearchEntry.prototype, {
|
|||
},
|
||||
raw: {
|
||||
get: function getRaw () {
|
||||
var obj = {
|
||||
const obj = {
|
||||
dn: this.dn.toString(),
|
||||
controls: []
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ SearchEntry.prototype.toObject = function () {
|
|||
SearchEntry.prototype.fromObject = function (obj) {
|
||||
if (typeof (obj) !== 'object') { throw new TypeError('object required') }
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
if (obj.controls) { this.controls = obj.controls }
|
||||
|
||||
if (obj.attributes) { obj = obj.attributes }
|
||||
|
@ -123,11 +123,11 @@ SearchEntry.prototype.setAttributes = function (obj) {
|
|||
})
|
||||
this.attributes = obj
|
||||
} else {
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
self.attributes = []
|
||||
Object.keys(obj).forEach(function (k) {
|
||||
var attr = new Attribute({ type: k })
|
||||
const attr = new Attribute({ type: k })
|
||||
if (Array.isArray(obj[k])) {
|
||||
obj[k].forEach(function (v) {
|
||||
attr.addValue(v.toString())
|
||||
|
@ -158,9 +158,9 @@ SearchEntry.prototype._parse = function (ber) {
|
|||
this.objectName = ber.readString()
|
||||
assert.ok(ber.readSequence())
|
||||
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) {
|
||||
var a = new Attribute()
|
||||
const a = new Attribute()
|
||||
a.parse(ber)
|
||||
this.attributes.push(a)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ SearchEntry.prototype._parse = function (ber) {
|
|||
SearchEntry.prototype._toBer = function (ber) {
|
||||
assert.ok(ber)
|
||||
|
||||
var formattedObjectName = this.objectName.format({ skipSpace: true })
|
||||
const formattedObjectName = this.objectName.format({ skipSpace: true })
|
||||
ber.writeString(formattedObjectName)
|
||||
ber.startSequence()
|
||||
this.attributes.forEach(function (a) {
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
// var asn1 = require('asn1')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var Protocol = require('../protocol')
|
||||
var dn = require('../dn')
|
||||
var url = require('../url')
|
||||
const LDAPMessage = require('./message')
|
||||
const Protocol = require('../protocol')
|
||||
const dn = require('../dn')
|
||||
const url = require('../url')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
// var BerWriter = asn1.BerWriter
|
||||
var parseURL = url.parse
|
||||
const parseURL = url.parse
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -78,7 +78,7 @@ SearchReference.prototype._parse = function (ber, length) {
|
|||
assert.ok(ber)
|
||||
|
||||
while (ber.offset < length) {
|
||||
var _url = ber.readString()
|
||||
const _url = ber.readString()
|
||||
parseURL(_url)
|
||||
this.uris.push(_url)
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
const LDAPMessage = require('./message')
|
||||
// var LDAPResult = require('./result')
|
||||
var dn = require('../dn')
|
||||
var filters = require('../filters')
|
||||
var Protocol = require('../protocol')
|
||||
const dn = require('../dn')
|
||||
const filters = require('../filters')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var Ber = asn1.Ber
|
||||
const Ber = asn1.Ber
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -95,7 +95,7 @@ SearchRequest.prototype._parse = function (ber) {
|
|||
// look for attributes
|
||||
if (ber.peek() === 0x30) {
|
||||
ber.readSequence()
|
||||
var end = ber.offset + ber.length
|
||||
const end = ber.offset + ber.length
|
||||
while (ber.offset < end) { this.attributes.push(ber.readString().toLowerCase()) }
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ SearchRequest.prototype._toBer = function (ber) {
|
|||
// Format only with commas, since that is what RFC 4514 mandates.
|
||||
// There's a gotcha here: even though it's called baseObject,
|
||||
// it can be a string or a DN object.
|
||||
var formattedDN = dn.DN.isDN(this.baseObject)
|
||||
const formattedDN = dn.DN.isDN(this.baseObject)
|
||||
? this.baseObject.format({ skipSpace: true })
|
||||
: this.baseObject.toString()
|
||||
ber.writeString(formattedDN)
|
||||
|
@ -118,7 +118,7 @@ SearchRequest.prototype._toBer = function (ber) {
|
|||
ber.writeInt(this.timeLimit)
|
||||
ber.writeBoolean(this.typesOnly)
|
||||
|
||||
var f = this.filter || new filters.PresenceFilter({ attribute: 'objectclass' })
|
||||
const f = this.filter || new filters.PresenceFilter({ attribute: 'objectclass' })
|
||||
ber = f.toBer(ber)
|
||||
|
||||
ber.startSequence(Ber.Sequence | Ber.Constructor)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPResult = require('./result')
|
||||
var SearchEntry = require('./search_entry')
|
||||
var SearchReference = require('./search_reference')
|
||||
const LDAPResult = require('./result')
|
||||
const SearchEntry = require('./search_entry')
|
||||
const SearchReference = require('./search_reference')
|
||||
|
||||
var dtrace = require('../dtrace')
|
||||
var parseDN = require('../dn').parse
|
||||
var parseURL = require('../url').parse
|
||||
var Protocol = require('../protocol')
|
||||
const dtrace = require('../dtrace')
|
||||
const parseDN = require('../dn').parse
|
||||
const parseURL = require('../url').parse
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
||||
|
@ -39,18 +39,19 @@ SearchResponse.prototype.send = function (entry, nofiltering) {
|
|||
if (nofiltering === undefined) { nofiltering = false }
|
||||
if (typeof (nofiltering) !== 'boolean') { throw new TypeError('noFiltering must be a boolean') }
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
const savedAttrs = {}
|
||||
const save = null
|
||||
if (entry instanceof SearchEntry || entry instanceof SearchReference) {
|
||||
if (!entry.messageID) { entry.messageID = this.messageID }
|
||||
if (entry.messageID !== this.messageID) { throw new Error('SearchEntry messageID mismatch') }
|
||||
} else {
|
||||
if (!entry.attributes) { throw new Error('entry.attributes required') }
|
||||
|
||||
var savedAttrs = {}
|
||||
var all = (self.attributes.indexOf('*') !== -1)
|
||||
const all = (self.attributes.indexOf('*') !== -1)
|
||||
Object.keys(entry.attributes).forEach(function (a) {
|
||||
var _a = a.toLowerCase()
|
||||
const _a = a.toLowerCase()
|
||||
if (!nofiltering && _a.length && _a[0] === '_') {
|
||||
savedAttrs[a] = entry.attributes[a]
|
||||
delete entry.attributes[a]
|
||||
|
@ -58,14 +59,14 @@ SearchResponse.prototype.send = function (entry, nofiltering) {
|
|||
savedAttrs[a] = entry.attributes[a]
|
||||
delete entry.attributes[a]
|
||||
} else if (all) {
|
||||
|
||||
// do nothing
|
||||
} else if (self.attributes.length && self.attributes.indexOf(_a) === -1) {
|
||||
savedAttrs[a] = entry.attributes[a]
|
||||
delete entry.attributes[a]
|
||||
}
|
||||
})
|
||||
|
||||
var save = entry
|
||||
const save = entry
|
||||
entry = new SearchEntry({
|
||||
objectName: typeof (save.dn) === 'string' ? parseDN(save.dn) : save.dn,
|
||||
messageID: self.messageID,
|
||||
|
@ -82,7 +83,7 @@ SearchResponse.prototype.send = function (entry, nofiltering) {
|
|||
|
||||
if (self._dtraceOp && self._dtraceId) {
|
||||
dtrace.fire('server-search-entry', function () {
|
||||
var c = self.connection || { ldap: {} }
|
||||
const c = self.connection || { ldap: {} }
|
||||
return [
|
||||
self._dtraceId || 0,
|
||||
(c.remoteAddress || ''),
|
||||
|
@ -95,7 +96,7 @@ SearchResponse.prototype.send = function (entry, nofiltering) {
|
|||
}
|
||||
|
||||
// Restore attributes
|
||||
Object.keys(savedAttrs || {}).forEach(function (k) {
|
||||
Object.keys(savedAttrs).forEach(function (k) {
|
||||
save.attributes[k] = savedAttrs[k]
|
||||
})
|
||||
} catch (e) {
|
||||
|
@ -107,7 +108,7 @@ SearchResponse.prototype.send = function (entry, nofiltering) {
|
|||
SearchResponse.prototype.createSearchEntry = function (object) {
|
||||
assert.object(object)
|
||||
|
||||
var entry = new SearchEntry({
|
||||
const entry = new SearchEntry({
|
||||
messageID: this.messageID,
|
||||
log: this.log,
|
||||
objectName: object.objectName || object.dn
|
||||
|
@ -121,11 +122,11 @@ SearchResponse.prototype.createSearchReference = function (uris) {
|
|||
|
||||
if (!Array.isArray(uris)) { uris = [uris] }
|
||||
|
||||
for (var i = 0; i < uris.length; i++) {
|
||||
for (let i = 0; i < uris.length; i++) {
|
||||
if (typeof (uris[i]) === 'string') { uris[i] = parseURL(uris[i]) }
|
||||
}
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
return new SearchReference({
|
||||
messageID: self.messageID,
|
||||
log: self.log,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var LDAPMessage = require('./message')
|
||||
var dn = require('../dn')
|
||||
var Protocol = require('../protocol')
|
||||
const LDAPMessage = require('./message')
|
||||
const dn = require('../dn')
|
||||
const Protocol = require('../protocol')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
var DN = dn.DN
|
||||
var RDN = dn.RDN
|
||||
const DN = dn.DN
|
||||
const RDN = dn.RDN
|
||||
|
||||
/// --- API
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert-plus')
|
||||
var util = require('util')
|
||||
const assert = require('assert-plus')
|
||||
const util = require('util')
|
||||
|
||||
var dtrace = require('../dtrace')
|
||||
const dtrace = require('../dtrace')
|
||||
|
||||
var LDAPMessage = require('./result')
|
||||
const LDAPMessage = require('./result')
|
||||
// var Protocol = require('../protocol')
|
||||
|
||||
/// --- API
|
||||
|
@ -40,10 +40,10 @@ UnbindResponse.prototype.end = function (status) {
|
|||
|
||||
this.connection.end()
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
if (self._dtraceOp && self._dtraceId) {
|
||||
dtrace.fire('server-' + self._dtraceOp + '-done', function () {
|
||||
var c = self.connection || { ldap: {} }
|
||||
const c = self.connection || { ldap: {} }
|
||||
return [
|
||||
self._dtraceId || 0,
|
||||
(c.remoteAddress || ''),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// var parseDN = require('./dn').parse
|
||||
|
||||
var EntryChangeNotificationControl =
|
||||
const EntryChangeNotificationControl =
|
||||
require('./controls').EntryChangeNotificationControl
|
||||
|
||||
/// --- API
|
||||
|
@ -17,9 +17,9 @@ PersistentSearch.prototype.addClient = function (req, res, callback) {
|
|||
if (typeof (res) !== 'object') { throw new TypeError('res must be an object') }
|
||||
if (callback && typeof (callback) !== 'function') { throw new TypeError('callback must be a function') }
|
||||
|
||||
var log = req.log
|
||||
const log = req.log
|
||||
|
||||
var client = {}
|
||||
const client = {}
|
||||
client.req = req
|
||||
client.res = res
|
||||
|
||||
|
@ -38,9 +38,9 @@ PersistentSearch.prototype.removeClient = function (req, res, callback) {
|
|||
if (typeof (res) !== 'object') { throw new TypeError('res must be an object') }
|
||||
if (callback && typeof (callback) !== 'function') { throw new TypeError('callback must be a function') }
|
||||
|
||||
var log = req.log
|
||||
const log = req.log
|
||||
log.debug('%s removing client', req.logId)
|
||||
var client = {}
|
||||
const client = {}
|
||||
client.req = req
|
||||
client.res = res
|
||||
|
||||
|
@ -80,8 +80,8 @@ function getOperationType (requestType) {
|
|||
function getEntryChangeNotificationControl (req, obj, callback) {
|
||||
// if we want to return a ECNC
|
||||
if (req.persistentSearch.value.returnECs) {
|
||||
var attrs = obj.attributes
|
||||
var value = {}
|
||||
const attrs = obj.attributes
|
||||
const value = {}
|
||||
value.changeType = getOperationType(attrs.changetype)
|
||||
// if it's a modDN request, fill in the previous DN
|
||||
if (value.changeType === 8 && attrs.previousDN) {
|
||||
|
|
150
lib/server.js
150
lib/server.js
|
@ -1,38 +1,38 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var assert = require('assert')
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var net = require('net')
|
||||
var tls = require('tls')
|
||||
var util = require('util')
|
||||
const assert = require('assert')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const net = require('net')
|
||||
const tls = require('tls')
|
||||
const util = require('util')
|
||||
|
||||
// var asn1 = require('asn1')
|
||||
var VError = require('verror').VError
|
||||
const VError = require('verror').VError
|
||||
|
||||
var dn = require('./dn')
|
||||
var dtrace = require('./dtrace')
|
||||
var errors = require('./errors')
|
||||
var Protocol = require('./protocol')
|
||||
const dn = require('./dn')
|
||||
const dtrace = require('./dtrace')
|
||||
const errors = require('./errors')
|
||||
const Protocol = require('./protocol')
|
||||
|
||||
var Parser = require('./messages').Parser
|
||||
var AbandonResponse = require('./messages/abandon_response')
|
||||
var AddResponse = require('./messages/add_response')
|
||||
var BindResponse = require('./messages/bind_response')
|
||||
var CompareResponse = require('./messages/compare_response')
|
||||
var DeleteResponse = require('./messages/del_response')
|
||||
var ExtendedResponse = require('./messages/ext_response')
|
||||
const Parser = require('./messages').Parser
|
||||
const AbandonResponse = require('./messages/abandon_response')
|
||||
const AddResponse = require('./messages/add_response')
|
||||
const BindResponse = require('./messages/bind_response')
|
||||
const CompareResponse = require('./messages/compare_response')
|
||||
const DeleteResponse = require('./messages/del_response')
|
||||
const ExtendedResponse = require('./messages/ext_response')
|
||||
// var LDAPResult = require('./messages/result')
|
||||
var ModifyResponse = require('./messages/modify_response')
|
||||
var ModifyDNResponse = require('./messages/moddn_response')
|
||||
var SearchRequest = require('./messages/search_request')
|
||||
var SearchResponse = require('./messages/search_response')
|
||||
var UnbindResponse = require('./messages/unbind_response')
|
||||
const ModifyResponse = require('./messages/modify_response')
|
||||
const ModifyDNResponse = require('./messages/moddn_response')
|
||||
const SearchRequest = require('./messages/search_request')
|
||||
const SearchResponse = require('./messages/search_response')
|
||||
const UnbindResponse = require('./messages/unbind_response')
|
||||
|
||||
/// --- Globals
|
||||
|
||||
// var Ber = asn1.Ber
|
||||
// var BerReader = asn1.BerReader
|
||||
var DN = dn.DN
|
||||
const DN = dn.DN
|
||||
|
||||
// var sprintf = util.format
|
||||
|
||||
|
@ -44,12 +44,12 @@ function mergeFunctionArgs (argv, start, end) {
|
|||
if (!start) { start = 0 }
|
||||
if (!end) { end = argv.length }
|
||||
|
||||
var handlers = []
|
||||
const handlers = []
|
||||
|
||||
for (var i = start; i < end; i++) {
|
||||
for (let i = start; i < end; i++) {
|
||||
if (argv[i] instanceof Array) {
|
||||
var arr = argv[i]
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
const arr = argv[i]
|
||||
for (let j = 0; j < arr.length; j++) {
|
||||
if (!(arr[j] instanceof Function)) {
|
||||
throw new TypeError('Invalid argument type: ' + typeof (arr[j]))
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ function mergeFunctionArgs (argv, start, end) {
|
|||
function getResponse (req) {
|
||||
assert.ok(req)
|
||||
|
||||
var Response
|
||||
let Response
|
||||
|
||||
switch (req.protocolOp) {
|
||||
case Protocol.LDAP_REQ_BIND:
|
||||
|
@ -106,7 +106,7 @@ function getResponse (req) {
|
|||
}
|
||||
assert.ok(Response)
|
||||
|
||||
var res = new Response({
|
||||
const res = new Response({
|
||||
messageID: req.messageID,
|
||||
log: req.log,
|
||||
attributes: ((req instanceof SearchRequest) ? req.attributes : undefined)
|
||||
|
@ -161,14 +161,14 @@ function fireDTraceProbe (req, res) {
|
|||
assert.ok(req)
|
||||
|
||||
req._dtraceId = res._dtraceId = dtrace._nextId()
|
||||
var probeArgs = [
|
||||
const probeArgs = [
|
||||
req._dtraceId,
|
||||
req.connection.remoteAddress || 'localhost',
|
||||
req.connection.ldap.bindDN.toString(),
|
||||
req.dn.toString()
|
||||
]
|
||||
|
||||
var op
|
||||
let op
|
||||
switch (req.protocolOp) {
|
||||
case Protocol.LDAP_REQ_ABANDON:
|
||||
op = 'abandon'
|
||||
|
@ -255,7 +255,7 @@ function Server (options) {
|
|||
} else {
|
||||
options = {}
|
||||
}
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
EventEmitter.call(this, options)
|
||||
|
||||
|
@ -263,7 +263,7 @@ function Server (options) {
|
|||
this.log = options.log
|
||||
this.strictDN = (options.strictDN !== undefined) ? options.strictDN : true
|
||||
|
||||
var log = this.log
|
||||
const log = this.log
|
||||
|
||||
function setupConnection (c) {
|
||||
assert.ok(c)
|
||||
|
@ -277,7 +277,7 @@ function Server (options) {
|
|||
c.remotePort = c.socket.remotePort
|
||||
}
|
||||
|
||||
var rdn = new dn.RDN({ cn: 'anonymous' })
|
||||
const rdn = new dn.RDN({ cn: 'anonymous' })
|
||||
|
||||
c.ldap = {
|
||||
id: c.remoteAddress + ':' + c.remotePort,
|
||||
|
@ -331,7 +331,7 @@ function Server (options) {
|
|||
|
||||
if (log.debug()) { log.debug('%s: message received: req=%j', c.ldap.id, req.json) }
|
||||
|
||||
var res = getResponse(req)
|
||||
const res = getResponse(req)
|
||||
if (!res) {
|
||||
log.warn('Unimplemented server method: %s', req.type)
|
||||
c.destroy()
|
||||
|
@ -372,9 +372,9 @@ function Server (options) {
|
|||
res.logId = req.logId
|
||||
res.requestDN = req.dn
|
||||
|
||||
var chain = self._getHandlerChain(req, res)
|
||||
const chain = self._getHandlerChain(req, res)
|
||||
|
||||
var i = 0
|
||||
let i = 0
|
||||
return (function messageIIFE (err) {
|
||||
function sendError (err) {
|
||||
res.status = err.code || errors.LDAP_OPERATIONS_ERROR
|
||||
|
@ -401,7 +401,7 @@ function Server (options) {
|
|||
}
|
||||
|
||||
try {
|
||||
var next = messageIIFE
|
||||
const next = messageIIFE
|
||||
if (chain.handlers[i]) { return chain.handlers[i++].call(chain.backend, req, res, next) }
|
||||
|
||||
if (req.protocolOp === Protocol.LDAP_REQ_BIND && res.status === 0) { c.ldap.bindDN = req.dn }
|
||||
|
@ -420,7 +420,7 @@ function Server (options) {
|
|||
|
||||
if (!message) { return c.destroy() }
|
||||
|
||||
var res = getResponse(message)
|
||||
const res = getResponse(message)
|
||||
if (!res) { return c.destroy() }
|
||||
|
||||
res.status = 0x02 // protocol error
|
||||
|
@ -478,14 +478,14 @@ Object.defineProperties(Server.prototype, {
|
|||
},
|
||||
url: {
|
||||
get: function getURL () {
|
||||
var str
|
||||
var addr = this.server.address()
|
||||
let str
|
||||
const addr = this.server.address()
|
||||
if (!addr) {
|
||||
return null
|
||||
}
|
||||
if (!addr.family) {
|
||||
str = 'ldapi://'
|
||||
str += this.host.replace(new RegExp('/', 'g'), '%2f')
|
||||
str += this.host.replace(/\//g, '%2f')
|
||||
return str
|
||||
}
|
||||
if (this.server instanceof tls.Server) {
|
||||
|
@ -512,7 +512,7 @@ module.exports = Server
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.add = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_ADD, name, args)
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ Server.prototype.add = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.bind = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_BIND, name, args)
|
||||
}
|
||||
|
||||
|
@ -542,7 +542,7 @@ Server.prototype.bind = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.compare = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_COMPARE, name, args)
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ Server.prototype.compare = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.del = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_DELETE, name, args)
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,7 @@ Server.prototype.del = function (name) {
|
|||
* @throws {TypeError} on bad input.
|
||||
*/
|
||||
Server.prototype.exop = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_EXTENSION, name, args, true)
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ Server.prototype.exop = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.modify = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_MODIFY, name, args)
|
||||
}
|
||||
|
||||
|
@ -602,7 +602,7 @@ Server.prototype.modify = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.modifyDN = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_MODRDN, name, args)
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ Server.prototype.modifyDN = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.search = function (name) {
|
||||
var args = Array.prototype.slice.call(arguments, 1)
|
||||
const args = Array.prototype.slice.call(arguments, 1)
|
||||
return this._mount(Protocol.LDAP_REQ_SEARCH, name, args)
|
||||
}
|
||||
|
||||
|
@ -631,14 +631,14 @@ Server.prototype.search = function (name) {
|
|||
* @throws {TypeError} on bad input
|
||||
*/
|
||||
Server.prototype.unbind = function () {
|
||||
var args = Array.prototype.slice.call(arguments, 0)
|
||||
const args = Array.prototype.slice.call(arguments, 0)
|
||||
return this._mount(Protocol.LDAP_REQ_UNBIND, 'unbind', args, true)
|
||||
}
|
||||
|
||||
Server.prototype.use = function use () {
|
||||
var args = Array.prototype.slice.call(arguments)
|
||||
var chain = mergeFunctionArgs(args, 0, args.length)
|
||||
var self = this
|
||||
const args = Array.prototype.slice.call(arguments)
|
||||
const chain = mergeFunctionArgs(args, 0, args.length)
|
||||
const self = this
|
||||
chain.forEach(function (c) {
|
||||
self._chain.push(c)
|
||||
})
|
||||
|
@ -647,7 +647,7 @@ Server.prototype.use = function use () {
|
|||
Server.prototype.after = function () {
|
||||
if (!this._postChain) { this._postChain = [] }
|
||||
|
||||
var self = this
|
||||
const self = this
|
||||
mergeFunctionArgs(arguments).forEach(function (h) {
|
||||
self._postChain.push(h)
|
||||
})
|
||||
|
@ -665,7 +665,7 @@ Server.prototype.listen = function (port, host, callback) {
|
|||
// Disambiguate between string ports and file paths
|
||||
port = parseInt(port, 10)
|
||||
}
|
||||
var self = this
|
||||
const self = this
|
||||
|
||||
function cbListen () {
|
||||
if (typeof (port) === 'number') {
|
||||
|
@ -706,7 +706,7 @@ Server.prototype._getRoute = function (_dn, backend) {
|
|||
|
||||
if (!backend) { backend = this }
|
||||
|
||||
var name
|
||||
let name
|
||||
if (_dn instanceof dn.DN) {
|
||||
name = _dn.toString()
|
||||
} else {
|
||||
|
@ -728,19 +728,19 @@ Server.prototype._sortedRouteKeys = function _sortedRouteKeys () {
|
|||
// The filtered/sorted route keys are cached to prevent needlessly
|
||||
// regenerating the list for every incoming request.
|
||||
if (!this._routeKeyCache) {
|
||||
var self = this
|
||||
var reversedRDNsToKeys = {}
|
||||
const self = this
|
||||
const reversedRDNsToKeys = {}
|
||||
// Generate mapping of reversedRDNs(DN) -> routeKey
|
||||
Object.keys(this.routes).forEach(function (key) {
|
||||
var _dn = self.routes[key].dn
|
||||
const _dn = self.routes[key].dn
|
||||
// Ignore non-DN routes such as exop or unbind
|
||||
if (_dn instanceof dn.DN) {
|
||||
var reversed = _dn.clone()
|
||||
const reversed = _dn.clone()
|
||||
reversed.rdns.reverse()
|
||||
reversedRDNsToKeys[reversed.format()] = key
|
||||
}
|
||||
})
|
||||
var output = []
|
||||
const output = []
|
||||
// Reverse-sort on reversedRDS(DN) in order to output routeKey list.
|
||||
// This will place more specific DNs in front of their parents:
|
||||
// 1. dc=test, dc=domain, dc=sub
|
||||
|
@ -759,9 +759,9 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
|||
|
||||
fireDTraceProbe(req, res)
|
||||
|
||||
var self = this
|
||||
var routes = this.routes
|
||||
var route
|
||||
const self = this
|
||||
const routes = this.routes
|
||||
let route
|
||||
|
||||
// check anonymous bind
|
||||
if (req.protocolOp === Protocol.LDAP_REQ_BIND &&
|
||||
|
@ -773,7 +773,7 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
|||
}
|
||||
}
|
||||
|
||||
var op = '0x' + req.protocolOp.toString(16)
|
||||
const op = '0x' + req.protocolOp.toString(16)
|
||||
|
||||
// Special cases are exops, unbinds and abandons. Handle those first.
|
||||
if (req.protocolOp === Protocol.LDAP_REQ_EXTENSION) {
|
||||
|
@ -811,13 +811,13 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
|||
|
||||
// Otherwise, match via DN rules
|
||||
assert.ok(req.dn)
|
||||
var keys = this._sortedRouteKeys()
|
||||
var fallbackHandler = [noSuffixHandler]
|
||||
const keys = this._sortedRouteKeys()
|
||||
let fallbackHandler = [noSuffixHandler]
|
||||
// invalid DNs in non-strict mode are routed to the default handler
|
||||
var testDN = (typeof (req.dn) === 'string') ? '' : req.dn
|
||||
const testDN = (typeof (req.dn) === 'string') ? '' : req.dn
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var suffix = keys[i]
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const suffix = keys[i]
|
||||
route = routes[suffix]
|
||||
assert.ok(route.dn)
|
||||
// Match a valid route or the route wildcard ('')
|
||||
|
@ -854,16 +854,16 @@ Server.prototype._mount = function (op, name, argv, notDN) {
|
|||
if (typeof (name) !== 'string') { throw new TypeError('name (string) required') }
|
||||
if (!argv.length) { throw new Error('at least one handler required') }
|
||||
|
||||
var backend = this
|
||||
var index = 0
|
||||
let backend = this
|
||||
let index = 0
|
||||
|
||||
if (typeof (argv[0]) === 'object' && !Array.isArray(argv[0])) {
|
||||
backend = argv[0]
|
||||
index = 1
|
||||
}
|
||||
var route = this._getRoute(notDN ? name : dn.parse(name), backend)
|
||||
const route = this._getRoute(notDN ? name : dn.parse(name), backend)
|
||||
|
||||
var chain = this._chain.slice()
|
||||
const chain = this._chain.slice()
|
||||
argv.slice(index).forEach(function (a) {
|
||||
chain.push(a)
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = {
|
|||
|
||||
if (u.search) {
|
||||
u.attributes = []
|
||||
var tmp = u.search.substr(1).split('?')
|
||||
const tmp = u.search.substr(1).split('?')
|
||||
if (tmp && tmp.length) {
|
||||
if (tmp[0]) {
|
||||
tmp[0].split(',').forEach(function (a) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
"get-port": "^5.1.1",
|
||||
"husky": "^4.2.5",
|
||||
"snazzy": "^9.0.0",
|
||||
"standard": "^15.0.0",
|
||||
"standard": "^16.0.0",
|
||||
"tap": "14.10.8"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -31,9 +31,9 @@ test('new with args', function (t) {
|
|||
})
|
||||
|
||||
test('new with args and buffer', function (t) {
|
||||
var img = fs.readFileSync(path.join(__dirname, '/imgs/test.jpg'))
|
||||
const img = fs.readFileSync(path.join(__dirname, '/imgs/test.jpg'))
|
||||
|
||||
var change = new Change({
|
||||
const change = new Change({
|
||||
operation: 'add',
|
||||
modification: {
|
||||
thumbnailPhoto: img
|
||||
|
|
|
@ -96,7 +96,7 @@ tap.beforeEach((done, t) => {
|
|||
}
|
||||
}))
|
||||
} else {
|
||||
var e = res.createSearchEntry({
|
||||
const e = res.createSearchEntry({
|
||||
objectName: req.dn,
|
||||
attributes: {
|
||||
cn: ['unit', 'test'],
|
||||
|
@ -1100,7 +1100,7 @@ tap.test('search empty attribute', function (t) {
|
|||
t.ok(res)
|
||||
let gotEntry = 0
|
||||
res.on('searchEntry', function (entry) {
|
||||
var obj = entry.toObject()
|
||||
const obj = entry.toObject()
|
||||
t.equal('dc=empty', obj.dn)
|
||||
t.ok(obj.member)
|
||||
t.equal(obj.member.length, 0)
|
||||
|
@ -1142,7 +1142,7 @@ tap.test('GH-21 binary attributes', function (t) {
|
|||
t.ok(entry.attributes[1].type, 'gb18030')
|
||||
t.equal(entry.attributes[1].buffers.length, 1)
|
||||
t.equal(expect2.length, entry.attributes[1].buffers[0].length)
|
||||
for (var i = 0; i < expect2.length; i++) { t.equal(expect2[i], entry.attributes[1].buffers[0][i]) }
|
||||
for (let i = 0; i < expect2.length; i++) { t.equal(expect2[i], entry.attributes[1].buffers[0][i]) }
|
||||
|
||||
t.ok(entry.object)
|
||||
gotEntry++
|
||||
|
@ -1240,7 +1240,7 @@ tap.test('idle timeout', function (t) {
|
|||
t.error(err)
|
||||
})
|
||||
res.on('end', function () {
|
||||
var late = setTimeout(function () {
|
||||
const late = setTimeout(function () {
|
||||
t.fail('too late')
|
||||
}, 500)
|
||||
// It's ok to go idle now
|
||||
|
@ -1358,7 +1358,7 @@ tap.test('abort reconnect', function (t) {
|
|||
socketPath: 'an invalid path',
|
||||
reconnect: true
|
||||
})
|
||||
var retryCount = 0
|
||||
let retryCount = 0
|
||||
abortClient.on('connectError', function () {
|
||||
++retryCount
|
||||
})
|
||||
|
@ -1531,7 +1531,7 @@ tap.test('connection timeout', function (t) {
|
|||
timeout: 1
|
||||
})
|
||||
|
||||
var done = false
|
||||
let done = false
|
||||
|
||||
setTimeout(function () {
|
||||
if (!done) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
||||
|
||||
var test = require('tap').test
|
||||
const test = require('tap').test
|
||||
|
||||
var asn1 = require('asn1')
|
||||
const asn1 = require('asn1')
|
||||
|
||||
var BerReader = asn1.BerReader
|
||||
var BerWriter = asn1.BerWriter
|
||||
var getControl
|
||||
var PersistentSearchControl
|
||||
const BerReader = asn1.BerReader
|
||||
const BerWriter = asn1.BerWriter
|
||||
let getControl
|
||||
let PersistentSearchControl
|
||||
|
||||
/// --- Tests
|
||||
|
||||
|
@ -25,7 +25,7 @@ test('new no args', function (t) {
|
|||
})
|
||||
|
||||
test('new with args', function (t) {
|
||||
var c = new PersistentSearchControl({
|
||||
const c = new PersistentSearchControl({
|
||||
type: '2.16.840.1.113730.3.4.3',
|
||||
criticality: true,
|
||||
value: {
|
||||
|
@ -42,10 +42,10 @@ test('new with args', function (t) {
|
|||
t.equal(c.value.changesOnly, false)
|
||||
t.equal(c.value.returnECs, false)
|
||||
|
||||
var writer = new BerWriter()
|
||||
const writer = new BerWriter()
|
||||
c.toBer(writer)
|
||||
var reader = new BerReader(writer.buffer)
|
||||
var psc = getControl(reader)
|
||||
const reader = new BerReader(writer.buffer)
|
||||
const psc = getControl(reader)
|
||||
t.ok(psc)
|
||||
t.equal(psc.type, '2.16.840.1.113730.3.4.3')
|
||||
t.ok(psc.criticality)
|
||||
|
@ -57,14 +57,14 @@ test('new with args', function (t) {
|
|||
})
|
||||
|
||||
test('getControl with args', function (t) {
|
||||
var buf = Buffer.from([
|
||||
const buf = Buffer.from([
|
||||
0x30, 0x26, 0x04, 0x17, 0x32, 0x2e, 0x31, 0x36, 0x2e, 0x38, 0x34, 0x30,
|
||||
0x2e, 0x31, 0x2e, 0x31, 0x31, 0x33, 0x37, 0x33, 0x30, 0x2e, 0x33, 0x2e,
|
||||
0x34, 0x2e, 0x33, 0x04, 0x0b, 0x30, 0x09, 0x02, 0x01, 0x0f, 0x01, 0x01,
|
||||
0xff, 0x01, 0x01, 0xff])
|
||||
|
||||
var ber = new BerReader(buf)
|
||||
var psc = getControl(ber)
|
||||
const ber = new BerReader(buf)
|
||||
const psc = getControl(ber)
|
||||
t.ok(psc)
|
||||
t.equal(psc.type, '2.16.840.1.113730.3.4.3')
|
||||
t.equal(psc.criticality, false)
|
||||
|
@ -75,7 +75,7 @@ test('getControl with args', function (t) {
|
|||
})
|
||||
|
||||
test('tober', function (t) {
|
||||
var psc = new PersistentSearchControl({
|
||||
const psc = new PersistentSearchControl({
|
||||
type: '2.16.840.1.113730.3.4.3',
|
||||
criticality: true,
|
||||
value: {
|
||||
|
@ -85,10 +85,10 @@ test('tober', function (t) {
|
|||
}
|
||||
})
|
||||
|
||||
var ber = new BerWriter()
|
||||
const ber = new BerWriter()
|
||||
psc.toBer(ber)
|
||||
|
||||
var c = getControl(new BerReader(ber.buffer))
|
||||
const c = getControl(new BerReader(ber.buffer))
|
||||
t.ok(c)
|
||||
t.equal(c.type, '2.16.840.1.113730.3.4.3')
|
||||
t.ok(c.criticality)
|
||||
|
|
|
@ -35,7 +35,7 @@ tap.beforeEach((done, t) => {
|
|||
})
|
||||
|
||||
server.search(suffix, function (req, res, next) {
|
||||
var entry = {
|
||||
const entry = {
|
||||
dn: 'cn=foo, ' + suffix,
|
||||
attributes: {
|
||||
objectclass: ['person', 'top'],
|
||||
|
|
Loading…
Reference in New Issue