public function synchToDrupalAccount($drupal_user, &$user_edit, $prov_event = LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER, $ldap_user = NULL,  $save = FALSE) {
    
    $debug = array(
      'account' => $drupal_user,
      'user_edit' => $user_edit,
      'ldap_user' => $ldap_user,
    );

    if (
        (!$ldap_user  && !isset($drupal_user->name)) ||
        (!$drupal_user && $save) ||
        ($ldap_user && !isset($ldap_user['sid']))
    ) {
       // should throw watchdog error also
      return FALSE;
    }

    if (!$ldap_user && $this->drupalAcctProvisionServer) {
      $ldap_user = ldap_servers_get_user_ldap_data($drupal_user->name, $this->drupalAcctProvisionServer, 'ldap_user_prov_to_drupal');
    }

    if (!$ldap_user) {
      return FALSE;
    }

    if ($this->drupalAcctProvisionServer) {
      $ldap_server = ldap_servers_get_servers($this->drupalAcctProvisionServer, NULL, TRUE);
      $this->entryToUserEdit($ldap_user, $user_edit, $ldap_server, LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, array($prov_event));
    }

    if ($save) {
      $account = user_load($drupal_user->uid);
      $result = user_save($account, $user_edit, 'ldap_user');
      return $result;
    }
    else {
      return TRUE;
    }
  }
public function synchToDrupalAccount($drupal_user, &$user_edit, $prov_event = LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER, $ldap_user = NULL,  $save = FALSE) {
    
    $debug = array(
      'account' => $drupal_user,
      'user_edit' => $user_edit,
      'ldap_user' => $ldap_user,
    );

    if (
        (!$ldap_user  && !isset($drupal_user->name)) ||
        (!$drupal_user && $save) ||
        ($ldap_user && !isset($ldap_user['sid']))
    ) {
       // should throw watchdog error also
      return FALSE;
    }

    if (!$ldap_user && $this->drupalAcctProvisionServer) {
      $ldap_user = ldap_servers_get_user_ldap_data($drupal_user->name, $this->drupalAcctProvisionServer, 'ldap_user_prov_to_drupal');
    }

    if (!$ldap_user) {
      return FALSE;
    }

    if ($this->drupalAcctProvisionServer) {
      $ldap_server = ldap_servers_get_servers($this->drupalAcctProvisionServer, NULL, TRUE);
      $this->entryToUserEdit($ldap_user, $user_edit, $ldap_server, LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, array($prov_event));
    }

    if ($save) {
      $account = user_load($drupal_user->uid);
      $result = user_save($account, $user_edit, 'ldap_user');
      return $result;
    }
    else {
      return TRUE;
    }
  }
public function synchToDrupalAccount ( $ drupal_user , & $ user_edit , $ prov_event = LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER , $ ldap_user = NULL , $ save = FALSE ) { $ debug = array ( 'account' => $ drupal_user , 'user_edit' => $ user_edit , 'ldap_user' => $ ldap_user , ) ; if ( ( ! $ ldap_user && ! isset ( $ drupal_user -> name ) ) || ( ! $ drupal_user && $ save ) || ( $ ldap_user && ! isset ( $ ldap_user [ 'sid' ] ) ) ) { // should throw watchdog error also return FALSE ; } if ( ! $ ldap_user && $ this -> drupalAcctProvisionServer ) { $ ldap_user = ldap_servers_get_user_ldap_data ( $ drupal_user -> name , $ this -> drupalAcctProvisionServer , 'ldap_user_prov_to_drupal' ) ; } if ( ! $ ldap_user ) { return FALSE ; } if ( $ this -> drupalAcctProvisionServer ) { $ ldap_server = ldap_servers_get_servers ( $ this -> drupalAcctProvisionServer , NULL , TRUE ) ; $ this -> entryToUserEdit ( $ ldap_user , $ user_edit , $ ldap_server , LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER , array ( $ prov_event ) ) ; } if ( $ save ) { $ account = user_load ( $ drupal_user -> uid ) ; $ result = user_save ( $ account , $ user_edit , 'ldap_user' ) ; return $ result ; } else { return TRUE ; } }
given a drupal account, query ldap and get all user fields and create user account

@param array $account drupal account array with minimum of name
@param array $user_edit drupal edit array in form user_save($account, $user_edit) would take,
generally empty unless overriding synchToDrupalAccount derived values
@param array $ldap_user as user's ldap entry.  passed to avoid requerying ldap in cases where already present
@param boolean $save indicating if drupal user should be saved.  generally depends on where function is called from.

@return result of user_save() function is $save is true, otherwise return TRUE
$user_edit data returned by reference
given a drupal account query ldap and get all user fields and create user account