The getDN() function returns the DN of the last entry returned by fetch()
Example:
$ldap = new LDAP();
$ldap->search("(objectClass=person)");
while($attrs = $ldap->fetch()) // Get all the returned attributes
{
echo "DN is: " . $ldap->getDN();
echo $attrs["cn"] . "<br>";
}