2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
var assert = require('assert-plus')
|
|
|
|
var util = require('util')
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
var LDAPMessage = require('./message')
|
|
|
|
var Protocol = require('../protocol')
|
|
|
|
var lassert = require('../assert')
|
2014-09-30 23:39:19 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
/// --- API
|
2014-09-30 23:39:19 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
function CompareRequest (options) {
|
|
|
|
options = options || {}
|
|
|
|
assert.object(options)
|
|
|
|
assert.optionalString(options.attribute)
|
|
|
|
assert.optionalString(options.value)
|
|
|
|
lassert.optionalStringDN(options.entry)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
options.protocolOp = Protocol.LDAP_REQ_COMPARE
|
|
|
|
LDAPMessage.call(this, options)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
this.entry = options.entry || null
|
|
|
|
this.attribute = options.attribute || ''
|
|
|
|
this.value = options.value || ''
|
2011-08-04 20:32:01 +00:00
|
|
|
}
|
2019-08-27 21:11:49 +00:00
|
|
|
util.inherits(CompareRequest, LDAPMessage)
|
2015-10-31 17:28:25 +00:00
|
|
|
Object.defineProperties(CompareRequest.prototype, {
|
|
|
|
type: {
|
2019-08-27 21:11:49 +00:00
|
|
|
get: function getType () { return 'CompareRequest' },
|
2015-10-31 17:28:25 +00:00
|
|
|
configurable: false
|
|
|
|
},
|
|
|
|
_dn: {
|
2019-08-27 21:11:49 +00:00
|
|
|
get: function getDN () { return this.entry },
|
2015-10-31 17:28:25 +00:00
|
|
|
configurable: false
|
|
|
|
}
|
2019-08-27 21:11:49 +00:00
|
|
|
})
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
CompareRequest.prototype._parse = function (ber) {
|
2019-08-27 21:11:49 +00:00
|
|
|
assert.ok(ber)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
this.entry = ber.readString()
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
ber.readSequence()
|
|
|
|
this.attribute = ber.readString().toLowerCase()
|
|
|
|
this.value = ber.readString()
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
return true
|
|
|
|
}
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
CompareRequest.prototype._toBer = function (ber) {
|
2019-08-27 21:11:49 +00:00
|
|
|
assert.ok(ber)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
ber.writeString(this.entry.toString())
|
|
|
|
ber.startSequence()
|
|
|
|
ber.writeString(this.attribute)
|
|
|
|
ber.writeString(this.value)
|
|
|
|
ber.endSequence()
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
return ber
|
|
|
|
}
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
CompareRequest.prototype._json = function (j) {
|
2019-08-27 21:11:49 +00:00
|
|
|
assert.ok(j)
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
j.entry = this.entry.toString()
|
|
|
|
j.attribute = this.attribute
|
|
|
|
j.value = this.value
|
2015-10-31 17:28:25 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
return j
|
|
|
|
}
|
2015-10-31 17:28:25 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
/// --- Exports
|
2015-10-31 17:28:25 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
module.exports = CompareRequest
|