Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-27-2009, 06:42 PM
Project Contributor
 
Posts: 67
Default PHP: Authing as regular user in PHP via SOAP (how to)

Hadn't found any info on the below code and recently figured it out.

Just to add to the database of info on these forums; here is how to auth to Zimbra as a standard user (as opposed to an Admin) in PHP using the built-in SOAP extensions:
$soapurl = The non-admin (/service/soap/) URL of your server
$authoken = An authToken returned from a urn:zimbraAdmin call to DelegateAuthRequest
$context = zimbraMail, zimbra, etc.
$user = a valid zimbra user ID (ie: b5e0355-3b57-41a9-a131-2e.....)
$session = A valid sessionID from the DelegateAuthRequest request
Unfortunately, PHP's SOAP extension doesn't allow attributes in tags, so it's rather messy:

Code:
function zimbraSOAPUserLogin($soapurl,$user,$authtoken,$session,$context) {
    $client = new SoapClient(null, array('location' => $soapurl, 'uri' => "urn:" . $context, 'trace' => 1, 'exceptions' => 1, 'soap_version' => SOAP_1_1, 'style' => SOAP_RPC, 'use' => SOAP_LITERAL)); 
    $soapHeader = array(new SoapHeader('urn:zimbra','context xmlns="urn:zimbra"',new SoapVar('<ns2:context><authToken>' . $authtoken . '</authToken><sessionId id="' . $session . '"/><account by="id">'. $user .'</account></ns2:context>',XSD_ANYXML)));
    $client->__setSoapHeaders($soapHeader);  
    return $client;
    }

Last edited by ab5602; 03-27-2009 at 06:50 PM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.