KevinTheJedi
I put print statements into the code and can see the values being used, and everything looks good. I entered the values, including the exact filter being used, into ldp.exe in Windows to test LDAP and the exact same query returns the correct result in ldp.exe. So it should be working...
list($samid) = explode('@', $dn);
print($this->getSearchBase() . "<br />");
print($dn . "<br />");
print_r($samid);
print("<br />" . $opts . "<br />");
print(sprintf('(|(userPrincipalName=%s)(samAccountName=%s))', $dn, $samid) . "<br />");
$r = $c->search(
$this->getSearchBase(),
sprintf('(|(userPrincipalName=%s)(samAccountName=%s))', $dn, $samid), $opts);
if (!PEAR::isError($r) && $r->count() > 0) {
$rc = $r->current();
if ($rc) {
$dn = $r->current()->dn();
} else {
print("rc = false" . "<br />");
}
}
Output:
CN=Users,DC=example,DC=local
testuser@example.local
testuser
(|(userPrincipalName=testuser@example.local)(samAccountName=testuser))
rc = false