Skip to content

Instantly share code, notes, and snippets.

@Nek-
Last active May 29, 2020 09:19
Show Gist options
  • Save Nek-/c53010ce1c4807aae083375a2da14eeb to your computer and use it in GitHub Desktop.
Save Nek-/c53010ce1c4807aae083375a2da14eeb to your computer and use it in GitHub Desktop.
Active directory ldap PHP
<?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]);
@Nek-
Copy link
Author

Nek- commented May 29, 2020

@jcarrier-vp TYPO. But still. 🇫🇷 🇫🇷 ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment