*** ldap.php.userdn	2010-02-02 13:25:24.000000000 +0100
--- ldap.php	2010-02-02 14:00:32.000000000 +0100
***************
*** 673,686 ****
                  return PEAR::raiseError($success->getMessage());
              }
  
-             // Set up search filter
-             $filter = '(' . $this->_params['memberuid'] . '=';
              if ($GLOBALS['conf']['group']['params']['attrisdn']) {
!                 $filter .= $GLOBALS['conf']['auth']['params']['uid'] . '=';
              }
!             $filter .= $user;
              if ($GLOBALS['conf']['group']['params']['attrisdn']) {
!                 $filter .= ',' . $GLOBALS['conf']['auth']['params']['basedn'];
              } 
              $filter .= ')';
  
--- 673,711 ----
                  return PEAR::raiseError($success->getMessage());
              }
  
              if ($GLOBALS['conf']['group']['params']['attrisdn']) {
!                $filter = '(' . $GLOBALS['conf']['auth']['params']['uid'] . '=' . $user . ')';
! 
!                $search = @ldap_search($this->_ds, $GLOBALS['conf']['auth']['params']['basedn'], $filter);
! 
!                if (@ldap_count_entries($this->_ds, $search) != 1) {
!                   return PEAR::raiseError(sprintf(_("Expected 1 object, got %d."),
!                                             ldap_count_entries($ldapcn, $search)));
!                }
!                $ent = @ldap_first_entry($this->_ds, $search);
!                if ($ent === false) {
!                   return PEAR::raiseError(sprintf(_("Error retrieving current script: (%d) %s"),
!                                             ldap_errno($ldapcn),
!                                             ldap_error($ldapcn)));
!                }
! 
!               /* Retrieve the user's DN. */
!               $v = @ldap_get_dn($this->_ds, $ent);
!               if ($v === false) {
!                  @ldap_free_result($search);
!                  return PEAR::raiseError(sprintf(_("Error retrieving current script: (%d) %s"),
!                                             ldap_errno($this->_ds),
!                                             ldap_error($this->_ds)));
!               }
!               $userDN = $v;
! 
              }
!             // Set up search filter
!             $filter = '(' . $this->_params['memberuid'] . '=';
              if ($GLOBALS['conf']['group']['params']['attrisdn']) {
!                 $filter .= $userDN;
!             } else {
!                 $filter .= $user;
              } 
              $filter .= ')';