Results 1 to 5 of 5

Thread: [SOLVED] PHP PreAuth Help

  1. #1
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    25

    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.

  2. #2
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    25

    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

  3. #3
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    25

    Default

    Was using the incorrect URN and all is working now

  4. #4
    Join Date
    Jun 2006
    Location
    Santiago - Chile
    Posts
    76
    Rep Power
    9

    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

  5. #5
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    25

    Default

    Yes that is the correct one for PreAuth.

Similar Threads

  1. March 6 EDU Summit @ Yahoo UK
    By mmorse in forum Zimbra in Education
    Replies: 0
    Last Post: 02-25-2009, 12:22 PM
  2. Zimbra @ Educause - Orlando
    By justcdl123 in forum Zimbra in Education
    Replies: 0
    Last Post: 08-19-2008, 01:15 PM
  3. [SOLVED] Another PHP Preauth example
    By riogd in forum Developers
    Replies: 0
    Last Post: 02-22-2008, 05:48 PM
  4. Preauth documentation improvements
    By riogd in forum Developers
    Replies: 0
    Last Post: 02-22-2008, 05:10 PM
  5. PHP Curl Preauth Code
    By Ericx in forum Developers
    Replies: 0
    Last Post: 02-01-2008, 01:35 PM

Posting Permissions

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