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 Display Modes
  #1 (permalink)  
Old 05-01-2007, 09:21 PM
New Member
 
Posts: 3
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!
Reply With Quote
  #2 (permalink)  
Old 05-02-2007, 11:52 AM
Zimbra Employee
 
Posts: 123
Default

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

Quote:
<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
Reply With Quote
  #3 (permalink)  
Old 05-02-2007, 12:28 PM
Zimbra Employee
 
Posts: 228
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!
Reply With Quote
Reply


Thread Tools
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.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0