public function Connect($UniqueID, $ProviderKey, $UserData, $Options = array()) {
      Trace('UserModel->Connect()');
      
      $UserID = FALSE;
      if (!isset($UserData['UserID'])) {
         // Check to see if the user already exists.
         $Auth = $this->GetAuthentication($UniqueID, $ProviderKey);
         $UserID = GetValue('UserID', $Auth);

         if ($UserID)
            $UserData['UserID'] = $UserID;
      }
      
      $UserInserted = FALSE;
      
      if ($UserID) {
         // Save the user.
         $this->SynchUser($UserID, $UserData);
         return $UserID;
      } else {
         // The user hasn't already been connected. We want to see if we can't find the user based on some critera.
         
         // Check to auto-connect based on email address.
         if (C('Garden.SSO.AutoConnect', C('Garden.Registration.AutoConnect')) && isset($UserData['Email'])) {
            $User = $this->GetByEmail($UserData['Email']);
            Trace($User, "Autoconnect User");
            if ($User) {
               $User = (array)$User;
               // Save the user.
               $this->SynchUser($User, $UserData);
               $UserID = $User['UserID'];
            }
         }
         
         if (!$UserID) {
            // Create a new user.
//            $UserID = $this->InsertForBasic($UserData, FALSE, array('ValidateEmail' => FALSE, 'NoConfirmEmail' => TRUE));
            $UserData['Password'] = md5(microtime());
            $UserData['HashMethod'] = 'Random';
            
            TouchValue('CheckCaptcha', $Options, FALSE);
            TouchValue('NoConfirmEmail', $Options, TRUE);
            TouchValue('NoActivity', $Options, TRUE);
            
            Trace($UserData, 'Registering User');
            $UserID = $this->Register($UserData, $Options);
            $UserInserted = TRUE;
         }
         
         if ($UserID) {
            // Save the authentication.
            $this->SaveAuthentication(array(
                'UniqueID' => $UniqueID, 
                'Provider' => $ProviderKey, 
                'UserID' => $UserID
            ));
            
            if ($UserInserted && C('Garden.Registration.SendConnectEmail', TRUE)) {
               $Provider = $this->SQL->GetWhere('UserAuthenticationProvider', array('AuthenticationKey' => $ProviderKey))->FirstRow(DATASET_TYPE_ARRAY);
            }
         } else {
            Trace($this->Validation->ResultsText(), TRACE_ERROR);
         }
      }
      
      return $UserID;
   }