[sork] Patch for lib/Drivers/ldap.php

Richard Heggs richard.heggs at nottinghamcity.gov.uk
Mon Dec 1 06:16:24 PST 2003


Hi List,

I'm trying to get accounts working with my Exim+LDAP installation, and I'm
having lots of fun.  Oh my, yes.

I've had to make a few changes to ldap.php (and I think there will be more
to come).  Here's a patch for the work I've done so far:

- Added more detailed comments at the top of the file, explaining each
option.
- Fixed a typo :)
- Renamed the functions (eg get_ -> get) to fit the naming convention of the
other drivers
- Added a 'version' parameter - PHP4 defaults to LDAP protocol 2, but newer
versions of OpenLDAP default to protocol 3, so it is necessary to set the
appropriate option befor calling ldap_bind().

Please consider applying to CVS.  There will probably be a couple more
patches to come.

--
Richard Heggs
Systems Analyst
Nottingham City Council

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

######################################################################
This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of Nottingham City Council unless specifically
stated. If you have received it in error, please delete it from your system,
do not use, copy or disclose the information in any way nor act in reliance
on it and notify the sender immediately. Please note that Nottingham City
Council monitors e-mails sent or received. Further communication will
signify your consent to this.
######################################################################
-------------- next part --------------
Index: ldap.php
===================================================================
RCS file: /var/rsync-horde/vacation/lib/Driver/ldap.php,v
retrieving revision 1.2
diff -u -r1.2 ldap.php
--- ldap.php	3 Oct 2003 19:16:18 -0000	1.2
+++ ldap.php	1 Dec 2003 12:44:40 -0000
@@ -7,8 +7,22 @@
  * See the enclosed file LICENSE for license information (BSD). If you
  * did not receive this file, see http://www.horde.org/bsdl.php.
  *
- * Vacation_Driver_forwards:: implements the Vacation_Driver API for ftp driven
- * dot-forward compliant mail servers.
+ * Vacation_Driver_ldap:: implements the Vacation_Driver API for LDAP-compliant
+ * mail servers (such as Exim).
+ *
+ * Parameters:
+ * (required)
+ *   host       - hostname of the LDAP server
+ *   port       - port number of the LDAP service
+ *   basedn     - base DN of the user directory
+ *   uid        - attribute to use for uid
+ *   vacation   - attribute to use for storing the vacation message
+ * (optional)
+ *   userdn     - another way of specifying the user DN (instead of
+ *                constructing it from uid+basedn).
+ *   version    - Protocol version for the LDAP server (PHP defaults
+ *                to version 2. OpenLDAP >= 2.1.4 uses version 3, and
+ *                so must be set explicitly).
  *
  * @author  Eric Rostetter <eric.rostetter at physics.utexas.edu>
  * @version $Revision: 1.2 $
@@ -50,6 +64,10 @@
         if (!$this->_ds) {
             return PEAR::raiseError(_("Could not connect to ldap server"));
         }
+        if (array_key_exists('version', $this->_params[$realm])) {
+             ldap_set_option($this->_ds, LDAP_OPT_PROTOCOL_VERSION,
+					$this->_params[$realm]['version']);
+        }
 
         if (!is_null($userdn)) {
             $result = @ldap_bind($this->_ds, $userdn, $password);
@@ -142,7 +160,7 @@
      * @param string    $target     The message to install.
      * @return boolean  Returns true on success, false on error.
      */
-    function set_vacation($user, $realm, $pass, $message)
+    function setVacation($user, $realm, $pass, $message)
     {
         // Make sure the configuration file is correct
         if (!$this->check_config($realm)) {
@@ -164,7 +182,7 @@
         if (PEAR::isError($res)) {
             $this->_disconnect();
             if ($res->getMessage() == _("Could not bind to ldap server")) {
-                return PEAR::raiseError(_("Incorect Password"));
+                return PEAR::raiseError(_("Incorrect Password"));
             }
             return $res;
         }
@@ -187,7 +205,7 @@
         return true;
     }
 
-    function get_vacation($realm = 'default', $user, $pass)
+    function getVacation($realm = 'default', $user, $pass)
     {
         // Make sure the configuration file is correct
         if (!$this->check_config($realm)) {
@@ -249,7 +267,7 @@
      *
      * @return boolean  Returns true on success, false on error.
      */
-    function unset_vacation($user, $realm, $pass)
+    function unsetVacation($user, $realm, $pass)
     {
         // Make sure the configuration file is correct
         if (!$this->check_config($realm)) {


More information about the sork mailing list