Skip to content

Commit

Permalink
Improve ppolicy documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Éloi Rivard authored and GitHub committed Dec 4, 2020
1 parent 4993d4a commit 7dfa21a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
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 @@ -209,3 +209,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

0 comments on commit 7dfa21a

Please sign in to comment.