Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
]

try:
Expand Down
13 changes: 13 additions & 0 deletions Doc/reference/ldap-controls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,16 @@ search.

.. autoclass:: ldap.controls.readentry.PostReadControl
:members:


:py:mod:`ldap.controls.ppolicy` Password Policy Control
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. seealso::
`draft-behera-ldap-password-policy <https://tools.ietf.org/html/draft-behera-ldap-password-policy>`_

.. py:module:: ldap.controls.ppolicy
:synopsis: passworld policies

.. autoclass:: ldap.controls.ppolicy.PasswordPolicyControl
:members:
20 changes: 17 additions & 3 deletions Lib/ldap/controls/ppolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,31 @@ class PasswordPolicyResponseValue(univ.Sequence):


class PasswordPolicyControl(ValueLessRequestControl,ResponseControl):
"""
Indicates the errors and warnings about the password policy.

Attributes
----------

timeBeforeExpiration : int
The time before the password expires.

graceAuthNsRemaining : int
The number of grace authentications remaining.

error: int
The password and authentication errors.
"""
controlType = '1.3.6.1.4.1.42.2.27.8.5.1'

def __init__(self,criticality=False):
self.criticality = criticality

def decodeControlValue(self,encodedControlValue):
ppolicyValue,_ = decoder.decode(encodedControlValue,asn1Spec=PasswordPolicyResponseValue())
self.timeBeforeExpiration = None
self.graceAuthNsRemaining = None
self.error = None

def decodeControlValue(self,encodedControlValue):
ppolicyValue,_ = decoder.decode(encodedControlValue,asn1Spec=PasswordPolicyResponseValue())
warning = ppolicyValue.getComponentByName('warning')
if warning.hasValue():
if 'timeBeforeExpiration' in warning:
Expand Down