Opened 2 years ago

Closed 23 months ago

#1487758 closed Bugs (fixed)

new_user_identity plugin breaks login for new users

Reported by: brandond Owned by:
Priority: 2 Milestone: 0.6-beta
Component: Plugins Version: git-master
Severity: normal Keywords: new_user_identity
Cc: m.duelli@…

Description

The new_user_identity plugin attempts to set private attributes of the rcube_ldap object, causing a PHP error that prevents the user from logging in.

The plugin does:

$match = $rcmail->config->get('new_user_identity_match');
$ldap = $rcmail->get_address_book($addressbook);
$ldap->prop['search_fields'] = array($match);
$results = $ldap->search($match, $args['user'], TRUE);

which results in the following error due to the prop array being private:

[01-Feb-2011 13:34:09] PHP Fatal error:  Cannot access protected property rcube_ldap::$prop in /usr/share/roundcubemail/plugins/new_user_identity/new_user_identity.php on line 38

Attachments (2)

new_user_identity-rcube_ldap-search_fields.patch (1.4 KB) - added by brandond 2 years ago.
I'm not sure what you think of the approach, but here's a proposed patch.
new_user_identity.patch (2.2 KB) - added by alec 23 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 2 years ago by alec

  • Milestone changed from 0.5.1 to 0.6-beta
  • Version changed from 0.5 to svn-trunk

I think this is for 0.6. In 0.5 this property is public.

Changed 2 years ago by brandond

I'm not sure what you think of the approach, but here's a proposed patch.

comment:2 Changed 2 years ago by duelli

  • Cc m.duelli@… added

BTW, just tracked it down: it was introduced in [0501b637]

comment:3 Changed 2 years ago by brandond

Any objection to my proposed fix? I've been using it on my install for several days and it's worked well so far.

comment:4 Changed 2 years ago by thomasb

  • Severity changed from major to normal

The plugin should extend rcube_ldap:

class new_user_ldap_backend extends rcube_ldap
{
  function __construct($p)
  {
    parent::__construct($p);
    $this->prop['search_fields'] = null;
  }
}

comment:5 Changed 2 years ago by duelli

Here is a very simple strategy to workaround the problem:

Index: new_user_identity/new_user_identity.php
===================================================================
--- new_user_identity/new_user_identity.php     (revision 4560)
+++ new_user_identity/new_user_identity.php     (working copy)
@@ -35,7 +35,6 @@
         if ($addressbook = $rcmail->config->get('new_user_identity_addressbook')) {
             $match = $rcmail->config->get('new_user_identity_match');
             $ldap = $rcmail->get_address_book($addressbook);
-            $ldap->prop['search_fields'] = array($match);
             $results = $ldap->search($match, $args['user'], TRUE);
             if (count($results->records) == 1) {
                 $args['user_name'] = $results->records[0]['name'];

You can workaround this problem by applying this simple patch and append the content of the new_user_identity_match entry to your LDAP addressbook's search_fields entry (in my case this is uid and just makes LDAP searches a bit tougher)

This fixes the problems that occur since [0501b637]. However, this is just a dirty workaround!

The general problem is that the search function in program/include/rcube_ldap.php only evalutes the $fields parameter iff it contains "ID" or the LDAP addressbook's search_fields entry is not an array!!

To that end, the new_user_identity plugin always worked around this issue by hard resetting the LDAP addressbook's search_fields entry (which is a hack that might cause other problems) which is now forbidden since it has been made protected.

A much better solution would enable the LDAP search function to respect the given set of search fields instead of deriving a new LDAP addressbook.

Changed 23 months ago by alec

comment:6 Changed 23 months ago by alec

Check my patch, please.

comment:7 Changed 23 months ago by duelli

Dear Alec,

there is a typo in the name of the new backend class.

However, this seems to be the only problem with this patch.

I just tested it and created a new user which worked just fine.

Thank you!

comment:8 Changed 23 months ago by alec

  • Resolution set to fixed
  • Status changed from new to closed

Applied in r4915/svn.

Note: See TracTickets for help on using tickets.