Skip to content

Instantly share code, notes, and snippets.

@Gunni
Created May 12, 2017 15:32
Show Gist options
  • Save Gunni/0bd5095fa73c74cea84eecea7be9d3a8 to your computer and use it in GitHub Desktop.
Save Gunni/0bd5095fa73c74cea84eecea7be9d3a8 to your computer and use it in GitHub Desktop.
<?php
define(LDAP_OPT_DIAGNOSTIC_MESSAGE, 0x0032);
$handle = ldap_connect('ldap://9.0.0.1');
$bind = ldap_bind($handle, 'observium-xxxxx@domain.local', 'super good password');
if ( ! $bind)
{
if (ldap_get_option($handle, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error))
{
echo "Error Binding to LDAP: $extended_error";
}
else
{
echo "Error Binding to LDAP: No additional information is available.";
}
}
else
{
$result = ldap_search($handle, 'DC=domain,DC=local', '(sAMAccountName=some_username)');
$info = ldap_get_entries($handle, $result);
var_dump($info);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment