e7e901f6e5
- Add PHP LDAP extension to Docker container - Implement LdapSync class for authentication and user synchronization - Add automatic user sync via cron (every 30 minutes) - Create role-based access control system (admin, manager, viewer) - Add LDAP configuration UI in settings - Support for both Active Directory and OpenLDAP - Group-to-role mapping with flexible configuration - Add 50+ translations (EN + RU) for LDAP features - Include comprehensive setup documentation - Enhance Auth::login() with LDAP fallback - Add LDAP settings page with connection testing
39 lines
1.1 KiB
PHP
Executable File
39 lines
1.1 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
/**
|
|
* LDAP User Synchronization Script
|
|
* Runs periodically to sync users from LDAP/AD
|
|
*/
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
require_once __DIR__ . '/../inc/Config.php';
|
|
require_once __DIR__ . '/../inc/DB.php';
|
|
require_once __DIR__ . '/../inc/LdapSync.php';
|
|
|
|
try {
|
|
$ldap = new LdapSync();
|
|
|
|
if (!$ldap->isEnabled()) {
|
|
exit(0); // LDAP not enabled, nothing to do
|
|
}
|
|
|
|
echo "[" . date('Y-m-d H:i:s') . "] Starting LDAP user synchronization...\n";
|
|
|
|
$result = $ldap->syncUsers();
|
|
|
|
if ($result['success']) {
|
|
echo "✓ Synchronization completed successfully:\n";
|
|
echo " - Total users in LDAP: {$result['total']}\n";
|
|
echo " - Synced (updated): {$result['synced']}\n";
|
|
echo " - Created: {$result['created']}\n";
|
|
echo " - Disabled: {$result['disabled']}\n";
|
|
} else {
|
|
echo "✗ Synchronization failed: {$result['error']}\n";
|
|
exit(1);
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo "✗ Error: " . $e->getMessage() . "\n";
|
|
exit(1);
|
|
}
|