display attempts to admin
This commit is contained in:
20
ldap.php
20
ldap.php
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once "database.php";
|
||||
|
||||
$ldap_domain_name = "woodywood";
|
||||
|
||||
$handle = ldap_connect("ldap://$ldap_domain_name.local");
|
||||
@@ -18,15 +20,25 @@ class UserInfo
|
||||
}
|
||||
}
|
||||
|
||||
function LdapConnect(string $domain, string $username, string $password, ?array $controls): LDAP\Result|false
|
||||
function LdapConnect(string $domain, string $username, string $password): LDAP\Result|false
|
||||
{
|
||||
global $handle;
|
||||
$bind = ldap_bind_ext($handle, $username . '@' . $domain, $password, $controls);
|
||||
LogConnection();
|
||||
$bind = ldap_bind_ext($handle, $username . '@' . $domain, $password);
|
||||
return $bind;
|
||||
}
|
||||
|
||||
function LogConnection() {}
|
||||
function LdapIsConnected(string $domain, string $username, string $password) {
|
||||
global $handle;
|
||||
$result = LdapConnect($domain, $username, $password);
|
||||
ldap_parse_result($handle, $result, $error_code, $matched_dn, $error_message, $referrals, $controls);
|
||||
$success = $error_code == 0;
|
||||
LogConnection($username, $success);
|
||||
return $success;
|
||||
}
|
||||
|
||||
function LogConnection(string $username, bool $success) {
|
||||
InsertLine(new AuthAttempt($username, $success ? "success" : "failure", $_SERVER['REMOTE_ADDR']));
|
||||
}
|
||||
|
||||
function LdapConnectAndBind()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user