I currently have in the environment the AD (Active Directory) of Windows Server 2012. Now in my PHP application I can already connect to this AD via ldap_connect + ldap_bind .
However, I would like to make a query within AD. Search for example the field displayName, mail or any attribute contained in the Attribute Editor tab.
I already found the PHP manual ldap_search , but I was unable to get it to work properly. Not to mention I do not know if this function would be the correct one for me.
Thank you.
EDIT-- Date: 04/27/2015.
I was able to perform the query, see how my code was:
$filtro = "(&(objectClass=user)(objectCategory=person)(displayname=*)(sAMAccountname=$login1))";
$mostrar = array("samaccountname");
if (!($busca=@ldap_search($connect, $base_dn, $filtro, $mostrar))){
die("Não foi possível realizar busca no Active Directory");
}
$info = ldap_get_entries($connect, $busca);
echo "<pre>".print_r($info,true)."</pre>";exit;