ldap
This commit is contained in:
@@ -16,6 +16,7 @@ $serviceResult = $ldap->testServiceBind();
|
|||||||
$messages = [];
|
$messages = [];
|
||||||
$errors = [];
|
$errors = [];
|
||||||
$form = ['username' => '', 'password' => '', 'new_password' => ''];
|
$form = ['username' => '', 'password' => '', 'new_password' => ''];
|
||||||
|
$attempt = null;
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$action = (string) ($_POST['action'] ?? '');
|
$action = (string) ($_POST['action'] ?? '');
|
||||||
@@ -37,6 +38,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
|
|
||||||
if ($errors === []) {
|
if ($errors === []) {
|
||||||
if ($action === 'test-login') {
|
if ($action === 'test-login') {
|
||||||
|
$attempt = [
|
||||||
|
'action' => 'Login-Test',
|
||||||
|
'username' => $form['username'],
|
||||||
|
];
|
||||||
$result = $ldap->testUserCredentials($form['username'], $form['password']);
|
$result = $ldap->testUserCredentials($form['username'], $form['password']);
|
||||||
|
|
||||||
if ($result['success'] ?? false) {
|
if ($result['success'] ?? false) {
|
||||||
@@ -45,6 +50,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$errors[] = (string) ($result['message'] ?? 'LDAP-Login fehlgeschlagen.');
|
$errors[] = (string) ($result['message'] ?? 'LDAP-Login fehlgeschlagen.');
|
||||||
}
|
}
|
||||||
} elseif ($action === 'change-password') {
|
} elseif ($action === 'change-password') {
|
||||||
|
$attempt = [
|
||||||
|
'action' => 'Passwortänderung',
|
||||||
|
'username' => $form['username'],
|
||||||
|
'new_password_length' => (string) strlen($form['new_password']),
|
||||||
|
];
|
||||||
$loginCheck = $ldap->testUserCredentials($form['username'], $form['password']);
|
$loginCheck = $ldap->testUserCredentials($form['username'], $form['password']);
|
||||||
|
|
||||||
if (!(bool) ($loginCheck['success'] ?? false)) {
|
if (!(bool) ($loginCheck['success'] ?? false)) {
|
||||||
@@ -121,7 +131,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<form class="login-form" method="post" action="/admin/ldap-test">
|
<?php if (is_array($attempt)): ?>
|
||||||
|
<div class="login-notice login-notice-info">
|
||||||
|
<strong>Letzter Versuch</strong>
|
||||||
|
<ul class="login-list">
|
||||||
|
<li>Aktion: <?= htmlspecialchars((string) ($attempt['action'] ?? ''), ENT_QUOTES) ?></li>
|
||||||
|
<li>Benutzername: <?= htmlspecialchars((string) ($attempt['username'] ?? ''), ENT_QUOTES) ?></li>
|
||||||
|
<?php if (isset($attempt['new_password_length'])): ?>
|
||||||
|
<li>Länge neues Passwort: <?= htmlspecialchars((string) ($attempt['new_password_length'] ?? ''), ENT_QUOTES) ?></li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form class="login-form" method="post" action="/admin/ldap-test/">
|
||||||
<label class="login-field">
|
<label class="login-field">
|
||||||
<span>Benutzername</span>
|
<span>Benutzername</span>
|
||||||
<input type="text" name="username" value="<?= htmlspecialchars($form['username'], ENT_QUOTES) ?>" required>
|
<input type="text" name="username" value="<?= htmlspecialchars($form['username'], ENT_QUOTES) ?>" required>
|
||||||
|
|||||||
Reference in New Issue
Block a user