getUserName(); $additionalAttrs = array(); $rdnAttr = extractRDNAttribute($userDn); $userName = null; if (($rdnAttr === 'uid') || ($rdnAttr === 'uid')) { $userName = extractRDNValue($userDn); } $pwdPolicyResult = checkPasswordStrength($password1, $userName, $additionalAttrs); if ($pwdPolicyResult !== true) { $message = new htmlStatusMessage('ERROR', $pwdPolicyResult); printContent($message); exit(); } // set new password $modifyResult = @ldap_exop_passwd($_SESSION['ldap']->server(), $userDn, $_SESSION['ldap']->getPassword(), $password1); if ($modifyResult === true) { $_SESSION['ldap']->encrypt_login($userDn, $password1); $message = new htmlStatusMessage('INFO', _('Password changed.')); printContent($message, false); exit(); } else { $message = new htmlStatusMessage('ERROR', _('Unable to set password'), getExtendedLDAPErrorMessage($_SESSION['ldap']->server())); printContent($message); exit(); } } printContent($message); /** * Displays the content area * * @param htmlStatusMessage $message status message * @param bool $showPasswordInputs show password input fields */ function printContent($message = null, $showPasswordInputs = true) { include __DIR__ . '/../lib/adminHeader.inc'; echo '
'; echo "
\n"; $container = new htmlResponsiveRow(); if ($message !== null) { $container->addVerticalSpacer('1rem'); $container->add($message, 12); } $container->addVerticalSpacer('2rem'); if ($showPasswordInputs) { $container->add(new htmlOutputText(_("It seems your password expired. You can set a new one here.")), 12, 12, 12, 'text-center'); $container->addVerticalSpacer('2rem'); $pwdInput1 = new htmlResponsiveInputField(_('New password'), 'password1', ''); $pwdInput1->setIsPassword(true, true, true); $container->add($pwdInput1, 12); $pwdInput2 = new htmlResponsiveInputField(_('Repeat password'), 'password2', ''); $pwdInput2->setIsPassword(true); $pwdInput2->setSameValueFieldID('password1'); $container->add($pwdInput2, 12); $container->addVerticalSpacer('1rem'); $container->add(new htmlButton('changePassword', _("Submit")), 12, 12, 12, 'text-center'); addSecurityTokenToMetaHTML($container); } $tabindex = 1; parseHtml(null, $container, array(), false, $tabindex, 'user'); echo "

\n"; echo "
\n"; include __DIR__ . '/../lib/adminFooter.inc'; }