Last active
May 29, 2020 09:19
-
-
Save Nek-/c53010ce1c4807aae083375a2da14eeb to your computer and use it in GitHub Desktop.
Active directory ldap PHP
This file contains hidden or 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 | |
$bind = ldap_bind($ldap, $username, $password); | |
$res = ldap_search( | |
$ldap, | |
'OU=UTILISATEUR,DC=scaprim,DC=local', | |
// Weirdo syntax to say objetClass must be type user but the username is either | |
// userprincipalname or samaccountname | |
"(&(objectClass=user)(|(userprincipalname=$username)(samaccountname=$username)))" | |
); | |
// For me cn is the user complete name | |
var_dump(ldap_get_entries($ldap, $res)[0]['cn'][0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 7 =>