Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

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 10-31-2008, 08:11 AM
Project Contributor
 
Posts: 14
Exclamation Acces to quotas information through SOAP

hello,

i'm in the way of creation a php interface to zimbra.
I user this class:
[SOLVED] PHP Class for easy access to Zimbra SOAP API

First i really don't know how to see the space that used for user, in the admin interface or with soap request...
Second when i apply a quota of 150Mb of a user, when i get result in soap or ldap the result is zimbraMailQuota = 157286400 ...so 157MB do you know why ?

thanks,
Syruis.
Reply With Quote
  #2 (permalink)  
Old 10-31-2008, 08:28 AM
Project Contributor
 
Posts: 14
Question

For the problème with 150&157, i have see the problem it since the size of a space disk is 1Mo = 1024 o..

But I don't know where i can see the size of a emailbox...

Rgds,
Reply With Quote
  #3 (permalink)  
Old 10-31-2008, 09:58 AM
Moderator
 
Posts: 6,237
Default

He does have it included in the php class - zimbraAdmin.php:
Code:
<GetQuotaUsageRequest xmlns="urn:zimbraAdmin"';
if ($limit != 0)
  $soapmessage .= ' limit=\"$limit\"';
if ($offset != 0)
  $soapmessage .= ' offset=\"$offset\"';
if ($domain != "")
  $soapmessage .= ' domain=\"$domain\"';
if ($sort != "")
  $soapmessage .= ' sortBy=\"$sort\"';
if ($sortAsc != "")
  $soapmessage .= ' sortAscending=\"$sortAsc\"';
$soapmessage .= '>
</GetQuotaUsageRequest>
soap-admin.txt
Code:
<GetQuotaUsageRequest [limit="..."] [offset="..."] [domain="{limit-to-domain}"]  
         [sortBy="{sort-by}"] [sortAscending="{sort-ascending}"]]> 
</GetQuotaUsageRequest> 
 
<GetQuotaUsageResponse more="{more-flag}" [searchTotal="{search-total}"]> 
  <account name="{name}" id="{id}" used="quota-used" limit="quota-limit"/>+ 
</GetQuotaUsageResponse> 
 
Notes: 
GetQuotaUsageRequest 
  limit - the number of accounts to return (0 is default and means all) 
  offset - the starting offset (0, 25, etc) 
  domain - the domain name to limit the search to 
  sortBy - valid values: "percentUsed", "totalUsed", "quotaLimit" 
  sortAscending - whether to sort in ascending order (0/1), 0 is default, so highest quotas are returned first 
  more-flag = true if more accounts left to return 
  search-total = total number of accounts that matched search (not affected by limit/offset) 
  used = used quota in bytes, or 0 if no quota used 
  limit = quota limit in bytes, or 0 if unlimited 
 
The target server should be specified in the soap header (see soap.txt, <targetServer>). 
 
When sorting by "quotaLimit", 0 is treated as the highest value possible.
Admin console:
Server Statistics > Server > Mailbox Quota tab

CLI:
zmprov GetQuotaUsage localhost
Spits it out in bytes- second column is max quota (0=unlimited) third column will be used amount

Could do something like:
zmprov gqu `zmhostname` | awk {'print " "$3" "$2" "$1'}
Reply With Quote
  #4 (permalink)  
Old 11-03-2008, 12:18 AM
Project Contributor
 
Posts: 14
Exclamation

Quote:
Originally Posted by mmorse View Post
He does have it included in the php class - zimbraAdmin.php:
Code:
<GetQuotaUsageRequest xmlns="urn:zimbraAdmin"';
if ($limit != 0)
  $soapmessage .= ' limit=\"$limit\"';
if ($offset != 0)
  $soapmessage .= ' offset=\"$offset\"';
if ($domain != "")
  $soapmessage .= ' domain=\"$domain\"';
if ($sort != "")
  $soapmessage .= ' sortBy=\"$sort\"';
if ($sortAsc != "")
  $soapmessage .= ' sortAscending=\"$sortAsc\"';
$soapmessage .= '>
</GetQuotaUsageRequest>
soap-admin.txt
Code:
<GetQuotaUsageRequest [limit="..."] [offset="..."] [domain="{limit-to-domain}"]  
         [sortBy="{sort-by}"] [sortAscending="{sort-ascending}"]]> 
</GetQuotaUsageRequest> 
 
<GetQuotaUsageResponse more="{more-flag}" [searchTotal="{search-total}"]> 
  <account name="{name}" id="{id}" used="quota-used" limit="quota-limit"/>+ 
</GetQuotaUsageResponse> 
 
Notes: 
GetQuotaUsageRequest 
  limit - the number of accounts to return (0 is default and means all) 
  offset - the starting offset (0, 25, etc) 
  domain - the domain name to limit the search to 
  sortBy - valid values: "percentUsed", "totalUsed", "quotaLimit" 
  sortAscending - whether to sort in ascending order (0/1), 0 is default, so highest quotas are returned first 
  more-flag = true if more accounts left to return 
  search-total = total number of accounts that matched search (not affected by limit/offset) 
  used = used quota in bytes, or 0 if no quota used 
  limit = quota limit in bytes, or 0 if unlimited 
 
The target server should be specified in the soap header (see soap.txt, <targetServer>). 
 
When sorting by "quotaLimit", 0 is treated as the highest value possible.
Admin console:
Server Statistics > Server > Mailbox Quota tab

CLI:
zmprov GetQuotaUsage localhost
Spits it out in bytes- second column is max quota (0=unlimited) third column will be used amount

Could do something like:
zmprov gqu `zmhostname` | awk {'print " "$3" "$2" "$1'}
I have see. But it's really doesn't work. the function "zimbra_get_cos" "zimbra_get_current_volumes" is bug too.

I have modify many "function"... like "zimbra_search_gal" but for this one, i haven"t show where is the problem.

Syruis.

Last edited by Syruis; 11-03-2008 at 12:22 AM..
Reply With Quote
  #5 (permalink)  
Old 11-03-2008, 12:44 AM
Moderator
 
Posts: 2,207
Default

I renamed the thread, in order to show the real problem (SOAP and quota).
Reply With Quote
  #6 (permalink)  
Old 11-03-2008, 12:45 AM
Project Contributor
 
Posts: 14
Default

Example1:
"zimbra_get_cos" always return:
3128soap:Senderno such cos: test@test.fraccount.NO_SUCH_COSbtpool0-9:1225702223229:a64b3cc9eef60d95
Reply With Quote
  #7 (permalink)  
Old 11-03-2008, 12:45 AM
Project Contributor
 
Posts: 14
Default

Quote:
Originally Posted by Klug View Post
I renamed the thread, in order to show the real problem (SOAP and quota).
Ok thanks...
Reply With Quote
  #8 (permalink)  
Old 11-03-2008, 01:20 AM
Project Contributor
 
Posts: 14
Default

Quote:
Originally Posted by Syruis View Post
Example1:
"zimbra_get_cos" always return:
3128soap:Senderno such cos: test@test.fraccount.NO_SUCH_COSbtpool0-9:1225702223229:a64b3cc9eef60d95
zimbra_get_quota_usage(0,0,"testdomain.com","","") ; =>

soap:Senderparse error: Error on line 11 of document : Open quote is expected for attribute "domain" associated with an element type "GetQuotaUsageRequest". Nested exception: Open quote is expected for attribute "domain" associated with an element type "GetQuotaUsageRequest".service.PARSE_ERRORbtpo ol0-9:1225703586774:a64b3cc9eef60d9

So i do:
// if ($domain != "")
// $soapmessage .= ' domain=\"'.$domain.'\"';

And it return "3132" ... "3133" ... "3134" .. etc ( and it have no signification for me ) does anyone knows why?

..
Excuse my poor English it's not my matern language...

Last edited by Syruis; 11-03-2008 at 01:57 AM..
Reply With Quote
  #9 (permalink)  
Old 11-04-2008, 03:13 AM
Project Contributor
 
Posts: 14
Exclamation

Solution.. for get a quota for a mail Call:
Code:
$val=$zim->zimbra_get_quota_usage($limit = 0, $offset = 0,$domain, $sort = "", $sortAsc = "");//retourne tous les quota du domaine

		if (!$val)//DEBUG
			return array(0 => 'return false xml error');
		
		$taille = sizeof($val['ACCOUNT']);$i=0;
		while($i != $taille){
			if (trim($val['ACCOUNT'][$i]['NAME']) == trim($email))
				return $val['ACCOUNT'][$i];
				
			$i++;
			
		}
		return array(0 => 'return false no account for this email ('.$email.')');
And modification in ZimbraAdmin.php
Code:
function zimbra_get_quota_usage($limit = 0, $offset = 0, $domain = "", $sort = "", $sortAsc = "") {

		$xml = new xml2Array();
		$this->set_zimbra_header();
		$soapmessage = $this->soapheader . '
		<GetQuotaUsageRequest xmlns="urn:zimbraAdmin"';
		if ($limit != 0)
			$soapmessage .= ' limit=\"'.$limit.'\"';
		if ($offset != 0)
			$soapmessage .= ' offset=\"$offset\"';
//	if ($domain != "")
			$soapmessage .= ' domain="'.$domain.'"';
		if ($sort != "")
			$soapmessage .= ' sortBy=\"$sort\"';
		if ($sortAsc != "")
			$soapmessage .= ' sortAscending=\"$sortAsc\"';
		$soapmessage .= '>' .
				'
		</GetQuotaUsageRequest>
		</soap:Body>
		</soap:Envelope>';
		curl_setopt($this->curlhandle, CURLOPT_POSTFIELDS, $soapmessage);
		if (!($zimbraSOAPResponse = curl_exec($this->curlhandle))) {
			$this->zimbraerrno = curl_errno($this->curlhandle);
			$this->zimbraerror = curl_error($this->curlhandle);
			return false;
		}
		$res = $xml->parse($zimbraSOAPResponse);
		if (isset ($res['SOAP:ENVELOPE']['SOAP:BODY']['GETQUOTAUSAGERESPONSE']))
			return $res['SOAP:ENVELOPE']['SOAP:BODY']['GETQUOTAUSAGERESPONSE'];
		return false;
	}
Thanks for all,
regards
Reply With Quote
  #10 (permalink)  
Old 10-22-2009, 05:34 PM
Member
 
Posts: 10
Default new xml2Array()

can you post the code for this one
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.