32 lines
811 B
PHP
32 lines
811 B
PHP
<?php
|
|
$ldap_server = 'ldap://intranet.epul3a.local';
|
|
$service_dn = "CN=Service LDAP Reader,CN=Users,DC=epul3a,DC=local";
|
|
|
|
|
|
$service_pwd = "Test@123";
|
|
|
|
$ldapconn = ldap_connect($ldap_server);
|
|
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
|
|
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
|
|
|
|
if (@ldap_bind($ldapconn, $service_dn, $service_pwd)) {
|
|
echo "✅ Connexion réussie avec svc_ldap_read !";
|
|
} else {
|
|
echo "❌ Erreur de connexion : " . ldap_error($ldapconn);
|
|
}
|
|
|
|
ldap_close($ldapconn);
|
|
|
|
// === TEST ===
|
|
require_once __DIR__ . '/models/LDAPAuth.php';
|
|
$ldap = new LDAPAuth();
|
|
$result = $ldap->authenticate("a.gathor", "Test@123");
|
|
|
|
if ($result['success']) {
|
|
echo "✅ Authentification réussie pour " . $result['dn'];
|
|
} else {
|
|
echo "❌ " . $result['message'];
|
|
}
|
|
|
|
$ldap->close();
|