Replace protocol with module (#806)
This commit is contained in:
parent
4355893077
commit
cb70776445
|
@ -4,7 +4,7 @@ const assert = require('assert')
|
||||||
|
|
||||||
const asn1 = require('@ldapjs/asn1')
|
const asn1 = require('@ldapjs/asn1')
|
||||||
|
|
||||||
const Protocol = require('./protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ Attribute.prototype.parse = function parse (ber) {
|
||||||
ber.readSequence()
|
ber.readSequence()
|
||||||
this.type = ber.readString()
|
this.type = ber.readString()
|
||||||
|
|
||||||
if (ber.peek() === Protocol.LBER_SET) {
|
if (ber.peek() === Protocol.core.LBER_SET) {
|
||||||
if (ber.readSequence(Protocol.LBER_SET)) {
|
if (ber.readSequence(Protocol.core.LBER_SET)) {
|
||||||
const end = ber.offset + ber.length
|
const end = ber.offset + ber.length
|
||||||
while (ber.offset < end) { this._vals.push(ber.readString(asn1.Ber.OctetString, true)) }
|
while (ber.offset < end) { this._vals.push(ber.readString(asn1.Ber.OctetString, true)) }
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ Attribute.prototype.toBer = function toBer (ber) {
|
||||||
|
|
||||||
ber.startSequence()
|
ber.startSequence()
|
||||||
ber.writeString(this.type)
|
ber.writeString(this.type)
|
||||||
ber.startSequence(Protocol.LBER_SET)
|
ber.startSequence(Protocol.core.LBER_SET)
|
||||||
if (this._vals.length) {
|
if (this._vals.length) {
|
||||||
this._vals.forEach(function (b) {
|
this._vals.forEach(function (b) {
|
||||||
ber.writeByte(asn1.Ber.OctetString)
|
ber.writeByte(asn1.Ber.OctetString)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
const assert = require('assert-plus')
|
const assert = require('assert-plus')
|
||||||
|
|
||||||
const Attribute = require('./attribute')
|
const Attribute = require('./attribute')
|
||||||
// var Protocol = require('./protocol')
|
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const Change = require('../change')
|
||||||
const Control = require('../controls/index').Control
|
const Control = require('../controls/index').Control
|
||||||
const { Control: LdapControl } = require('@ldapjs/controls')
|
const { Control: LdapControl } = require('@ldapjs/controls')
|
||||||
const SearchPager = require('./search_pager')
|
const SearchPager = require('./search_pager')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const dn = require('../dn')
|
const dn = require('../dn')
|
||||||
const errors = require('../errors')
|
const errors = require('../errors')
|
||||||
const filters = require('../filters')
|
const filters = require('../filters')
|
||||||
|
@ -601,7 +601,7 @@ Client.prototype.search = function search (base,
|
||||||
baseObject: baseDN,
|
baseObject: baseDN,
|
||||||
scope: options.scope || 'base',
|
scope: options.scope || 'base',
|
||||||
filter: options.filter,
|
filter: options.filter,
|
||||||
derefAliases: options.derefAliases || Protocol.NEVER_DEREF_ALIASES,
|
derefAliases: options.derefAliases || Protocol.search.NEVER_DEREF_ALIASES,
|
||||||
sizeLimit: options.sizeLimit || 0,
|
sizeLimit: options.sizeLimit || 0,
|
||||||
timeLimit: options.timeLimit || 10,
|
timeLimit: options.timeLimit || 10,
|
||||||
typesOnly: options.typesOnly || false,
|
typesOnly: options.typesOnly || false,
|
||||||
|
|
|
@ -7,7 +7,6 @@ const assert = require('assert-plus')
|
||||||
|
|
||||||
// var dn = require('../dn')
|
// var dn = require('../dn')
|
||||||
// var messages = require('../messages/index')
|
// var messages = require('../messages/index')
|
||||||
// var Protocol = require('../protocol')
|
|
||||||
const { PagedResultsControl } = require('@ldapjs/controls')
|
const { PagedResultsControl } = require('@ldapjs/controls')
|
||||||
|
|
||||||
const CorkedEmitter = require('../corked_emitter.js')
|
const CorkedEmitter = require('../corked_emitter.js')
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
// var assert = require('assert')
|
// var assert = require('assert')
|
||||||
|
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
const TYPES = {
|
const TYPES = {
|
||||||
and: Protocol.FILTER_AND,
|
and: Protocol.search.FILTER_AND,
|
||||||
or: Protocol.FILTER_OR,
|
or: Protocol.search.FILTER_OR,
|
||||||
not: Protocol.FILTER_NOT,
|
not: Protocol.search.FILTER_NOT,
|
||||||
equal: Protocol.FILTER_EQUALITY,
|
equal: Protocol.search.FILTER_EQUALITY,
|
||||||
substring: Protocol.FILTER_SUBSTRINGS,
|
substring: Protocol.search.FILTER_SUBSTRINGS,
|
||||||
ge: Protocol.FILTER_GE,
|
ge: Protocol.search.FILTER_GE,
|
||||||
le: Protocol.FILTER_LE,
|
le: Protocol.search.FILTER_LE,
|
||||||
present: Protocol.FILTER_PRESENT,
|
present: Protocol.search.FILTER_PRESENT,
|
||||||
approx: Protocol.FILTER_APPROX,
|
approx: Protocol.search.FILTER_APPROX,
|
||||||
ext: Protocol.FILTER_EXT
|
ext: Protocol.search.FILTER_EXT
|
||||||
}
|
}
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
|
@ -6,7 +6,7 @@ const asn1 = require('@ldapjs/asn1')
|
||||||
|
|
||||||
const parents = require('ldap-filter')
|
const parents = require('ldap-filter')
|
||||||
|
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
const Filter = require('./filter')
|
const Filter = require('./filter')
|
||||||
const AndFilter = require('./and_filter')
|
const AndFilter = require('./and_filter')
|
||||||
|
@ -71,53 +71,53 @@ function _parse (ber) {
|
||||||
|
|
||||||
const type = ber.readSequence()
|
const type = ber.readSequence()
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Protocol.FILTER_AND:
|
case Protocol.search.FILTER_AND:
|
||||||
f = new AndFilter()
|
f = new AndFilter()
|
||||||
parseSet(f)
|
parseSet(f)
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.FILTER_APPROX:
|
case Protocol.search.FILTER_APPROX:
|
||||||
f = new ApproximateFilter()
|
f = new ApproximateFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.FILTER_EQUALITY:
|
case Protocol.search.FILTER_EQUALITY:
|
||||||
f = new EqualityFilter()
|
f = new EqualityFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case Protocol.FILTER_EXT:
|
case Protocol.search.FILTER_EXT:
|
||||||
f = new ExtensibleFilter()
|
f = new ExtensibleFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case Protocol.FILTER_GE:
|
case Protocol.search.FILTER_GE:
|
||||||
f = new GreaterThanEqualsFilter()
|
f = new GreaterThanEqualsFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case Protocol.FILTER_LE:
|
case Protocol.search.FILTER_LE:
|
||||||
f = new LessThanEqualsFilter()
|
f = new LessThanEqualsFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
return f
|
return f
|
||||||
|
|
||||||
case Protocol.FILTER_NOT:
|
case Protocol.search.FILTER_NOT:
|
||||||
f = new NotFilter({
|
f = new NotFilter({
|
||||||
filter: _parse(ber)
|
filter: _parse(ber)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.FILTER_OR:
|
case Protocol.search.FILTER_OR:
|
||||||
f = new OrFilter()
|
f = new OrFilter()
|
||||||
parseSet(f)
|
parseSet(f)
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.FILTER_PRESENT:
|
case Protocol.search.FILTER_PRESENT:
|
||||||
f = new PresenceFilter()
|
f = new PresenceFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.FILTER_SUBSTRINGS:
|
case Protocol.search.FILTER_SUBSTRINGS:
|
||||||
f = new SubstringFilter()
|
f = new SubstringFilter()
|
||||||
f.parse(ber)
|
f.parse(ber)
|
||||||
break
|
break
|
||||||
|
|
|
@ -5,7 +5,7 @@ const logger = require('./logger')
|
||||||
const client = require('./client')
|
const client = require('./client')
|
||||||
const Attribute = require('./attribute')
|
const Attribute = require('./attribute')
|
||||||
const Change = require('./change')
|
const Change = require('./change')
|
||||||
const Protocol = require('./protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const Server = require('./server')
|
const Server = require('./server')
|
||||||
|
|
||||||
const controls = require('./controls')
|
const controls = require('./controls')
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ function AbandonRequest (options) {
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
assert.optionalNumber(options.abandonID)
|
assert.optionalNumber(options.abandonID)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_ABANDON
|
options.protocolOp = Protocol.operations.LDAP_REQ_ABANDON
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.abandonID = options.abandonID || 0
|
this.abandonID = options.abandonID || 0
|
||||||
|
|
|
@ -4,7 +4,6 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./result')
|
const LDAPMessage = require('./result')
|
||||||
// var Protocol = require('../protocol')
|
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Attribute = require('../attribute')
|
const Attribute = require('../attribute')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const lassert = require('../assert')
|
const lassert = require('../assert')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
@ -16,7 +16,7 @@ function AddRequest (options) {
|
||||||
lassert.optionalStringDN(options.entry)
|
lassert.optionalStringDN(options.entry)
|
||||||
lassert.optionalArrayOfAttribute(options.attributes)
|
lassert.optionalArrayOfAttribute(options.attributes)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_ADD
|
options.protocolOp = Protocol.operations.LDAP_REQ_ADD
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.entry = options.entry || null
|
this.entry = options.entry || null
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function AddResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_ADD
|
options.protocolOp = Protocol.operations.LDAP_RES_ADD
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(AddResponse, LDAPResult)
|
util.inherits(AddResponse, LDAPResult)
|
||||||
|
|
|
@ -6,7 +6,7 @@ const util = require('util')
|
||||||
const asn1 = require('@ldapjs/asn1')
|
const asn1 = require('@ldapjs/asn1')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function BindRequest (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_BIND
|
options.protocolOp = Protocol.operations.LDAP_REQ_BIND
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.version = options.version || 0x03
|
this.version = options.version || 0x03
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function BindResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_BIND
|
options.protocolOp = Protocol.operations.LDAP_RES_BIND
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(BindResponse, LDAPResult)
|
util.inherits(BindResponse, LDAPResult)
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const lassert = require('../assert')
|
const lassert = require('../assert')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
@ -16,7 +16,7 @@ function CompareRequest (options) {
|
||||||
assert.optionalString(options.value)
|
assert.optionalString(options.value)
|
||||||
lassert.optionalStringDN(options.entry)
|
lassert.optionalStringDN(options.entry)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_COMPARE
|
options.protocolOp = Protocol.operations.LDAP_REQ_COMPARE
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.entry = options.entry || null
|
this.entry = options.entry || null
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function CompareResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_COMPARE
|
options.protocolOp = Protocol.operations.LDAP_RES_COMPARE
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(CompareResponse, LDAPResult)
|
util.inherits(CompareResponse, LDAPResult)
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const lassert = require('../assert')
|
const lassert = require('../assert')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
@ -14,7 +14,7 @@ function DeleteRequest (options) {
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
lassert.optionalStringDN(options.entry)
|
lassert.optionalStringDN(options.entry)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_DELETE
|
options.protocolOp = Protocol.operations.LDAP_REQ_DELETE
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.entry = options.entry || null
|
this.entry = options.entry || null
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function DeleteResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_DELETE
|
options.protocolOp = Protocol.operations.LDAP_RES_DELETE
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(DeleteResponse, LDAPResult)
|
util.inherits(DeleteResponse, LDAPResult)
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ function ExtendedRequest (options) {
|
||||||
throw new TypeError('options.requestValue must be a buffer or a string')
|
throw new TypeError('options.requestValue must be a buffer or a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_EXTENSION
|
options.protocolOp = Protocol.operations.LDAP_REQ_EXTENSION
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.requestName = options.requestName || ''
|
this.requestName = options.requestName || ''
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ function ExtendedResponse (options) {
|
||||||
this.responseName = options.responseName || undefined
|
this.responseName = options.responseName || undefined
|
||||||
this.responseValue = options.responseValue || undefined
|
this.responseValue = options.responseValue || undefined
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_EXTENSION
|
options.protocolOp = Protocol.operations.LDAP_RES_EXTENSION
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(ExtendedResponse, LDAPResult)
|
util.inherits(ExtendedResponse, LDAPResult)
|
||||||
|
|
|
@ -7,7 +7,6 @@ const asn1 = require('@ldapjs/asn1')
|
||||||
|
|
||||||
const logger = require('../logger')
|
const logger = require('../logger')
|
||||||
// var Control = require('../controls').Control
|
// var Control = require('../controls').Control
|
||||||
// var Protocol = require('../protocol')
|
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const dn = require('../dn')
|
const dn = require('../dn')
|
||||||
const lassert = require('../assert')
|
const lassert = require('../assert')
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ function ModifyDNRequest (options) {
|
||||||
lassert.optionalDN(options.newRdn)
|
lassert.optionalDN(options.newRdn)
|
||||||
lassert.optionalDN(options.newSuperior)
|
lassert.optionalDN(options.newSuperior)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_MODRDN
|
options.protocolOp = Protocol.operations.LDAP_REQ_MODRDN
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.entry = options.entry || null
|
this.entry = options.entry || null
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function ModifyDNResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_MODRDN
|
options.protocolOp = Protocol.operations.LDAP_RES_MODRDN
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(ModifyDNResponse, LDAPResult)
|
util.inherits(ModifyDNResponse, LDAPResult)
|
||||||
|
|
|
@ -5,7 +5,7 @@ const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Change = require('../change')
|
const Change = require('../change')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const lassert = require('../assert')
|
const lassert = require('../assert')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
@ -16,7 +16,7 @@ function ModifyRequest (options) {
|
||||||
lassert.optionalStringDN(options.object)
|
lassert.optionalStringDN(options.object)
|
||||||
lassert.optionalArrayOfAttribute(options.attributes)
|
lassert.optionalArrayOfAttribute(options.attributes)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_MODIFY
|
options.protocolOp = Protocol.operations.LDAP_REQ_MODIFY
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.object = options.object || null
|
this.object = options.object || null
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert-plus')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
|
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ function ModifyResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_MODIFY
|
options.protocolOp = Protocol.operations.LDAP_RES_MODIFY
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(ModifyResponse, LDAPResult)
|
util.inherits(ModifyResponse, LDAPResult)
|
||||||
|
|
|
@ -33,7 +33,7 @@ const UnbindRequest = require('./unbind_request')
|
||||||
const LDAPResult = require('./result')
|
const LDAPResult = require('./result')
|
||||||
// var Message = require('./message')
|
// var Message = require('./message')
|
||||||
|
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
|
@ -118,83 +118,83 @@ Parser.prototype.getMessage = function (ber) {
|
||||||
|
|
||||||
let Message
|
let Message
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Protocol.LDAP_REQ_ABANDON:
|
case Protocol.operations.LDAP_REQ_ABANDON:
|
||||||
Message = AbandonRequest
|
Message = AbandonRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_ADD:
|
case Protocol.operations.LDAP_REQ_ADD:
|
||||||
Message = AddRequest
|
Message = AddRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_ADD:
|
case Protocol.operations.LDAP_RES_ADD:
|
||||||
Message = AddResponse
|
Message = AddResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_BIND:
|
case Protocol.operations.LDAP_REQ_BIND:
|
||||||
Message = BindRequest
|
Message = BindRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_BIND:
|
case Protocol.operations.LDAP_RES_BIND:
|
||||||
Message = BindResponse
|
Message = BindResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_COMPARE:
|
case Protocol.operations.LDAP_REQ_COMPARE:
|
||||||
Message = CompareRequest
|
Message = CompareRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_COMPARE:
|
case Protocol.operations.LDAP_RES_COMPARE:
|
||||||
Message = CompareResponse
|
Message = CompareResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_DELETE:
|
case Protocol.operations.LDAP_REQ_DELETE:
|
||||||
Message = DeleteRequest
|
Message = DeleteRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_DELETE:
|
case Protocol.operations.LDAP_RES_DELETE:
|
||||||
Message = DeleteResponse
|
Message = DeleteResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_EXTENSION:
|
case Protocol.operations.LDAP_REQ_EXTENSION:
|
||||||
Message = ExtendedRequest
|
Message = ExtendedRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_EXTENSION:
|
case Protocol.operations.LDAP_RES_EXTENSION:
|
||||||
Message = ExtendedResponse
|
Message = ExtendedResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_MODIFY:
|
case Protocol.operations.LDAP_REQ_MODIFY:
|
||||||
Message = ModifyRequest
|
Message = ModifyRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_MODIFY:
|
case Protocol.operations.LDAP_RES_MODIFY:
|
||||||
Message = ModifyResponse
|
Message = ModifyResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_MODRDN:
|
case Protocol.operations.LDAP_REQ_MODRDN:
|
||||||
Message = ModifyDNRequest
|
Message = ModifyDNRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_MODRDN:
|
case Protocol.operations.LDAP_RES_MODRDN:
|
||||||
Message = ModifyDNResponse
|
Message = ModifyDNResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_SEARCH:
|
case Protocol.operations.LDAP_REQ_SEARCH:
|
||||||
Message = SearchRequest
|
Message = SearchRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_SEARCH_ENTRY:
|
case Protocol.operations.LDAP_RES_SEARCH_ENTRY:
|
||||||
Message = SearchEntry
|
Message = SearchEntry
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_SEARCH_REF:
|
case Protocol.operations.LDAP_RES_SEARCH_REF:
|
||||||
Message = SearchReference
|
Message = SearchReference
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REP_SEARCH:
|
case Protocol.operations.LDAP_RES_SEARCH:
|
||||||
Message = SearchResponse
|
Message = SearchResponse
|
||||||
break
|
break
|
||||||
|
|
||||||
case Protocol.LDAP_REQ_UNBIND:
|
case Protocol.operations.LDAP_REQ_UNBIND:
|
||||||
Message = UnbindRequest
|
Message = UnbindRequest
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ Parser.prototype.getMessage = function (ber) {
|
||||||
' not supported'),
|
' not supported'),
|
||||||
new LDAPResult({
|
new LDAPResult({
|
||||||
messageID: messageID,
|
messageID: messageID,
|
||||||
protocolOp: type || Protocol.LDAP_REP_EXTENSION
|
protocolOp: type || Protocol.operations.LDAP_RES_EXTENSION
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -7,7 +7,7 @@ const util = require('util')
|
||||||
|
|
||||||
const dtrace = require('../dtrace')
|
const dtrace = require('../dtrace')
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ LDAPResult.prototype._parse = function (ber) {
|
||||||
|
|
||||||
const t = ber.peek()
|
const t = ber.peek()
|
||||||
|
|
||||||
if (t === Protocol.LDAP_REP_REFERRAL) {
|
if (t === Protocol.operations.LDAP_RES_REFERRAL) {
|
||||||
const end = ber.offset + ber.length
|
const end = ber.offset + ber.length
|
||||||
while (ber.offset < end) { this.referrals.push(ber.readString()) }
|
while (ber.offset < end) { this.referrals.push(ber.readString()) }
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ LDAPResult.prototype._toBer = function (ber) {
|
||||||
ber.writeString(this.errorMessage || '')
|
ber.writeString(this.errorMessage || '')
|
||||||
|
|
||||||
if (this.referrals.length) {
|
if (this.referrals.length) {
|
||||||
ber.startSequence(Protocol.LDAP_REP_REFERRAL)
|
ber.startSequence(Protocol.operations.LDAP_RES_REFERRAL)
|
||||||
ber.writeStringArray(this.referrals)
|
ber.writeStringArray(this.referrals)
|
||||||
ber.endSequence()
|
ber.endSequence()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Attribute = require('../attribute')
|
const Attribute = require('../attribute')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const lassert = require('../assert')
|
const lassert = require('../assert')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
@ -21,7 +21,7 @@ function SearchEntry (options) {
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
lassert.optionalStringDN(options.objectName)
|
lassert.optionalStringDN(options.objectName)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_SEARCH_ENTRY
|
options.protocolOp = Protocol.operations.LDAP_RES_SEARCH_ENTRY
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.objectName = options.objectName || null
|
this.objectName = options.objectName || null
|
||||||
|
|
|
@ -6,7 +6,7 @@ const util = require('util')
|
||||||
// var asn1 = require('@ldapjs/asn1')
|
// var asn1 = require('@ldapjs/asn1')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
const dn = require('../dn')
|
const dn = require('../dn')
|
||||||
const url = require('../url')
|
const url = require('../url')
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function SearchReference (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_SEARCH_REF
|
options.protocolOp = Protocol.operations.LDAP_RES_SEARCH_REF
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
this.uris = options.uris || []
|
this.uris = options.uris || []
|
||||||
|
|
|
@ -9,7 +9,7 @@ const LDAPMessage = require('./message')
|
||||||
// var LDAPResult = require('./result')
|
// var LDAPResult = require('./result')
|
||||||
const dn = require('../dn')
|
const dn = require('../dn')
|
||||||
const filters = require('../filters')
|
const filters = require('../filters')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function SearchRequest (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_SEARCH
|
options.protocolOp = Protocol.operations.LDAP_REQ_SEARCH
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
|
|
||||||
if (options.baseObject !== undefined) {
|
if (options.baseObject !== undefined) {
|
||||||
|
@ -30,7 +30,7 @@ function SearchRequest (options) {
|
||||||
this.baseObject = dn.parse('')
|
this.baseObject = dn.parse('')
|
||||||
}
|
}
|
||||||
this.scope = options.scope || 'base'
|
this.scope = options.scope || 'base'
|
||||||
this.derefAliases = options.derefAliases || Protocol.NEVER_DEREF_ALIASES
|
this.derefAliases = options.derefAliases || Protocol.search.NEVER_DEREF_ALIASES
|
||||||
this.sizeLimit = options.sizeLimit || 0
|
this.sizeLimit = options.sizeLimit || 0
|
||||||
this.timeLimit = options.timeLimit || 0
|
this.timeLimit = options.timeLimit || 0
|
||||||
this.typesOnly = options.typesOnly || false
|
this.typesOnly = options.typesOnly || false
|
||||||
|
@ -50,9 +50,9 @@ Object.defineProperties(SearchRequest.prototype, {
|
||||||
scope: {
|
scope: {
|
||||||
get: function getScope () {
|
get: function getScope () {
|
||||||
switch (this._scope) {
|
switch (this._scope) {
|
||||||
case Protocol.SCOPE_BASE_OBJECT: return 'base'
|
case Protocol.search.SCOPE_BASE_OBJECT: return 'base'
|
||||||
case Protocol.SCOPE_ONE_LEVEL: return 'one'
|
case Protocol.search.SCOPE_ONE_LEVEL: return 'one'
|
||||||
case Protocol.SCOPE_SUBTREE: return 'sub'
|
case Protocol.search.SCOPE_SUBTREE: return 'sub'
|
||||||
default:
|
default:
|
||||||
throw new Error(this._scope + ' is an invalid search scope')
|
throw new Error(this._scope + ' is an invalid search scope')
|
||||||
}
|
}
|
||||||
|
@ -61,13 +61,13 @@ Object.defineProperties(SearchRequest.prototype, {
|
||||||
if (typeof (val) === 'string') {
|
if (typeof (val) === 'string') {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 'base':
|
case 'base':
|
||||||
this._scope = Protocol.SCOPE_BASE_OBJECT
|
this._scope = Protocol.search.SCOPE_BASE_OBJECT
|
||||||
break
|
break
|
||||||
case 'one':
|
case 'one':
|
||||||
this._scope = Protocol.SCOPE_ONE_LEVEL
|
this._scope = Protocol.search.SCOPE_ONE_LEVEL
|
||||||
break
|
break
|
||||||
case 'sub':
|
case 'sub':
|
||||||
this._scope = Protocol.SCOPE_SUBTREE
|
this._scope = Protocol.search.SCOPE_SUBTREE
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new Error(val + ' is an invalid search scope')
|
throw new Error(val + ' is an invalid search scope')
|
||||||
|
|
|
@ -10,7 +10,7 @@ const SearchReference = require('./search_reference')
|
||||||
const dtrace = require('../dtrace')
|
const dtrace = require('../dtrace')
|
||||||
const parseDN = require('../dn').parse
|
const parseDN = require('../dn').parse
|
||||||
const parseURL = require('../url').parse
|
const parseURL = require('../url').parse
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ function SearchResponse (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REP_SEARCH
|
options.protocolOp = Protocol.operations.LDAP_RES_SEARCH
|
||||||
LDAPResult.call(this, options)
|
LDAPResult.call(this, options)
|
||||||
|
|
||||||
this.attributes = options.attributes ? options.attributes.slice() : []
|
this.attributes = options.attributes ? options.attributes.slice() : []
|
||||||
|
|
|
@ -5,7 +5,7 @@ const util = require('util')
|
||||||
|
|
||||||
const LDAPMessage = require('./message')
|
const LDAPMessage = require('./message')
|
||||||
const dn = require('../dn')
|
const dn = require('../dn')
|
||||||
const Protocol = require('../protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
/// --- Globals
|
/// --- Globals
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ function UnbindRequest (options) {
|
||||||
options = options || {}
|
options = options || {}
|
||||||
assert.object(options)
|
assert.object(options)
|
||||||
|
|
||||||
options.protocolOp = Protocol.LDAP_REQ_UNBIND
|
options.protocolOp = Protocol.operations.LDAP_REQ_UNBIND
|
||||||
LDAPMessage.call(this, options)
|
LDAPMessage.call(this, options)
|
||||||
}
|
}
|
||||||
util.inherits(UnbindRequest, LDAPMessage)
|
util.inherits(UnbindRequest, LDAPMessage)
|
||||||
|
|
|
@ -6,7 +6,6 @@ const util = require('util')
|
||||||
const dtrace = require('../dtrace')
|
const dtrace = require('../dtrace')
|
||||||
|
|
||||||
const LDAPMessage = require('./result')
|
const LDAPMessage = require('./result')
|
||||||
// var Protocol = require('../protocol')
|
|
||||||
|
|
||||||
/// --- API
|
/// --- API
|
||||||
// Ok, so there's really no such thing as an unbind 'response', but to make
|
// Ok, so there's really no such thing as an unbind 'response', but to make
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
// Misc
|
|
||||||
LDAP_VERSION_3: 0x03,
|
|
||||||
LBER_SET: 0x31,
|
|
||||||
LDAP_CONTROLS: 0xa0,
|
|
||||||
|
|
||||||
// Search
|
|
||||||
SCOPE_BASE_OBJECT: 0,
|
|
||||||
SCOPE_ONE_LEVEL: 1,
|
|
||||||
SCOPE_SUBTREE: 2,
|
|
||||||
|
|
||||||
NEVER_DEREF_ALIASES: 0,
|
|
||||||
DEREF_IN_SEARCHING: 1,
|
|
||||||
DEREF_BASE_OBJECT: 2,
|
|
||||||
DEREF_ALWAYS: 3,
|
|
||||||
|
|
||||||
FILTER_AND: 0xa0,
|
|
||||||
FILTER_OR: 0xa1,
|
|
||||||
FILTER_NOT: 0xa2,
|
|
||||||
FILTER_EQUALITY: 0xa3,
|
|
||||||
FILTER_SUBSTRINGS: 0xa4,
|
|
||||||
FILTER_GE: 0xa5,
|
|
||||||
FILTER_LE: 0xa6,
|
|
||||||
FILTER_PRESENT: 0x87,
|
|
||||||
FILTER_APPROX: 0xa8,
|
|
||||||
FILTER_EXT: 0xa9,
|
|
||||||
|
|
||||||
// Protocol Operations
|
|
||||||
LDAP_REQ_BIND: 0x60,
|
|
||||||
LDAP_REQ_UNBIND: 0x42,
|
|
||||||
LDAP_REQ_SEARCH: 0x63,
|
|
||||||
LDAP_REQ_MODIFY: 0x66,
|
|
||||||
LDAP_REQ_ADD: 0x68,
|
|
||||||
LDAP_REQ_DELETE: 0x4a,
|
|
||||||
LDAP_REQ_MODRDN: 0x6c,
|
|
||||||
LDAP_REQ_COMPARE: 0x6e,
|
|
||||||
LDAP_REQ_ABANDON: 0x50,
|
|
||||||
LDAP_REQ_EXTENSION: 0x77,
|
|
||||||
|
|
||||||
LDAP_REP_BIND: 0x61,
|
|
||||||
LDAP_REP_SEARCH_ENTRY: 0x64,
|
|
||||||
LDAP_REP_SEARCH_REF: 0x73,
|
|
||||||
LDAP_REP_SEARCH: 0x65,
|
|
||||||
LDAP_REP_MODIFY: 0x67,
|
|
||||||
LDAP_REP_ADD: 0x69,
|
|
||||||
LDAP_REP_DELETE: 0x6b,
|
|
||||||
LDAP_REP_MODRDN: 0x6d,
|
|
||||||
LDAP_REP_COMPARE: 0x6f,
|
|
||||||
LDAP_REP_EXTENSION: 0x78
|
|
||||||
}
|
|
|
@ -12,7 +12,7 @@ const VError = require('verror').VError
|
||||||
const dn = require('./dn')
|
const dn = require('./dn')
|
||||||
const dtrace = require('./dtrace')
|
const dtrace = require('./dtrace')
|
||||||
const errors = require('./errors')
|
const errors = require('./errors')
|
||||||
const Protocol = require('./protocol')
|
const Protocol = require('@ldapjs/protocol')
|
||||||
|
|
||||||
const Parser = require('./messages').Parser
|
const Parser = require('./messages').Parser
|
||||||
const AbandonResponse = require('./messages/abandon_response')
|
const AbandonResponse = require('./messages/abandon_response')
|
||||||
|
@ -71,34 +71,34 @@ function getResponse (req) {
|
||||||
let Response
|
let Response
|
||||||
|
|
||||||
switch (req.protocolOp) {
|
switch (req.protocolOp) {
|
||||||
case Protocol.LDAP_REQ_BIND:
|
case Protocol.operations.LDAP_REQ_BIND:
|
||||||
Response = BindResponse
|
Response = BindResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_ABANDON:
|
case Protocol.operations.LDAP_REQ_ABANDON:
|
||||||
Response = AbandonResponse
|
Response = AbandonResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_ADD:
|
case Protocol.operations.LDAP_REQ_ADD:
|
||||||
Response = AddResponse
|
Response = AddResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_COMPARE:
|
case Protocol.operations.LDAP_REQ_COMPARE:
|
||||||
Response = CompareResponse
|
Response = CompareResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_DELETE:
|
case Protocol.operations.LDAP_REQ_DELETE:
|
||||||
Response = DeleteResponse
|
Response = DeleteResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_EXTENSION:
|
case Protocol.operations.LDAP_REQ_EXTENSION:
|
||||||
Response = ExtendedResponse
|
Response = ExtendedResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_MODIFY:
|
case Protocol.operations.LDAP_REQ_MODIFY:
|
||||||
Response = ModifyResponse
|
Response = ModifyResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_MODRDN:
|
case Protocol.operations.LDAP_REQ_MODRDN:
|
||||||
Response = ModifyDNResponse
|
Response = ModifyDNResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_SEARCH:
|
case Protocol.operations.LDAP_REQ_SEARCH:
|
||||||
Response = SearchResponse
|
Response = SearchResponse
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_UNBIND:
|
case Protocol.operations.LDAP_REQ_UNBIND:
|
||||||
Response = UnbindResponse
|
Response = UnbindResponse
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -170,44 +170,44 @@ function fireDTraceProbe (req, res) {
|
||||||
|
|
||||||
let op
|
let op
|
||||||
switch (req.protocolOp) {
|
switch (req.protocolOp) {
|
||||||
case Protocol.LDAP_REQ_ABANDON:
|
case Protocol.operations.LDAP_REQ_ABANDON:
|
||||||
op = 'abandon'
|
op = 'abandon'
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_ADD:
|
case Protocol.operations.LDAP_REQ_ADD:
|
||||||
op = 'add'
|
op = 'add'
|
||||||
probeArgs.push(req.attributes.length)
|
probeArgs.push(req.attributes.length)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_BIND:
|
case Protocol.operations.LDAP_REQ_BIND:
|
||||||
op = 'bind'
|
op = 'bind'
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_COMPARE:
|
case Protocol.operations.LDAP_REQ_COMPARE:
|
||||||
op = 'compare'
|
op = 'compare'
|
||||||
probeArgs.push(req.attribute)
|
probeArgs.push(req.attribute)
|
||||||
probeArgs.push(req.value)
|
probeArgs.push(req.value)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_DELETE:
|
case Protocol.operations.LDAP_REQ_DELETE:
|
||||||
op = 'delete'
|
op = 'delete'
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_EXTENSION:
|
case Protocol.operations.LDAP_REQ_EXTENSION:
|
||||||
op = 'exop'
|
op = 'exop'
|
||||||
probeArgs.push(req.name)
|
probeArgs.push(req.name)
|
||||||
probeArgs.push(req.value)
|
probeArgs.push(req.value)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_MODIFY:
|
case Protocol.operations.LDAP_REQ_MODIFY:
|
||||||
op = 'modify'
|
op = 'modify'
|
||||||
probeArgs.push(req.changes.length)
|
probeArgs.push(req.changes.length)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_MODRDN:
|
case Protocol.operations.LDAP_REQ_MODRDN:
|
||||||
op = 'modifydn'
|
op = 'modifydn'
|
||||||
probeArgs.push(req.newRdn.toString())
|
probeArgs.push(req.newRdn.toString())
|
||||||
probeArgs.push((req.newSuperior ? req.newSuperior.toString() : ''))
|
probeArgs.push((req.newSuperior ? req.newSuperior.toString() : ''))
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_SEARCH:
|
case Protocol.operations.LDAP_REQ_SEARCH:
|
||||||
op = 'search'
|
op = 'search'
|
||||||
probeArgs.push(req.scope)
|
probeArgs.push(req.scope)
|
||||||
probeArgs.push(req.filter.toString())
|
probeArgs.push(req.filter.toString())
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_UNBIND:
|
case Protocol.operations.LDAP_REQ_UNBIND:
|
||||||
op = 'unbind'
|
op = 'unbind'
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -343,22 +343,22 @@ function Server (options) {
|
||||||
// parse string DNs for routing/etc
|
// parse string DNs for routing/etc
|
||||||
try {
|
try {
|
||||||
switch (req.protocolOp) {
|
switch (req.protocolOp) {
|
||||||
case Protocol.LDAP_REQ_BIND:
|
case Protocol.operations.LDAP_REQ_BIND:
|
||||||
req.name = dn.parse(req.name)
|
req.name = dn.parse(req.name)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_ADD:
|
case Protocol.operations.LDAP_REQ_ADD:
|
||||||
case Protocol.LDAP_REQ_COMPARE:
|
case Protocol.operations.LDAP_REQ_COMPARE:
|
||||||
case Protocol.LDAP_REQ_DELETE:
|
case Protocol.operations.LDAP_REQ_DELETE:
|
||||||
req.entry = dn.parse(req.entry)
|
req.entry = dn.parse(req.entry)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_MODIFY:
|
case Protocol.operations.LDAP_REQ_MODIFY:
|
||||||
req.object = dn.parse(req.object)
|
req.object = dn.parse(req.object)
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_MODRDN:
|
case Protocol.operations.LDAP_REQ_MODRDN:
|
||||||
req.entry = dn.parse(req.entry)
|
req.entry = dn.parse(req.entry)
|
||||||
// TODO: handle newRdn/Superior
|
// TODO: handle newRdn/Superior
|
||||||
break
|
break
|
||||||
case Protocol.LDAP_REQ_SEARCH:
|
case Protocol.operations.LDAP_REQ_SEARCH:
|
||||||
req.baseObject = dn.parse(req.baseObject)
|
req.baseObject = dn.parse(req.baseObject)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -406,7 +406,7 @@ function Server (options) {
|
||||||
const next = messageIIFE
|
const next = messageIIFE
|
||||||
if (chain.handlers[i]) { return chain.handlers[i++].call(chain.backend, req, res, next) }
|
if (chain.handlers[i]) { return chain.handlers[i++].call(chain.backend, req, res, next) }
|
||||||
|
|
||||||
if (req.protocolOp === Protocol.LDAP_REQ_BIND && res.status === 0) {
|
if (req.protocolOp === Protocol.operations.LDAP_REQ_BIND && res.status === 0) {
|
||||||
// 0 length == anonymous bind
|
// 0 length == anonymous bind
|
||||||
if (req.dn.length === 0 && req.credentials === '') {
|
if (req.dn.length === 0 && req.credentials === '') {
|
||||||
conn.ldap.bindDN = new DN([new dn.RDN({ cn: 'anonymous' })])
|
conn.ldap.bindDN = new DN([new dn.RDN({ cn: 'anonymous' })])
|
||||||
|
@ -417,7 +417,7 @@ function Server (options) {
|
||||||
|
|
||||||
// unbind clear bindDN for safety
|
// unbind clear bindDN for safety
|
||||||
// conn should terminate on unbind (RFC4511 4.3)
|
// conn should terminate on unbind (RFC4511 4.3)
|
||||||
if (req.protocolOp === Protocol.LDAP_REQ_UNBIND && res.status === 0) {
|
if (req.protocolOp === Protocol.operations.LDAP_REQ_UNBIND && res.status === 0) {
|
||||||
conn.ldap.bindDN = new DN([new dn.RDN({ cn: 'anonymous' })])
|
conn.ldap.bindDN = new DN([new dn.RDN({ cn: 'anonymous' })])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ module.exports = Server
|
||||||
*/
|
*/
|
||||||
Server.prototype.add = function (name) {
|
Server.prototype.add = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_ADD, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_ADD, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -551,7 +551,7 @@ Server.prototype.add = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.bind = function (name) {
|
Server.prototype.bind = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_BIND, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_BIND, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -566,7 +566,7 @@ Server.prototype.bind = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.compare = function (name) {
|
Server.prototype.compare = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_COMPARE, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_COMPARE, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,7 +581,7 @@ Server.prototype.compare = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.del = function (name) {
|
Server.prototype.del = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_DELETE, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_DELETE, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -596,7 +596,7 @@ Server.prototype.del = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.exop = function (name) {
|
Server.prototype.exop = function (name) {
|
||||||
const 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)
|
return this._mount(Protocol.operations.LDAP_REQ_EXTENSION, name, args, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -611,7 +611,7 @@ Server.prototype.exop = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.modify = function (name) {
|
Server.prototype.modify = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_MODIFY, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_MODIFY, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -626,7 +626,7 @@ Server.prototype.modify = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.modifyDN = function (name) {
|
Server.prototype.modifyDN = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_MODRDN, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_MODRDN, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -641,7 +641,7 @@ Server.prototype.modifyDN = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.search = function (name) {
|
Server.prototype.search = function (name) {
|
||||||
const args = Array.prototype.slice.call(arguments, 1)
|
const args = Array.prototype.slice.call(arguments, 1)
|
||||||
return this._mount(Protocol.LDAP_REQ_SEARCH, name, args)
|
return this._mount(Protocol.operations.LDAP_REQ_SEARCH, name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -655,7 +655,7 @@ Server.prototype.search = function (name) {
|
||||||
*/
|
*/
|
||||||
Server.prototype.unbind = function () {
|
Server.prototype.unbind = function () {
|
||||||
const 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)
|
return this._mount(Protocol.operations.LDAP_REQ_UNBIND, 'unbind', args, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
Server.prototype.use = function use () {
|
Server.prototype.use = function use () {
|
||||||
|
@ -787,7 +787,7 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
||||||
let route
|
let route
|
||||||
|
|
||||||
// check anonymous bind
|
// check anonymous bind
|
||||||
if (req.protocolOp === Protocol.LDAP_REQ_BIND &&
|
if (req.protocolOp === Protocol.operations.LDAP_REQ_BIND &&
|
||||||
req.dn.toString() === '' &&
|
req.dn.toString() === '' &&
|
||||||
req.credentials === '') {
|
req.credentials === '') {
|
||||||
return {
|
return {
|
||||||
|
@ -799,7 +799,7 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
||||||
const op = '0x' + req.protocolOp.toString(16)
|
const op = '0x' + req.protocolOp.toString(16)
|
||||||
|
|
||||||
// Special cases are exops, unbinds and abandons. Handle those first.
|
// Special cases are exops, unbinds and abandons. Handle those first.
|
||||||
if (req.protocolOp === Protocol.LDAP_REQ_EXTENSION) {
|
if (req.protocolOp === Protocol.operations.LDAP_REQ_EXTENSION) {
|
||||||
route = routes[req.requestName]
|
route = routes[req.requestName]
|
||||||
if (route) {
|
if (route) {
|
||||||
return {
|
return {
|
||||||
|
@ -812,7 +812,7 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
||||||
handlers: [noExOpHandler]
|
handlers: [noExOpHandler]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (req.protocolOp === Protocol.LDAP_REQ_UNBIND) {
|
} else if (req.protocolOp === Protocol.operations.LDAP_REQ_UNBIND) {
|
||||||
route = routes.unbind
|
route = routes.unbind
|
||||||
if (route) {
|
if (route) {
|
||||||
return {
|
return {
|
||||||
|
@ -825,7 +825,7 @@ Server.prototype._getHandlerChain = function _getHandlerChain (req, res) {
|
||||||
handlers: [defaultNoOpHandler]
|
handlers: [defaultNoOpHandler]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (req.protocolOp === Protocol.LDAP_REQ_ABANDON) {
|
} else if (req.protocolOp === Protocol.operations.LDAP_REQ_ABANDON) {
|
||||||
return {
|
return {
|
||||||
backend: self,
|
backend: self,
|
||||||
handlers: [defaultNoOpHandler]
|
handlers: [defaultNoOpHandler]
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ldapjs/asn1": "^1.0.0",
|
"@ldapjs/asn1": "^1.0.0",
|
||||||
"@ldapjs/controls": "^1.0.0",
|
"@ldapjs/controls": "^1.0.0",
|
||||||
|
"@ldapjs/protocol": "^1.0.0",
|
||||||
"abstract-logging": "^2.0.0",
|
"abstract-logging": "^2.0.0",
|
||||||
"assert-plus": "^1.0.0",
|
"assert-plus": "^1.0.0",
|
||||||
"backoff": "^2.5.0",
|
"backoff": "^2.5.0",
|
||||||
|
|
Loading…
Reference in New Issue