Created
July 12, 2020 07:00
-
-
Save jacricelli/499abb4d55a588c69b31ec52327d02d7 to your computer and use it in GitHub Desktop.
LDAP Entry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$adServer = "ldap://ip"; | |
$ldap = ldap_connect($adServer); | |
$username = ''; | |
$password = ''; | |
$ldaprdn = 'DOMAIN' . "\\" . $username; | |
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); | |
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); | |
ldap_set_option($ldap, LDAP_OPT_NETWORK_TIMEOUT, 10); | |
$bind = ldap_bind($ldap, $ldaprdn, $password); | |
if ($bind) { | |
$attributes = array(); | |
$attributes[] = 'givenname'; | |
$attributes[] = 'mail'; | |
$attributes[] = 'memberof'; | |
$attributes[] = 'samaccountname'; | |
$attributes[] = 'sn'; | |
$result = ldap_search($ldap, "OU=Users,DC=domain,DC=com", "(&(objectClass=person)(samaccountname=$username))", $attributes); | |
$entry = ldap_get_entries($ldap, $result); | |
var_dump($entry); | |
@ldap_close($ldap); | |
} else { | |
echo "Bad!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment