PHP code example of t3chn0crat / laravel-ldap-connector

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

    

t3chn0crat / laravel-ldap-connector example snippets


    'driver' => 'ldap',
    

    public function getAuthIdentifier()
    {
        if (isset($this->ldap)) {
            return $this->ldap->samaccountname;
        }
    }
    

return [
	'account_suffix'=>  "@domain.local",
    // Load balancing domain controllers, but only one is requried
	'domain_controllers'=>  [
        "192.168.0.1", 
        "dc02.domain.local"
    ],
	'base_dn'   =>  'DC=domain,DC=local',
    // AD attributes to get http://msdn.microsoft.com/en-us/library/windows/desktop/ms675090%28v=vs.85%29.aspx
    'fields' => [
        'company',
        'department',
        'displayname',
        'homephone',
        'mail',
        'memberof',
        'mobile',
        'primarygroupid',
        'samaccountname',
        'telephonenumber',
        'title',
    ]
];

	'T3chn0crat\LdapConnector\LdapConnectorServiceProvider'
	

if (Auth::attempt(array('username' => $email, 'password' => $password)))
{
    return Redirect::intended('dashboard');
}

Email: {{ Auth::user()->ldap->mail }}
Department {{ Auth::user()->ldap->department }}

if (Auth::user()->ldap->isMemberOf('Git Hub Users')) { return 'yes'; }


$ldap = App::make('T3chn0crat\LdapConnector\LdapService', [Config::get('ldap')]);
$collection = $ldap->getAllUsersWithFields();

$test = $collection->where('mail', '[email protected]');
$department = $test->department;