File: passwd.py

package info (click to toggle)
python-ldap 3.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,368 kB
  • sloc: python: 9,560; ansic: 3,052; makefile: 139; sh: 79
file content (32 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (3)
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
"""
ldap.extop.passwd - Classes for Password Modify extended operation
(see RFC 3062)

See https://www.python-ldap.org/ for details.
"""

from ldap.extop import ExtendedResponse

# Imports from pyasn1
from pyasn1.type import namedtype, univ, tag
from pyasn1.codec.der import decoder


class PasswordModifyResponse(ExtendedResponse):
    responseName = None

    class PasswordModifyResponseValue(univ.Sequence):
        componentType = namedtype.NamedTypes(
            namedtype.OptionalNamedType(
                'genPasswd',
                univ.OctetString().subtype(
                    implicitTag=tag.Tag(tag.tagClassContext,
                                        tag.tagFormatSimple, 0)
                )
            )
        )

    def decodeResponseValue(self, value):
        respValue, _ = decoder.decode(value, asn1Spec=self.PasswordModifyResponseValue())
        self.genPasswd = bytes(respValue.getComponentByName('genPasswd'))
        return self.genPasswd