Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/PHPOpenLDAPer/LDAPEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,26 @@ public function __construct($conn, $dn)

/**
* Pulls an entry from the ldap connection, and sets $object If entry does not exist, $object = null.
* @returns bool existence of ldap object
*/
private function pullObject()
{
$result = @ldap_read($this->conn, $this->dn, "(objectclass=*)");
if ($result === false) {
$this->object = null;
return false;
}
$search = @ldap_get_entries($this->conn, $result);
LDAPConn::stripCount($search);

if (isset($search)) {
// Object Exists
if (count($search) > 1) { // 1 For LDAP count element, and 1 for actual object
// Duplicate Objects Found
die("FATAL: Call to ldapObject with non-unique DN.");
} else {
$this->object = $search[0];
}
$entries = @ldap_get_entries($this->conn, $result);
if ($entries === false) {
$this->object = null;
return false;
}
LDAPConn::stripCount($entries);
if (count($entries) > 1) {
throw new \Exception("FATAL: Call to ldapObject with non-unique DN.");
} else {
$this->object = $entries[0];
return true;
}
}

Expand Down