Checking what user a migration is running as I have a single migration out of a larger group, that needs to be run as the administrator or an entity reference fails to map the User entity properly.  I'd love ideas on what I might change so that I wouldn't have to be an administrator to entity reference users, but failing that:

How can I check what user the migration is currently running as?  Basically I want to be sure that drush has been invoked with --user=1 or throw an exception with a reminder that this migration needs to be run as administrator.
In the interest of trying to up the percentage of Drupal Questions that have an answer, I'll post the solution that I came to as a result of Clive's comment.

I added a preImport and postImport method to my migration class as follows:

  public function preImport() {
    parent::preImport();
    $GLOBALS['user']-&gt;previousid = $GLOBALS['user']-&gt;uid;
    $GLOBALS['user']-&gt;uid = 1;
    if ($GLOBALS['user']-&gt;uid != 1) {
      throw new MigrateException('Run Staff Contributor Migration as user 1.');
    }
  }

  public function postImport() {
    parent::postImport();
    $GLOBALS['user']-&gt;uid = $GLOBALS['user']-&gt;previousid;
  }


This ensures that this particular migration is run as user 1 and returns the user value back to whatever it had been at the end of the migration.  It also throws an exception if for some reason the user switch failed.