PHP code example of rodrigopedra / ldap-eloquent-auth

1. Go to this page and download the library: Download rodrigopedra/ldap-eloquent-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/ */

    

rodrigopedra / ldap-eloquent-auth example snippets


// in your config/app.php add the provider to the service providers key

'providers' => [
    /* ... */
    
    'RodrigoPedra\LDAP\LDAPServiceProvider',
]

// in your config/auth.php

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'ldap',
        ],
    ],

    'providers' => [
        'ldap' => [
            'driver' => 'ldap-auth',
            'model' => App\User::class,
        ],
    ],




// in your config/ldap.php
return [
    'servers' => [
        'default' => [
            'server' => env( 'LDAP_SERVER' ),
            'domain' => env( 'LDAP_DOMAIN' ),
        ],
        'other' => [
            'server' => 'OTHER_SERVER',
            'domain' => 'OTHER_DOMAIN',
        ], 
        // ...
        // you can specify multiple servers, the driver will   
        // try to log the user in the order specified here
    ],
];

// create_user_table migration
$table->string('username')->unique();

php artisan vendor:publish --provider="RodrigoPedra\LDAP\LDAPServiceProvider"