I have a small script to force users on our Google Apps domain to change their password at next login. I'm using Zend Framework 1.11.13 but I also get the same results on 1.12.0.
The example for updating users in the google docs ( https://developers.google.com/google-apps/provisioning/#updating_a_user_account ) seems out of date or incorrect as calling updateUser on the client object always returns an undefined method error.
Here is my code:
<?php
set_include_path(implode(PATH_SEPARATOR, array(
"/var/www/workspace/extlib/zend-framework/library/",
get_include_path(),
)));
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$client = Zend_Gdata_ClientLogin::getHttpClient("removed", "removed", Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$gdata = new Zend_Gdata_Gapps($client, 'domain.com');
$userEntry = $gdata->retrieveUser("a.username");
$userEntry->getLogin()->setChangePasswordAtNextLogin(true);
$gdata->updateUser("a.username", $userEntry);
And the error I get is:
PHP Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 500
Internal Error' in /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php:718
Stack trace:
#0 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('PUT', 'https://apps-ap...', Array, '<atom:entry xml...', 'application/ato...', NULL)
#1 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php(934): Zend_Gdata->performHttpRequest('PUT', 'https://apps-ap...', Array, '<atom:entry xml...', 'application/ato...')
#2 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/Gapps.php(272): Zend_Gdata_App->put(Object(Zend_Gdata_Gapps_UserEntry), 'https://apps-ap...', NULL, NULL, Array)
#3 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php(1025): Zend_Gdata_Gapps->put(Object(Zend_Gdata_Gapps_UserEntry), 'https://apps-ap...', NULL, NULL, Array)
#4 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/Gapps.php(1005): Zend_ in /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php on line 718
I've added in some debug code here and there and the user definitely gets loaded ok so it doesn't appear to be a permissions error or networking error as the initial request works fine. The error comes about from when I try to call updateUser.
Any help would be really appreciated!