Results 1 to 7 of 7

Thread: Zimbra, SOAP vb .net examples

  1. #1
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    6

    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!

  2. #2
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    6

    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.

  3. #3
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    6

    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

  4. #4
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    6

    Default

    Thankyou alot for this!! This is exactly the type of info I was looking for!

  5. #5
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    5

    Default

    Hi All,

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

    Thnkyou, Pablo

  6. #6
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,587
    Rep Power
    58

    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


    Acompli: A new adventure for Co-Founder KevinH.

  7. #7
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    5

    Default

    Ah! ok... Thank you Bill!!

Similar Threads

  1. Recover the mail after the crash HDD
    By MrSnaKe in forum Administrators
    Replies: 3
    Last Post: 12-02-2009, 04:38 AM
  2. zimbra install with perpetually broken logger/stats
    By jptech in forum Installation
    Replies: 8
    Last Post: 09-29-2008, 03:33 PM
  3. Replies: 12
    Last Post: 02-25-2008, 07:28 PM
  4. 4.5 Upgrade failure
    By brained in forum Installation
    Replies: 9
    Last Post: 03-03-2007, 03:30 PM
  5. dspam logrotate errors
    By michaeln in forum Users
    Replies: 7
    Last Post: 02-19-2007, 12:45 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
  •