Development of an internal social media platform with personalised dashboards for students
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.

pwdpolicy.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. """
  3. ldap.controls.pwdpolicy - classes for Password Policy controls
  4. (see https://tools.ietf.org/html/draft-vchu-ldap-pwd-policy)
  5. See https://www.python-ldap.org/ for project details.
  6. """
  7. __all__ = [
  8. 'PasswordExpiringControl',
  9. 'PasswordExpiredControl',
  10. ]
  11. # Imports from python-ldap 2.4+
  12. import ldap.controls
  13. from ldap.controls import RequestControl,ResponseControl,ValueLessRequestControl,KNOWN_RESPONSE_CONTROLS
  14. class PasswordExpiringControl(ResponseControl):
  15. """
  16. Indicates time in seconds when password will expire
  17. """
  18. controlType = '2.16.840.1.113730.3.4.5'
  19. def decodeControlValue(self,encodedControlValue):
  20. self.gracePeriod = int(encodedControlValue)
  21. KNOWN_RESPONSE_CONTROLS[PasswordExpiringControl.controlType] = PasswordExpiringControl
  22. class PasswordExpiredControl(ResponseControl):
  23. """
  24. Indicates that password is expired
  25. """
  26. controlType = '2.16.840.1.113730.3.4.4'
  27. def decodeControlValue(self,encodedControlValue):
  28. self.passwordExpired = encodedControlValue=='0'
  29. KNOWN_RESPONSE_CONTROLS[PasswordExpiredControl.controlType] = PasswordExpiredControl