wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict'
 
const { BerReader } = require('@ldapjs/asn1')
const ExtensionResponse = require('../extension-response')
 
/**
 * Implements the password modify extension defined by
 * https://www.rfc-editor.org/rfc/rfc3062.
 */
class PasswordModifyResponse extends ExtensionResponse {
  /**
   * Given a basic {@link ExtensionResponse} with a buffer string in
   * `responseValue`, parse into a specific {@link PasswordModifyResponse}
   * instance.
   *
   * @param {ExtensionResponse} response
   *
   * @returns {PasswordModifyResponse}
   */
  static fromResponse (response) {
    if (response.responseValue === undefined) {
      return new PasswordModifyResponse()
    }
 
    const valueBuffer = Buffer.from(response.responseValue.substring(8), 'hex')
    const reader = new BerReader(valueBuffer)
    reader.readSequence()
    const responseValue = reader.readString(0x80)
    return new PasswordModifyResponse({ responseValue })
  }
}
 
module.exports = PasswordModifyResponse