From 7c60ffbdaa8df2a4938ca0fb64a2fac79ba96fb6 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 10 Jun 2009 14:01:16 -0400
Subject: [PATCH] - fix email address pattern for some addresses
---
program/include/rcube_ldap.php | 59 +++++++++++++++++++++--------------------------------------
1 files changed, 21 insertions(+), 38 deletions(-)
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index bbbff46..8e035c5 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -4,7 +4,7 @@
| program/include/rcube_ldap.php |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -24,7 +24,7 @@
*
* @package Addressbook
*/
-class rcube_ldap
+class rcube_ldap extends rcube_addressbook
{
var $conn;
var $prop = array();
@@ -68,8 +68,10 @@
*/
function connect()
{
+ global $RCMAIL;
+
if (!function_exists('ldap_connect'))
- raise_error(array('type' => 'ldap', 'message' => "No ldap support in this installation of PHP"), true);
+ raise_error(array('code' => 100, 'type' => 'ldap', 'message' => "No ldap support in this installation of PHP"), true);
if (is_resource($this->conn))
return true;
@@ -99,47 +101,28 @@
{
$this->ready = true;
+ // User specific access, generate the proper values to use.
if ($this->prop["user_specific"]) {
- // User specific access, generate the proper values to use.
- global $CONFIG, $RCMAIL;
+ // No password set, use the session password
if (empty($this->prop['bind_pass'])) {
- // No password set, use the users.
- $this->prop['bind_pass'] = $RCMAIL->decrypt_passwd($_SESSION["password"]);
- } // end if
+ $this->prop['bind_pass'] = $RCMAIL->decrypt($_SESSION['password']);
+ }
// Get the pieces needed for variable replacement.
- // See if the logged in username has an "@" in it.
- if (is_bool(strstr($_SESSION["username"], "@"))) {
- // It does not, use the global default.
- $fu = $_SESSION["username"]."@".$CONFIG["username_domain"];
- $u = $_SESSION["username"];
- $d = $CONFIG["username_domain"];
- } // end if
- else {
- // It does.
- $fu = $_SESSION["username"];
- // Get the pieces needed for username and domain.
- list($u, $d) = explode("@", $_SESSION["username"]);
- } # end else
-
- // Replace the bind_dn variables.
- $bind_dn = str_replace(array("%fu", "%u", "%d"),
- array($fu, $u, $d),
- $this->prop['bind_dn']);
- $this->prop['bind_dn'] = $bind_dn;
- // Replace the base_dn variables.
- $base_dn = str_replace(array("%fu", "%u", "%d"),
- array($fu, $u, $d),
- $this->prop['base_dn']);
- $this->prop['base_dn'] = $base_dn;
-
- $this->ready = $this->bind($this->prop['bind_dn'], $this->prop['bind_pass']);
- } // end if
- elseif (!empty($this->prop['bind_dn']) && !empty($this->prop['bind_pass']))
+ $fu = $RCMAIL->user->get_username();
+ list($u, $d) = explode('@', $fu);
+
+ // Replace the bind_dn and base_dn variables.
+ $replaces = array('%fu' => $fu, '%u' => $u, '%d' => $d);
+ $this->prop['bind_dn'] = strtr($this->prop['bind_dn'], $replaces);
+ $this->prop['base_dn'] = strtr($this->prop['base_dn'], $replaces);
+ }
+
+ if (!empty($this->prop['bind_dn']) && !empty($this->prop['bind_pass']))
$this->ready = $this->bind($this->prop['bind_dn'], $this->prop['bind_pass']);
}
else
- raise_error(array('type' => 'ldap', 'message' => "Could not connect to any LDAP server, tried $host:{$this->prop[port]} last"), true);
+ raise_error(array('code' => 100, 'type' => 'ldap', 'message' => "Could not connect to any LDAP server, tried $host:{$this->prop[port]} last"), true);
// See if the directory is writeable.
if ($this->prop['writable']) {
@@ -256,7 +239,7 @@
function list_records($cols=null, $subset=0)
{
// add general filter to query
- if (!empty($this->prop['filter']))
+ if (!empty($this->prop['filter']) && empty($this->filter))
{
$filter = $this->prop['filter'];
$this->set_search_set($filter);
--
Gitblit v1.9.1