Skip to content

Instantly share code, notes, and snippets.

@Wintereise
Created September 18, 2016 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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','some.user@somecompany.com');
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