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 03-19-2009, 09:53 AM
Member
 
Posts: 12
Angry [SOLVED] PHP error connection to Zimbra

Hi guys, i use this part of a class to connect to zimbra, but it always report an error... i try zmsoap to check soap is working ok and it works on localhost where the server is... but when we execute this class to connect to https://domain:7071/service/admin/soap it says can't connect to sever.
Any ideas?

Here's the code (extract of a functionally joomla integration for zimbra) :

class zimbraAdmin {
public $soapheader;
public $zimbra_error;
public $zimbra_errno;
public $zimbra_session;
public $zimbra_auth;
public $curlhandle;

public function zimbraAdmin($server) {

$this->curlhandle = curl_init();
curl_setopt($this->curlhandle, CURLOPT_URL, "https://$server:7071/service/admin/soap");
curl_setopt($this->curlhandle, CURLOPT_POST, TRUE);
curl_setopt($this->curlhandle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($this->curlhandle, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($this->curlhandle, CURLOPT_SSL_VERIFYHOST, TRUE);

}

public function set_zimbra_header() {
$this->soapheader = '<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<context xmlns="urn:zimbra"';
if ($this->zimbra_session != 0)
$this->soapheader .= '>
<authToken>' . $this->zimbra_auth . '</authToken>
<sessionId id="' . $this->zimbra_session . '">' . $this->zimbra_session . '</sessionId>
</context>';
else
$this->soapheader .= '/>';
$this->soapheader .= '
</soap:Header>
<soap:Body>
';
}

public function zimbra_login($adminuser, $adminpass)
{

$xml = new xml2Array();
$this->set_zimbra_header();
$soapmessage = $this->soapheader . '
<AuthRequest xmlns="urn:zimbraAdmin">
<name>' . $adminuser . '</name>
<password>' . $adminpass . '</password>
</AuthRequest>
</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']['AUTHRESPONSE']))
return false;
$x = $res['SOAP:ENVELOPE']['SOAP:BODY']['AUTHRESPONSE'];
$this->zimbra_session = $x['SESSIONID']['DATA'];
$this->zimbra_auth = $x['AUTHTOKEN']['DATA'];

return true;
}
}

$obj = new zimbraAdmin('192.123.321.1');
$obj->zimbra_login('admin@domain','pass');
print_r($obj);

Any comments would be apreciated
Reply With Quote
  #2 (permalink)  
Old 03-20-2009, 04:14 AM
Moderator
 
Posts: 7,928
Default

You posted in the Zimbra Desktop area so I moved it for you
__________________
Reply With Quote
  #3 (permalink)  
Old 03-20-2009, 08:35 AM
Member
 
Posts: 12
Default

Thanks Uxbod.

Ok, i solve the problem connecting via imap and managing the connection with the imap_open... in a further post i'll post the class file that i've implemented in my company so that it helps another user's who have the same initial problems.

In the soap access class i've rewrite it to php 5.

Reply With Quote
  #4 (permalink)  
Old 03-15-2010, 03:04 AM
Loyal Member
 
Posts: 92
Default

Quote:
Originally Posted by ajflorido View Post
Thanks Uxbod.

Ok, i solve the problem (..) in a further post i'll post the class file that i've implemented in my company so that it helps another user's who have the same initial problems.

In the soap access class i've rewrite it to php 5.

shall you please ?

thanks !
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.