63 lines
1.3 KiB
JavaScript
63 lines
1.3 KiB
JavaScript
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
var assert = require('assert-plus')
|
|
var util = require('util')
|
|
|
|
var LDAPMessage = require('./message')
|
|
var Protocol = require('../protocol')
|
|
var lassert = require('../assert')
|
|
|
|
/// --- API
|
|
|
|
function DeleteRequest (options) {
|
|
options = options || {}
|
|
assert.object(options)
|
|
lassert.optionalStringDN(options.entry)
|
|
|
|
options.protocolOp = Protocol.LDAP_REQ_DELETE
|
|
LDAPMessage.call(this, options)
|
|
|
|
this.entry = options.entry || null
|
|
}
|
|
util.inherits(DeleteRequest, LDAPMessage)
|
|
Object.defineProperties(DeleteRequest.prototype, {
|
|
type: {
|
|
get: function getType () { return 'DeleteRequest' },
|
|
configurable: false
|
|
},
|
|
_dn: {
|
|
get: function getDN () { return this.entry },
|
|
configurable: false
|
|
}
|
|
})
|
|
|
|
DeleteRequest.prototype._parse = function (ber, length) {
|
|
assert.ok(ber)
|
|
|
|
this.entry = ber.buffer.slice(0, length).toString('utf8')
|
|
ber._offset += ber.length
|
|
|
|
return true
|
|
}
|
|
|
|
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]) }
|
|
|
|
return ber
|
|
}
|
|
|
|
DeleteRequest.prototype._json = function (j) {
|
|
assert.ok(j)
|
|
|
|
j.entry = this.entry
|
|
|
|
return j
|
|
}
|
|
|
|
/// --- Exports
|
|
|
|
module.exports = DeleteRequest
|