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 01-21-2010, 10:57 AM
Member
 
Posts: 13
Default Zimbra, SOAP vb .net examples

I have searched the thread, but have not found any examples or hints on how to connecto to zimbra to do taskts like add mailbox/user or update passwords and such in visual basic.net

I have found the soap api, but, i cannot found any hints on how to implement it. For example, how do I authenticate towards the zimbra server as an admin.

Any help in the right direction would be great!
Reply With Quote
  #2 (permalink)  
Old 01-21-2010, 11:47 PM
Zimbra Employee
 
Posts: 105
Default

I can't speak to how to code .NET but I can speak in more general terms how to submit a request to the Zimbra SOAP interface. You should be able to take these guidelines and implement the .NET tech-specific calls (i.e. calling a web service, submitting XML to that service, etc, etc).

Note: A list of the SOAP request commands are found in ZimbraServer/docs/soap.txt and admin commands (like SetPasswordRequest) in soap-admin.txt

At a high-level, to use the Zimbra SOAP interface, you will POST a SOAP request to the Zimbra server SOAP interface. For example, for admin SOAP requests, submit the SOAP request to the admin SOAP interface at:

https://localhost:7071/service/admin/soap

A SOAP request format takes the XML form of:

Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
   ...auth info goes here...
  </soap:Header>
  <soap:Body>
  .... your request goes here...
  </soap:Body>
</soap:Envelope>
Let's walk thru the sequence of SOAP requests you will make in order to set a new password on an account:

1) Authenticate as an admin. There's an "AuthRequest" command for that. Here's what the full SOAP request would look like that you would submit to the SOAP interface:

Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
    <context xmlns="urn:zimbra">
      <nosession/>
    </context>
  </soap:Header>
  <soap:Body>
    <AuthRequest xmlns="urn:zimbraAdmin">
      <name>myadminname</name>
      <password>myadminpassword</password>
    </AuthRequest>
  </soap:Body>
</soap:Envelope>
2) The "AuthResponse" (from the above command) will include an auth token. You'll use that token for the subsequent SOAP requests so read the response and hold onto that token.

3) Now, the set password SOAP command requires you specify the account id. You can get this by making a "GetAccountInfoRequest" and grabbing the "zimbraId" from the response. A "GetAccountInfoRequest" for an account name "user1" looks like:

Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
    <context xmlns="urn:zimbra">
    <authToken>X_XXXXXXXXXXXX_XXXXXXXXXXX</authToken>
      <nosession/>
    </context>
  </soap:Header>
  <soap:Body>
    <GetAccountInfoRequest xmlns="urn:zimbraAdmin">
      <account by="name">user1</account>
    </GetAccountInfoRequest>
  </soap:Body>
</soap:Envelope>
Note: be sure to put the token from the auth into this request.

4) The response from this command has account info, including a "zimbraId". This is the account id. Read the response, hold onto that value...you'll need it next...

5) Now submit the "SetPasswordRequest" command:

Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
    <context xmlns="urn:zimbra">
    <authToken>X_XXXXXXXXXXXX_XXXXXXXXXXX</authToken>
      <nosession/>
    </context>
  </soap:Header>
  <soap:Body>
    <SetPasswordRequest xmlns="urn:zimbraAdmin">
      <id>XXX_XXXX_XXX_THE_ZIMBRA_ID_XXXXX</id>
      <newPassword>thenewpassword</newPassword>
    </SetPasswordRequest>
  </soap:Body>
</soap:Envelope>
Note: be sure to put the token from the auth command and the zimbraId from the previous command into this request.

6) And that's it. You've set the password for an account.
Reply With Quote
  #3 (permalink)  
Old 01-21-2010, 11:50 PM
Zimbra Employee
 
Posts: 105
Default

One more thing, there is also a ZmSoap utility included ZCS. You can submit SOAP commands to this utility and it will form the SOAP request and submit them to the server. Even if you plan to call SOAP from .NET, this is a useful utility to try-out commands. if you run it -v "verbose", you'll get the command syntax.

Zmsoap - Zimbra :: Wiki
Reply With Quote
  #4 (permalink)  
Old 01-22-2010, 01:18 AM
Member
 
Posts: 13
Default

Thankyou alot for this!! This is exactly the type of info I was looking for!
Reply With Quote
  #5 (permalink)  
Old 11-27-2010, 07:39 AM
Starter Member
 
Posts: 2
Default

Hi All,

I have a question: Where I can find ZmSoap utility to download?

Thnkyou, Pablo
Reply With Quote
  #6 (permalink)  
Old 11-27-2010, 07:53 AM
Zimbra Consultant & Moderator
 
Posts: 20,316
Default

Quote:
Originally Posted by PabloXenn View Post
I have a question: Where I can find ZmSoap utility to download?
You'll find it in the /opt/zimbra directory structure when you install Zimbra Collaboration Suite.
__________________
Regards


Bill
Reply With Quote
  #7 (permalink)  
Old 11-27-2010, 09:24 AM
Starter Member
 
Posts: 2
Default

Ah! ok... Thank you Bill!!
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.