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

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 04-27-2010, 06:17 AM
Moderator
 
Posts: 7,928
Default [SOLVED] PHP PreAuth Help

Hi,

I am delving into try to write a small PHP program and falling over at the first hurdle on pre-auth. My code so far
Code:
<?php
        $client = new SoapClient(null,
                array(
                        'location' => "https://zimbra.fqdn/service/soap/",
                        'uri' => "urn:zimbra",
                        'trace' => 1,
                        'exceptions' => 1,
                        'soap_version' => SOAP_1_1,
                        'style' => SOAP_RPC,
                        'use' => SOAP_LITERAL
                )
        );

        $key = "<my domain auth key>";
        $timestamp = time() * 1000;
        $preauthToken = hash_hmac("sha1", "uxbod@domain.com" . "|name|0|" . $timestamp, $key);

        $params = array(
                new SoapParam("uxbod@domain.com", "name"),
                new SoapParam("$preauthToken", "preauth"),
                new SoapParam("0", "expires"),
        );

        try
        {
                $zimbraSession = $client->__soapCall(
                        "AuthRequest",
                        $params,
                        new SoapHeader("urn:zimbra", "context")
                );

        } catch (SoapFault $exception) { echo "Failed : $exception\n\n"; }

        echo htmlentities($client->__getLastResponse()) . "\n\n";
?>
I end up getting the error message
Code:
PHP Fatal error:  SoapClient::__soapCall(): first parameter must be string or null in code.php line 30
Any help would be gratefully appreciated. All I am wanting to do in the end is query for a contact and pull out the name.
__________________
Reply With Quote
  #2 (permalink)  
Old 04-28-2010, 04:06 AM
Moderator
 
Posts: 7,928
Default

Getting a little further as it would appear I was missing a parameter to the SOAP call
Code:
$zimbraSession = $client->__soapCall(
                        "AuthRequest",
                        $params,
                        NULL,
                        new SoapHeader("urn:zimbraAccount", "context")
                );
Yet it still does not authenticate and the error I get back is
Code:
service.UNKNOWN_DOCUMENT
__________________
Reply With Quote
  #3 (permalink)  
Old 04-28-2010, 06:44 AM
Moderator
 
Posts: 7,928
Default

Was using the incorrect URN and all is working now
__________________
Reply With Quote
  #4 (permalink)  
Old 04-29-2010, 02:25 PM
Project Contributor
 
Posts: 72
Default

Quote:
Originally Posted by uxbod View Post
Was using the incorrect URN and all is working now
What is the correct URN?

'uri' => "urn:zimbraAccount", ???
__________________
Daniel Eugenin
http://www.it-linux.cl
Reply With Quote
  #5 (permalink)  
Old 04-30-2010, 01:06 AM
Moderator
 
Posts: 7,928
Default

Yes that is the correct one for PreAuth.
__________________
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.