Results 1 to 1 of 1

Thread: PHP: Authing as regular user in PHP via SOAP (how to)

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    Detroit, MI
    Posts
    67
    Rep Power
    7

    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.

Similar Threads

  1. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  2. [SOLVED] Zimbra logwatch.
    By nishith in forum Administrators
    Replies: 5
    Last Post: 06-10-2009, 05:42 PM
  3. Can't start Zimbra!
    By zibra in forum Administrators
    Replies: 5
    Last Post: 03-22-2007, 12:34 PM
  4. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 11:38 AM
  5. Services stopped working
    By lilwong in forum Administrators
    Replies: 4
    Last Post: 08-15-2006, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •