コード例 #1
0
 public function get_user_info($username)
 {
     $client = Zend_Gdata_ClientLogin::getHttpClient($this->email, $this->password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
     $gdata = new Zend_Gdata_Gapps($client, $this->domain);
     $result = $gdata->retrieveUser($username);
     return $result;
 }
コード例 #2
0
/**
 * Undo forcing a user to change their password at next login.
 *
 * @param  Zend_Gdata_Gapps $gapps    The service object to use for communicating with the Google
 *                                    Apps server.
 * @param  boolean          $html     True if output should be formatted for display in a web browser.
 * @param  string           $username The username which should be updated.
 * @return void
 */
function clearUserMustChangePassword($gapps, $html, $username)
{
    if ($html) {
        echo "<h2>Undo Force User To Change Password</h2>\n";
    }
    $user = $gapps->retrieveUser($username);
    if ($user !== null) {
        $user->login->changePasswordAtNextLogin = false;
        $user->save();
    } else {
        if ($html) {
            echo '<p>';
        }
        echo 'Error: Specified user not found.';
        if ($html) {
            echo '</p>';
        }
        echo "\n";
    }
    if ($html) {
        echo "<p>Done.</p>\n";
    }
}
コード例 #3
0
function google_reset_password($password = "")
{
    global $db, $GOOGLE_APPS, $ENTRADA_USER;
    if (isset($GOOGLE_APPS) && is_array($GOOGLE_APPS) && isset($GOOGLE_APPS["active"]) && (bool) $GOOGLE_APPS["active"] && $password) {
        $query = "\tSELECT a.*, b.`group`, b.`role`\n\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\tON a.`id` = b.`user_id`\n\t\t\t\t\tWHERE a.`id` = " . $db->qstr($ENTRADA_USER->getID()) . "\n\t\t\t\t\tAND b.`app_id` = " . $db->qstr(AUTH_APP_ID);
        $result = $db->GetRow($query);
        if ($result) {
            if (!in_array($result["google_id"], array("", "opt-out", "opt-in"))) {
                try {
                    $client = Zend_Gdata_ClientLogin::getHttpClient($GOOGLE_APPS["admin_username"], $GOOGLE_APPS["admin_password"], Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
                    $service = new Zend_Gdata_Gapps($client, $GOOGLE_APPS["domain"]);
                    $account = $service->retrieveUser($result["google_id"]);
                    $account->login->password = $password;
                    $account->save();
                    application_log("success", "Successfully updated Google account password for google_id [" . $result["google_id"] . "] and proxy_id [" . $ENTRADA_USER->getID() . "].");
                    return true;
                } catch (Zend_Gdata_Gapps_ServiceException $e) {
                    application_log("error", "Unable to change password for google_id [" . $google_id . "] for proxy_id [" . $ENTRADA_USER->getID() . "]. Error details: [" . $error->getErrorCode() . "] " . $error->getReason() . ".");
                    if (is_array($e->getErrors())) {
                        foreach ($e->getErrors() as $error) {
                            application_log("error", "Unable to change password for google_id [" . $google_id . "] for proxy_id [" . $ENTRADA_USER->getID() . "]. Error details: [" . $error->getErrorCode() . "] " . $error->getReason() . ".");
                        }
                    }
                }
            }
        } else {
            application_log("error", "google_reset_password() failed because we were unable to fetch information on proxy_id [" . $ENTRADA_USER->getID() . "]. Database said: " . $db->ErrorMsg());
        }
    }
    return false;
}
コード例 #4
0
ファイル: gapps.php プロジェクト: name256/crm42
<?php

Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$domain = 'couleetechlink.com';
//CTLTODO make this a global setting
$email = $username . '@' . $domain;
ob_start();
try {
    $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, 'apps');
    $apps = new Zend_Gdata_Gapps($client, $domain);
    $gdClient = new Zend_Gdata($client);
    $user = $apps->retrieveUser($username);
    $logged_in = true;
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
    echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
    echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
    $logged_in = false;
    file_put_contents('/var/log/email_client.log', 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl(), FILE_APPEND);
} catch (Zend_Gdata_App_AuthException $ae) {
    echo 'Problem authenticating: ' . $ae->exception() . "\n";
    file_put_contents('/var/log/email_client.log', 'Problem authenticating: ' . $ae->exception() . "\n{$username} {$password}\n", FILE_APPEND);
    $logged_in = false;
}
ob_end_clean();
if ($logged_in == true) {
    $user_info = array();
    $user_info['user_name'] = $username;