Skip to content

Instantly share code, notes, and snippets.

@Wintereise
Created September 18, 2016 07:01
Show Gist options
  • Save Wintereise/4280091ae4b2c82aaaf554d8716642ec to your computer and use it in GitHub Desktop.
Save Wintereise/4280091ae4b2c82aaaf554d8716642ec to your computer and use it in GitHub Desktop.
<?php
require_once __DIR__ .'vendor/autoload.php';
$config = [
// Mandatory Configuration Options
'domain_controllers' => [ 'a.b.c' ],
'base_dn' => 'ou=users,dc=b,dc=com',
'admin_username' => 'uid=someuser,ou=something',
'admin_password' => 'somepass',
// Optional Configuration Options
'account_prefix' => '',
'account_suffix' => '',
'admin_account_suffix' => '',
'port' => 10636,
'follow_referrals' => false,
'use_ssl' => true,
'use_tls' => false,
'timeout' => 5,
];
$ad = new \Adldap\Adldap();
$provider = new Adldap\Connections\Provider($config);
$ad->addProvider('default', $provider);
try
{
$ad->connect('default');
$results = $provider->search()->findByOrFail('mail','[email protected]');
var_dump($results);
}
catch (Exception $e)
{
echo $e->getMessage() . $e->getTraceAsString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment