Re: [PATCH] Auth + Imap
| From: | Jeroen Houben | Date: | Mon, 25 Aug 2003 07:58:07 +0000 |
| Subject: | Re: [PATCH] Auth + Imap | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20487@lists.php.net to get a copy of this message | ||
Cipriano Groenendal wrote:
Hello. After I saw someone request the ability for Auth_Imap to handle SSL connections, something I'd be needing too in the near future, I created this patch to the current IMAP.php included with the Auth package. It also has a new option added to disable server-connection-checking. In my case, this behaviour c reated quite a many entries into my IMAP-server-logs, since the connection is made even when the connection isn't checked. While this may be desirable in some cases, in others like mine, it's not. Below you'll find the patch I generated. Let me know if you'd rather have it in an attachment or via some other way :) Cipriano Groenendal diff -Nabur Container.org/IMAP.php Container/IMAP.phpIt looks fine to me. I'd probably change $this->options['checkServer'] = 1; to $this->options['checkServer'] = true; I don't have CVS access, so you would have to ask the current maintainer of the Auth package to apply the patch. Jeroen--- Container.org/IMAP.php 2003-08-23 12:16:11.000000000 +0200+++ Container/IMAP.php 2003-08-23 12:59:23.000000000 +0200 @@ -28,8 +28,11 @@ * This class is based on LDAP containers, but it very simple. * By default it connects to localhost:143 * The constructor will first check if the host:port combination is - * actually reachable. + * actually reachable. This behaviour can be disabled. * It then tries to create an IMAP stream (without opening a mailbox) + * If you wish to pass extended options to the connections, you may + * do so with a specific baseDSN. + * * To use this storage containers, you have to use the * following syntax: * @@ -42,9 +45,23 @@ * $myAuth = new Auth('IMAP', $params); * .... * + * By default we connect without any options set. However, some servers + * require you to connect with the notls or norsh options set. + * To do this you need to add the following value to the params array: + * 'baseDSN' => '/imap/notls/norsh' + * To connect to an SSL IMAP server: + * 'baseDSN' => '/imap/ssl' + * To connect to an SSL IMAP server with a self-signed certificate: + * 'baseDSN' => '/imap/ssl/novalidate-cert' + * + * Further options may be available and can be found on the php site at + * http://www.php.net/manual/function.imap-open.php + * + */ + /** * - * @author Jeroen Houben <jeroen@terena.nl> + * @author Jeroen Houben <jeroen@terena.nl>, Cipriano Groenendal <cipri@campai.nl> * @package Auth * @version $Revision: 1.4 $ */ @@ -59,7 +76,7 @@/** * Constructor of the container class * - * @param $params, associative hash with host,port,basedn and userattrkey+ * @param $params, associative array withhost,port,baseDSN,checkServer key* @return object Returns an error object if something went wrong */ function Auth_Container_IMAP($params)@@ -75,7 +92,9 @@$this->_parseOptions($params); }+ if ($this->options['checkServer']) { $this->_checkServer(); + } return true; }@@ -88,6 +107,8 @@{ $this->options['host'] = 'localhost'; $this->options['port'] = 143; + $this->options['baseDSN'] = ''; + $this->options['checkServer'] = 1; }@@ -131,8 +152,9 @@*/ function fetchData($username, $password) { - $conn = @imap_open('{'.$this->options['host'].':'.$this->options['port'].'}', $username, $password, OP_HALFOPEN);- if ($conn) { + $dsn ='{'.$this->options['host'].':'.$this->options['port'].$this->options['baseDS N'].'}';+ $conn = @imap_open ($dsn, $username, $password, OP_HALFOPEN); + if (is_resource($conn)) { $this->activeUser = $username; @imap_close($conn); return true;Hi,