Synchronizing information with LDAP and authenticating users by membership in the LDAP security group
- Authenticating users by membership in the LDAP security group;
- Support external authentication, e.g.
kerberos
; - Checking user for compliance with roles;
- Synchronizing information from LDAP to database;
- Synchronizing information as a subordination tree of employees;
- Support for a customizable list of fields for synchronization;
- Support for customize binded information for models
Employee
andDepartment
; - Support for customize displaying information of employees.
-
Install the Plugin using composer:
composer require anklimsk/cakephp-ldap-sync
-
Add the next line to the end of the file
app/Config/bootstrap.php
:CakePlugin::load('CakeLdap', ['bootstrap' => true, 'routes' => true]);
-
Open file
app/Config/database.php
and add connectionldap
, e.g.:public $ldap = [ 'datasource' => 'CakeLdap.LdapExtSource', 'persistent' => false, 'host' => ['ldapsrv01', 'ldapsrv02'], 'port' => 389, 'login' => '[email protected]', 'password' => 'pas$w0rd', 'database' => '', 'basedn' => 'dc=fabrikam,dc=com', 'type' => 'ActiveDirectory', 'tls' => false, 'version' => 3, ];
-
Copy configuration file from
app/Plugin/CakeLdap/Config/cakeldap.php
toapp/Config
. -
Edit config file and configure plugin See
Example of configuration file
-
Create database tables of plugin using the CakePHP console, run the command:
Console/cake schema create -p CakeLdap
-
In your file
app\Config\core.php
uncomment modify next line:Configure::write('Routing.prefixes', array('admin'));
-
Copy translation files from
app/Plugin/CakeLdap/Locale/rus/LC_MESSAGES/
toapp/Locale/rus/LC_MESSAGES
:
cake_ldap_field_name.*
;cake_ldap_validation_errors.*
.
- Get the name of the user that is running the web server, run the command:
ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1
. - Configure scripts to run schedule, run the command
crontab -u www-data -e
wherewww-data
- user name for web server. - Add the following line to the list of cron jobs:
#
# In this example, run the synchronizing script
# will be made every day on 7:10 AM
10 7 * * * cd /var/www/paht_to_app/app && Console/cake CakeLdap.cron sync -q