1. Go to this page and download the library: Download templatemonster/ldap-auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
...
'controllerMap' => [
...
'migrate'=>[
'class' => 'indigerd\migrationaware\controllers\MigrateController',
'configFiles' => [
'@backend/config/web.php',
],
'migrationPath'=>'@common/migrations/db', //leave as it was before
'migrationTable'=>'{{%system_db_migration}}' //leave as it was before
],
...
],
...
use yii\db\Migration;
use common\models\User;
class m161011_115434_assign_ldap_roles extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
/** @var \yii\rbac\DbManager $auth */
$auth = \Yii::$app->ldapGroupsManager;
$this->insert('{{%ldap_group}}', [
'id' => 1,
'ldap_group' => 'Administrators',
'rbac_roles' => User::ROLE_ADMINISTRATOR
]);
$auth->assign($auth->getRole(User::ROLE_ADMINISTRATOR), 1);
}
/**
* @inheritdoc
*/
public function safeDown()
{
$this->delete('{{%ldap_group}}', ['id' => [1]]);
\Yii::$app->ldapGroupsManager->revokeAll(1);
}
}