src/LdapTools/Object/LdapObjectManager.php
protected function getObjectRestoreLocation(LdapObject $ldapObject, $location)
    {
        // If a location was defined, use that.
        if ($location) {
            $newLocation = (string) $location;
        // Check the attribute for the last known location first...
        } elseif ($ldapObject->has('lastKnownLocation')) {
            $newLocation = $ldapObject->get('lastKnownLocation');
        // All else failed, so query it from the DN...
        } else {
            try {
                $newLocation = (new LdapQueryBuilder($this->connection, $this->schemaFactory))
                    ->select('lastKnownParent')
                    ->from(LdapObjectType::DELETED)
                    ->where(['dn' => $ldapObject->get('dn')])
                    ->getLdapQuery()
                    ->getSingleScalarOrNullResult();
            } catch (Exception $e) {
                $newLocation = null;
            }
        }

        // Either this was not a deleted object or it no longer exists?
        if (is_null($newLocation)) {
            throw new InvalidArgumentException(sprintf(
                'No restore location specified and cannot find the last known location for "%s".',
                $ldapObject->get('dn')
            ));
        }

        return $newLocation;
    }
protected function getObjectRestoreLocation(LdapObject $ldapObject, $location)
    {
        // If a location was defined, use that.
        if ($location) {
            $newLocation = (string) $location;
        // Check the attribute for the last known location first...
        } elseif ($ldapObject->has('lastKnownLocation')) {
            $newLocation = $ldapObject->get('lastKnownLocation');
        // All else failed, so query it from the DN...
        } else {
            try {
                $newLocation = (new LdapQueryBuilder($this->connection, $this->schemaFactory))
                    ->select('lastKnownParent')
                    ->from(LdapObjectType::DELETED)
                    ->where(['dn' => $ldapObject->get('dn')])
                    ->getLdapQuery()
                    ->getSingleScalarOrNullResult();
            } catch (Exception $e) {
                $newLocation = null;
            }
        }

        // Either this was not a deleted object or it no longer exists?
        if (is_null($newLocation)) {
            throw new InvalidArgumentException(sprintf(
                'No restore location specified and cannot find the last known location for "%s".',
                $ldapObject->get('dn')
            ));
        }

        return $newLocation;
    }
protected function getObjectRestoreLocation ( LdapObject $ ldapObject , $ location ) { // If a location was defined, use that. if ( $ location ) { $ newLocation = ( string ) $ location ; // Check the attribute for the last known location first... } elseif ( $ ldapObject -> has ( 'lastKnownLocation' ) ) { $ newLocation = $ ldapObject -> get ( 'lastKnownLocation' ) ; // All else failed, so query it from the DN... } else { try { $ newLocation = ( new LdapQueryBuilder ( $ this -> connection , $ this -> schemaFactory ) ) -> select ( 'lastKnownParent' ) -> from ( LdapObjectType :: DELETED ) -> where ( [ 'dn' => $ ldapObject -> get ( 'dn' ) ] ) -> getLdapQuery ( ) -> getSingleScalarOrNullResult ( ) ; } catch ( Exception $ e ) { $ newLocation = null ; } } // Either this was not a deleted object or it no longer exists? if ( is_null ( $ newLocation ) ) { throw new InvalidArgumentException ( sprintf ( 'No restore location specified and cannot find the last known location for "%s".' , $ ldapObject -> get ( 'dn' ) ) ) ; } return $ newLocation ; }
It's possible a new location was not explicitly given and the attribute that contains the last know location
was not queried for when the object was originally found. In that case attempt to retrieve the last known
location from a separate LDAP query.

@param LdapObject $ldapObject
@param string|null $location
@return string
It s possible a new location was not explicitly given and the attribute that contains the last know location was not queried for when the object was originally found . In that case attempt to retrieve the last known location from a separate LDAP query .