Question

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!

Was it helpful?

Solution 2

I have found out that the problem was actually permissions based.

The user I created to manage the changing of passwords although had permissions to reset passwords, it was unable to reset passwords for users which had Super Admin privileges because it only had Admin permissions.

Maybe a more appropriate error message is required here?

OTHER TIPS

Use Fiddler for the error description, it gives more description about the error

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top