PHP code example of fschwaiger / laravel-ldap
1. Go to this page and download the library: Download fschwaiger/laravel-ldap 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/ */
fschwaiger / laravel-ldap example snippets
Fschwaiger\Ldap\LdapServiceProvider::class,
'providers' => [
'users' => [
'driver' => 'ldap',
'model' => App\User::class,
],
],
namespace App;
use Fschwaiger\Ldap\User as LdapUser;
class User extends LdapUser;
{
...
}
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('ldap:import-groups')->daily();
}
Gate::authorize('privilege')
// or
$allowed = $user->can('privilege')
$this->middleware('can:privilege')
// or
Route::get('action', ['middleware' => 'can:privilege', 'uses' => 'MyController@action'])
@can('privilege')
...
@endcan
console
config/ldap.php
config/privileges.php
database/migrations/2016_12_17_000000_extend_users_table.php
database/migrations/2016_12_17_100000_create_groups_table.php
database/migrations/2016_12_17_200000_create_group_user_table.php
ini
LDAP_USERNAME=binduser
LDAP_PASSWORD=bindpass
console
php artisan migrate