node-ldapjs/lib/messages/del_request.js

63 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-08-04 20:32:01 +00:00
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
2020-10-31 21:07:32 +00:00
const assert = require('assert-plus')
const util = require('util')
2011-08-04 20:32:01 +00:00
2020-10-31 21:07:32 +00:00
const LDAPMessage = require('./message')
const Protocol = require('../protocol')
const lassert = require('../assert')
2011-08-04 20:32:01 +00:00
/// --- API
2011-08-04 20:32:01 +00:00
function DeleteRequest (options) {
options = options || {}
assert.object(options)
lassert.optionalStringDN(options.entry)
2011-08-04 20:32:01 +00:00
options.protocolOp = Protocol.LDAP_REQ_DELETE
LDAPMessage.call(this, options)
2011-08-04 20:32:01 +00:00
this.entry = options.entry || null
2011-08-04 20:32:01 +00:00
}
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
}
})
2011-08-04 20:32:01 +00:00
DeleteRequest.prototype._parse = function (ber, length) {
assert.ok(ber)
2011-08-04 20:32:01 +00:00
this.entry = ber.buffer.slice(0, length).toString('utf8')
ber._offset += ber.length
2011-08-04 20:32:01 +00:00
return true
}
2011-08-04 20:32:01 +00:00
DeleteRequest.prototype._toBer = function (ber) {
assert.ok(ber)
2011-08-04 20:32:01 +00:00
2020-10-31 21:07:32 +00:00
const buf = Buffer.from(this.entry.toString())
for (let i = 0; i < buf.length; i++) { ber.writeByte(buf[i]) }
2011-08-04 20:32:01 +00:00
return ber
}
2011-08-04 20:32:01 +00:00
DeleteRequest.prototype._json = function (j) {
assert.ok(j)
2011-08-04 20:32:01 +00:00
j.entry = this.entry
return j
}
/// --- Exports
module.exports = DeleteRequest