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.

ext_response.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2011 Mark Cavage, Inc. All rights reserved.
  2. var assert = require('assert-plus');
  3. var util = require('util');
  4. var LDAPResult = require('./result');
  5. var Protocol = require('../protocol');
  6. ///--- API
  7. function ExtendedResponse(options) {
  8. options = options || {};
  9. assert.object(options);
  10. assert.optionalString(options.responseName);
  11. assert.optionalString(options.responsevalue);
  12. this.responseName = options.responseName || undefined;
  13. this.responseValue = options.responseValue || undefined;
  14. options.protocolOp = Protocol.LDAP_REP_EXTENSION;
  15. LDAPResult.call(this, options);
  16. }
  17. util.inherits(ExtendedResponse, LDAPResult);
  18. Object.defineProperties(ExtendedResponse.prototype, {
  19. type: {
  20. get: function getType() { return 'ExtendedResponse'; },
  21. configurable: false
  22. },
  23. _dn: {
  24. get: function getDN() { return this.responseName; },
  25. configurable: false
  26. },
  27. name: {
  28. get: function getName() { return this.responseName; },
  29. set: function setName(val) {
  30. assert.string(val);
  31. this.responseName = val;
  32. },
  33. configurable: false
  34. },
  35. value: {
  36. get: function getValue() { return this.responseValue; },
  37. set: function (val) {
  38. assert.string(val);
  39. this.responseValue = val;
  40. },
  41. configurable: false
  42. }
  43. });
  44. ExtendedResponse.prototype._parse = function (ber) {
  45. assert.ok(ber);
  46. if (!LDAPResult.prototype._parse.call(this, ber))
  47. return false;
  48. if (ber.peek() === 0x8a)
  49. this.responseName = ber.readString(0x8a);
  50. if (ber.peek() === 0x8b)
  51. this.responseValue = ber.readString(0x8b);
  52. return true;
  53. };
  54. ExtendedResponse.prototype._toBer = function (ber) {
  55. assert.ok(ber);
  56. if (!LDAPResult.prototype._toBer.call(this, ber))
  57. return false;
  58. if (this.responseName)
  59. ber.writeString(this.responseName, 0x8a);
  60. if (this.responseValue)
  61. ber.writeString(this.responseValue, 0x8b);
  62. return ber;
  63. };
  64. ExtendedResponse.prototype._json = function (j) {
  65. assert.ok(j);
  66. j = LDAPResult.prototype._json.call(this, j);
  67. j.responseName = this.responseName;
  68. j.responseValue = this.responseValue;
  69. return j;
  70. };
  71. ///--- Exports
  72. module.exports = ExtendedResponse;