Hello

I'm looking for how to empty a calendar ccurate user specific whitj SOAP from a Web server

This is my php script

Code:
<?PHP
        $ServerAddress          = "192.168.1.243";
        $AdminUserName          = "calendriers.externes@domain.fr";
        $AdminPassword          = "cpassword";
	//$AdminUserName          = "admin";
        //$AdminPassword          = "password";

        $NewUserName            = "mynewaccount@mydomain.com";
        $NewUserPassword        = "mynewpassoword";
        $COSId                  = "f070eede-c0c5-4867-a158-1f35f1c39e15";

        // To get your COSId for COS defualt or any other COS (I left mine in there as an example):
        // zmprov getCos default | grep "zimbraId:" from the command line

        //if(($ZimbraSOAPResponse = ZimbraAdminEmptyCalendar(1, $ServerAddress, $AdminUserName, $AdminPassword, $NewUserName, $NewUserPassword, $COSId)) == FALSE)
		if(($ZimbraSOAPResponse = ZimbraAdminEmptyCalendar(1, $ServerAddress, $AdminUserName, $AdminPassword)) == FALSE)
        {
                printf("ZimbraAdminEmptyCalendar Failed!<BR>\n");
                return(FALSE);
        }

        print("ZimbraAdminEmptyCalendar response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");
?>

<?PHP

// -------------------------------------------------------------------

function ZimbraAdminEmptyCalendar($Trace, $ServerAddress, $AdminUserName, $AdminPassword)
{
        $CurlHandle = curl_init();
        //curl_setopt($CurlHandle, CURLOPT_URL,           "https://$ServerAddress:7071/service/admin/soap");
        //curl_setopt($CurlHandle, CURLOPT_URL,           "https://$ServerAddress/home/calendriers.externes@domain.fr");
	curl_setopt($CurlHandle, CURLOPT_URL,           "https://$ServerAddress/service/soap/");
	curl_setopt($CurlHandle, CURLOPT_POST,           TRUE);
        curl_setopt($CurlHandle, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYHOST, FALSE);

        // ------ Send the zimbraAdmin AuthRequest -----

        $SOAPMessage  = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra"/>
                                </soap:Header>
                                <soap:Body>
                                        <AuthRequest xmlns="urn:zimbraAdmin">
                                                <name>' . $AdminUserName . '</name>
                                                <password>' . $AdminPassword . '</password>
                                        </AuthRequest>
                                </soap:Body>
                        </soap:Envelope>';

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        // Parse for the sessionId
        // <sessionId type="admin" id="123">123</sessionId>
        $sessionId = strstr($ZimbraSOAPResponse, "<sessionId");
        $sessionId = strstr($sessionId, ">");
        $sessionId = substr($sessionId, 1, strpos($sessionId, "<") - 1);
        // print("sessionId = $sessionId<BR>\n");

        // Parse for the authToken
        // <authToken>123</authToken>
        $authToken = strstr($ZimbraSOAPResponse, "<authToken");
        $authToken = strstr($authToken, ">");
        $authToken = substr($authToken, 1, strpos($authToken, "<") - 1);
        // print("authToken = $authToken<BR>\n");


        // ------ Send the zimbraCreateAccount request -----
        $SOAPMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra">
                                                <authToken>' . $authToken . '</authToken>
                                                <sessionId id="' . $sessionId . '">' . $sessionId . '</sessionId>
                                        </context>
                                </soap:Header>
                                <soap:Body>
					
					<FolderActionRequest xmlns="urn:zimbraMail">
  					<action id="360" op="empty" recursive="false"/>
					</FolderActionRequest>	
					
					<FolderActionResponse xmlns="urn:zimbraMail">
					 <action op="empty" id="360"></action>
					</FolderActionResponse>
					
                                </soap:Body>
                        </soap:Envelope>';
						
                                        //<CreateAccountRequest xmlns="urn:zimbraAdmin">
                                        //        <name>' . $NewUserName . '</name>
                                        //        <password>' . $NewUserPassword . '</password>
                                        //        <a n="zimbraCOSId">' . $COSId . '</a>
                                        //</CreateAccountRequest>						

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        return($ZimbraSOAPResponse);
}

function ZimbraAdminCreateAccount($Trace, $ServerAddress, $AdminUserName, $AdminPassword, $NewUserName, $NewPassword, $COSId)
{
        $CurlHandle = curl_init();
        curl_setopt($CurlHandle, CURLOPT_URL,           "https://$ServerAddress:7071/service/admin/soap");
        curl_setopt($CurlHandle, CURLOPT_POST,           TRUE);
        curl_setopt($CurlHandle, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYHOST, FALSE);

        // ------ Send the zimbraAdmin AuthRequest -----

        $SOAPMessage  = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra"/>
                                </soap:Header>
                                <soap:Body>
                                        <AuthRequest xmlns="urn:zimbraAdmin">
                                                <name>' . $AdminUserName . '</name>
                                                <password>' . $AdminPassword . '</password>
                                        </AuthRequest>
                                </soap:Body>
                        </soap:Envelope>';

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        // Parse for the sessionId
        // <sessionId type="admin" id="123">123</sessionId>
        $sessionId = strstr($ZimbraSOAPResponse, "<sessionId");
        $sessionId = strstr($sessionId, ">");
        $sessionId = substr($sessionId, 1, strpos($sessionId, "<") - 1);
        // print("sessionId = $sessionId<BR>\n");

        // Parse for the authToken
        // <authToken>123</authToken>
        $authToken = strstr($ZimbraSOAPResponse, "<authToken");
        $authToken = strstr($authToken, ">");
        $authToken = substr($authToken, 1, strpos($authToken, "<") - 1);
        // print("authToken = $authToken<BR>\n");


        // ------ Send the zimbraCreateAccount request -----
        $SOAPMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra">
                                                <authToken>' . $authToken . '</authToken>
                                                <sessionId id="' . $sessionId . '">' . $sessionId . '</sessionId>
                                        </context>
                                </soap:Header>
                                <soap:Body>
                                        <CreateAccountRequest xmlns="urn:zimbraAdmin">
                                                <name>' . $NewUserName . '</name>
                                                <password>' . $NewUserPassword . '</password>
                                                <a n="zimbraCOSId">' . $COSId . '</a>
                                        </CreateAccountRequest>
                                </soap:Body>
                        </soap:Envelope>';

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        return($ZimbraSOAPResponse);
}

function ZimbraAdminDeleteAccount($Trace, $ServerAddress, $AdminUserName, $AdminPassword, $DeleteUserName)
{
        $CurlHandle = curl_init();
        curl_setopt($CurlHandle, CURLOPT_URL,           "https://$ServerAddress:7071/service/admin/soap");
        curl_setopt($CurlHandle, CURLOPT_POST,           TRUE);
        curl_setopt($CurlHandle, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYHOST, FALSE);

        // ------ Send the zimbraAdmin AuthRequest -----

        $SOAPMessage  = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra"/>
                                </soap:Header>
                                <soap:Body>
                                        <AuthRequest xmlns="urn:zimbraAdmin">
                                                <name>' . $AdminUserName . '</name>
                                                <password>' . $AdminPassword . '</password>
                                        </AuthRequest>
                                </soap:Body>
                        </soap:Envelope>';

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        // Parse for the sessionId
        // <sessionId type="admin" id="123">123</sessionId>
        $sessionId = strstr($ZimbraSOAPResponse, "<sessionId");
        $sessionId = strstr($sessionId, ">");
        $sessionId = substr($sessionId, 1, strpos($sessionId, "<") - 1);
        // print("sessionId = $sessionId<BR>\n");

        // Parse for the authToken
        // <authToken>123</authToken>
        $authToken = strstr($ZimbraSOAPResponse, "<authToken");
        $authToken = strstr($authToken, ">");
        $authToken = substr($authToken, 1, strpos($authToken, "<") - 1);
        // print("authToken = $authToken<BR>\n");


        // ------ Send the GetAccountRequest request -----
        $SOAPMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra">
                                                <authToken>' . $authToken . '</authToken>
                                                <sessionId id="' . $sessionId . '">' . $sessionId . '</sessionId>
                                        </context>
                                </soap:Header>
                                <soap:Body>
                                        <GetAccountRequest xmlns="urn:zimbraAdmin">
                                                <account by="name">' . $DeleteUserName . '</account>
                                        </GetAccountRequest>
                                </soap:Body>
                        </soap:Envelope>';

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        // Parse for zimbraId
        // <a n="zimbraId">0ffaa258-048f-47f2-9efd-5901f2fd6913</a>
        $zimbraId = strstr($ZimbraSOAPResponse, "<a n=\"zimbraId\"");
        $zimbraId = strstr($zimbraId, ">");
        $zimbraId = substr($zimbraId, 1, strpos($zimbraId, "<") - 1);
        // print("zimbraId = $zimbraId<BR>\n");
        // Check if we got a zimbraId
        if($zimbraId == "")
        {
                // No zimbraId found!  This usually means that the account is not found.  You can parse the message if you really want to know
                // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");
                return(FALSE);
        }

        // ------ Send the zimbraCreateAccount request -----
        $SOAPMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                                <soap:Header>
                                        <context xmlns="urn:zimbra">
                                                <authToken>' . $authToken . '</authToken>
                                                <sessionId id="' . $sessionId . '">' . $sessionId . '</sessionId>
                                        </context>
                                </soap:Header>
                                <soap:Body>
                                        <DeleteAccountRequest xmlns="urn:zimbraAdmin">
                                                <id>' . $zimbraId . '</id>
                                        </DeleteAccountRequest>
                                </soap:Body>
                        </soap:Envelope>';

        curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

        if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
        {
                print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
                return(FALSE);
        }

        // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

        return($ZimbraSOAPResponse);
}
?>
Avec ce genre ce script si mon authentification de fait avec l'admin j'arrive bien à vider un calendar mais dans le mailbox de l'admin
Je ne comprend pas commend le faire sur d'autre comptes...

If i am authenticate whith admin account i can emptying calendar but only in admin account
I cannot authenticate with user that i want emptying calendar


Code:
ZimbraAdminEmptyCalendar response:<BR>&lt;soap:Envelope xmlns:soap=&quot;http://www.w3.org/2003/05/soap-envelope&quot;&gt;&lt;soap:Header&gt;&lt;context xmlns=&quot;urn:zimbra&quot;/&gt;&lt;/soap:Header&gt;&lt;soap:Body&gt;&lt;soap:Fault&gt;&lt;soap:Code&gt;&lt;soap:Value&gt;soap:Sender&lt;/soap:Value&gt;&lt;/soap:Code&gt;&lt;soap:Reason&gt;&lt;soap:Text&gt;no valid authtoken present&lt;/soap:Text&gt;&lt;/soap:Reason&gt;&lt;soap:Detail&gt;&lt;Error xmlns=&quot;urn:zimbra&quot;&gt;&lt;Code&gt;service.AUTH_REQUIRED&lt;/Code&gt;&lt;Trace&gt;com.zimbra.common.service.ServiceException: no valid authtoken present
ExceptionId:btpool0-25://192.168.1.243/service/soap/:1321979347377:8d56917213a85d83:SoapEngine287
Code:service.AUTH_REQUIRED
	at com.zimbra.common.service.ServiceException.AUTH_REQUIRED(ServiceException.java:296)
	at com.zimbra.soap.SoapEngine.dispatchRequest(SoapEngine.java:355)
	at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.java:287)
	at com.zimbra.soap.SoapEngine.dispatch(SoapEngine.java:158)
	at com.zimbra.soap.SoapServlet.doWork(SoapServlet.java:294)
	at com.zimbra.soap.SoapServlet.doPost(SoapServlet.java:215)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
	at com.zimbra.cs.servlet.ZimbraServlet.service(ZimbraServlet.java:208)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:814)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at com.zimbra.cs.servlet.SetHeaderFilter.doFilter(SetHeaderFilter.java:79)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:81)
	at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter.java:155)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:218)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:422)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.handler.rewrite.RewriteHandler.handle(RewriteHandler.java:230)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.handler.DebugHandler.handle(DebugHandler.java:77)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:585)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:988)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:415)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:429)
	at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:451)
&lt;/Trace&gt;&lt;/Error&gt;&lt;/soap:Detail&gt;&lt;/soap:Fault&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;<BR><BR>
How can i emptying calendar of an other account than administrator