如何取得給定 samaccountname 的 DN
/*連線部分*/
$ldap_conn = ldap_connect($hostname, $port);
$bind = ldap_bind($ldap_conn, $username, $password);
/*連線部分*/
$samaccountname = john.doe;
$filter="(samaccountname=$samaccountname)";
$dn="OU=PEOPLE, DC=example, DC=com"; //即使它看起來很明顯,我還是要在此指出 dn 只是一個範例,您必須提供您自己的 OU 和 DC
$res = ldap_search($ldap_conn, $dn, $filter);
$first = ldap_first_entry($ldap_conn, $res);
$data = ldap_get_dn($ldap_conn, $first);
echo "所需的 DN 是:".$data;