pam.py (nss-pam-ldapd-0.9.11) | : | pam.py (nss-pam-ldapd-0.9.12) | ||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
import passwd | import passwd | |||
import search | import search | |||
import shadow | import shadow | |||
random = random.SystemRandom() | random = random.SystemRandom() | |||
def authenticate(binddn, password): | def authenticate(binddn, password): | |||
# open a new connection | # open a new connection | |||
conn = search.Connection() | conn = search.Connection() | |||
# bind using the specified credentials | # bind using the specified credentials | |||
pwctrl = PasswordPolicyControl() | serverctrls = [] | |||
res, data, msgid, ctrls = conn.simple_bind_s(binddn, password, serverctrls=[ | if cfg.pam_authc_ppolicy: | |||
pwctrl]) | serverctrls.append(PasswordPolicyControl()) | |||
res, data, msgid, ctrls = conn.simple_bind_s(binddn, password, serverctrls=s | ||||
erverctrls) | ||||
# go over bind result server controls | # go over bind result server controls | |||
for ctrl in ctrls: | for ctrl in ctrls: | |||
if ctrl.controlType == PasswordPolicyControl.controlType: | if ctrl.controlType == PasswordPolicyControl.controlType: | |||
# found a password policy control | # found a password policy control | |||
logging.debug( | logging.debug( | |||
'PasswordPolicyControl found: error=%s (%s), ' | 'PasswordPolicyControl found: error=%s (%s), ' | |||
'timeBeforeExpiration=%s, graceAuthNsRemaining=%s', | 'timeBeforeExpiration=%s, graceAuthNsRemaining=%s', | |||
'None' if ctrl.error is None else PasswordPolicyError(ctrl.error ).prettyPrint(), | 'None' if ctrl.error is None else PasswordPolicyError(ctrl.error ).prettyPrint(), | |||
ctrl.error, ctrl.timeBeforeExpiration, ctrl.graceAuthNsRemaining ) | ctrl.error, ctrl.timeBeforeExpiration, ctrl.graceAuthNsRemaining ) | |||
if ctrl.error == 0: # passwordExpired | if ctrl.error == 0: # passwordExpired | |||
End of changes. 1 change blocks. | ||||
3 lines changed or deleted | 5 lines changed or added |