Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compare_request.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2011 Mark Cavage, Inc. All rights reserved.
  2. var assert = require('assert-plus');
  3. var util = require('util');
  4. var LDAPMessage = require('./message');
  5. var Protocol = require('../protocol');
  6. var lassert = require('../assert');
  7. ///--- API
  8. function CompareRequest(options) {
  9. options = options || {};
  10. assert.object(options);
  11. assert.optionalString(options.attribute);
  12. assert.optionalString(options.value);
  13. lassert.optionalStringDN(options.entry);
  14. options.protocolOp = Protocol.LDAP_REQ_COMPARE;
  15. LDAPMessage.call(this, options);
  16. this.entry = options.entry || null;
  17. this.attribute = options.attribute || '';
  18. this.value = options.value || '';
  19. }
  20. util.inherits(CompareRequest, LDAPMessage);
  21. Object.defineProperties(CompareRequest.prototype, {
  22. type: {
  23. get: function getType() { return 'CompareRequest'; },
  24. configurable: false
  25. },
  26. _dn: {
  27. get: function getDN() { return this.entry; },
  28. configurable: false
  29. }
  30. });
  31. CompareRequest.prototype._parse = function (ber) {
  32. assert.ok(ber);
  33. this.entry = ber.readString();
  34. ber.readSequence();
  35. this.attribute = ber.readString().toLowerCase();
  36. this.value = ber.readString();
  37. return true;
  38. };
  39. CompareRequest.prototype._toBer = function (ber) {
  40. assert.ok(ber);
  41. ber.writeString(this.entry.toString());
  42. ber.startSequence();
  43. ber.writeString(this.attribute);
  44. ber.writeString(this.value);
  45. ber.endSequence();
  46. return ber;
  47. };
  48. CompareRequest.prototype._json = function (j) {
  49. assert.ok(j);
  50. j.entry = this.entry.toString();
  51. j.attribute = this.attribute;
  52. j.value = this.value;
  53. return j;
  54. };
  55. ///--- Exports
  56. module.exports = CompareRequest;