Results 1 to 3 of 3

Thread: php CreateAccountRequest via SOAP

  1. #1
    bookatechie is offline New Member
    Join Date
    May 2007
    Posts
    3
    Rep Power
    7

    Default php CreateAccountRequest via SOAP

    This is the correct soap request to create a new user

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra">
    <authToken>authToken goes here</authToken>
    </context>
    </soap:Header>
    <soap:Body>
    <CreateAccountRequest xmlns=\"urn:zimbraAdmin\">
    <name>test@mydomain.com</name>
    <password>myverystrongpassword</password>
    </CreateAccountRequest>
    </soap:Body>
    </soap:Envelope>

    I got a php page that will create this except the conetxt section with the authToken. This is what I got so far but it doesnt work.

    $soapHeader = new SoapHeader('urn:zimbra',
    'context',
    new Context(
    array(
    new SoapParam($authToken['authToken'], 'authToken'),
    )));

    $soapClient->__setSoapHeaders($soapHeader);


    This gives me the following error...

    Uncaught SoapFault exception: [soap:Client] no valid authtoken present

    Does anyone know what the correct php syntax is to create the content section?


    Thank you!

  2. #2
    Greg is offline Zimbra Employee
    Join Date
    Sep 2005
    Location
    Tucson - San Francisco - Moscow
    Posts
    127
    Rep Power
    9

    Default

    There are two problems with this example, first - CreateAccountRequest is in namespace zimbraAdmin, so

    <context xmlns="urn:zimbra">
    should be

    <context xmlns="urn:zimbraAdmin">

    consequently, this request requires admin Auth token, not client auth token, so your AuthRequest should also be in zimbraAdmin namespace.
    Bugzilla - Wiki - Downloads - Before posting... Search!
    P.S.: don't forget to vote on this bug
    add Samba LDAP entries to Exchange Migration Tool

  3. #3
    schemers is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    228
    Rep Power
    9

    Default

    actually, the <context> element is always in the "urn:zimbra" namespace.

    If you run:
    Code:
    zmprov -d createAccount {name} {password}
    You'll see the SOAP it sends:

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
      <soap:Header>
        <context xmlns="urn:zimbra">
          <authToken>...</authToken>
          <sessionId id="317">317</sessionId>
        </context>
      </soap:Header>
      <soap:Body>
        <CreateAccountRequest xmlns="urn:zimbraAdmin">
          <name>user9@slapshot.local</name>
          <password>test123</password>
        </CreateAccountRequest>
      </soap:Body>
    </soap:Envelope>
    Is it possible to dump the outgoing SOAP in PHP to compare? Another option is turn on debugging in the server.

    I do that by editing log4j.properties (/opt/zimbra/conf) and adding:

    Code:
    log4j.logger.zimbra.soap=DEBUG
    Then it should log every soap packet in/out of the server in the /opt/zimbra/log/mailbox.log file.
    Bugzilla - Wiki - Downloads - Before posting... Search!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Simple SOAP Admin Example In PHP
    By mikes2277 in forum Developers
    Replies: 11
    Last Post: 07-23-2011, 01:00 AM
  2. PHP SOAP vs Zimbra
    By Corey Scott in forum Developers
    Replies: 14
    Last Post: 02-05-2011, 04:41 AM
  3. PHP SOAP create appointment example
    By AddGun in forum Developers
    Replies: 13
    Last Post: 09-27-2010, 04:41 PM
  4. How to handle SOAP body response in PHP
    By ferdinant in forum Developers
    Replies: 1
    Last Post: 07-03-2007, 01:21 PM
  5. Problem with SOAP CreateAccountRequest
    By rtanner in forum Administrators
    Replies: 1
    Last Post: 04-21-2006, 06:18 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
  •