phpldapadmin PHP error

Kernels & Hardware, configuring network, installing services

phpldapadmin PHP error

Postby chema » 2014-02-09 16:41

Hi,
I'm running a Debian jessie/sid web server and I want to configure a directory in order to use the same user accounts for different services. I installed and configured slapd and phpldapadmin. For the latter I had to create a symbolic link from /etc/apache2/conf-enabled/phpldapadmin.conf to /etc/phpldapadmin/apache.conf since it didn't work by default (it creates a file in the Apache conf.d directory, which is not read since it doesn't end in .conf).

But now, when I access the phpldapadmin document root at domain.com/phpldapadmin, it shows the following error and doesn't render the index page:

Fatal error: Cannot redeclare password_hash() in /usr/share/phpldapadmin/lib/functions.php on line 2225

I tried installing it from source and got the same error, although in a different line number. So I'm guessing it's probably a configuration error on my part. The config.php file is huge so I'm a bit lost here. Has anyone experienced the same error? Or could anyone give me some pointers to narrow down the problem? I figured that at least it should display the login page, even if the connection information for the LDAP server is all wrong.

I'm sorry if this is forum is not the correct place to ask this, the bug tracker at http://sourceforge.net/p/phpldapadmin/bugs/ seems to no longer be in use and I can't figure out where else can I ask for help.

Thank you.
chema
 
Posts: 2
Joined: 2014-02-09 15:54

Re: phpldapadmin PHP error

Postby chema » 2014-02-10 00:10

I had to rename the password_hash function because it is incompatible with the built-in one and storing passwords didn't work. So just rename the function for something like pla_password_hash at:

/usr/share/phpldapadmin/lib/functions.php lines 2130, 2311 and 2320

/usr/share/phpldapadmin/lib/PageRender.php line 289

I get a couple of warnings on the main page though (deprecated functions and such), so I guess the phpldapadmin code is a bit outdated with respect to the current PHP version.

Edit: the warnings are fixed by replacing all calls to preg_replace which use the /e modifier with the newer preg_replace_callback function, which is apparently safer. So that would be:

At /usr/share/phpldapadmin/lib/functions.php line 2549 and /usr/share/phpldapadmin/lib/ds_ldap.php line 1120:

Replace

Code: Select all
preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn);


With

Code: Select all
preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',function(){return "''.chr(hexdec('\\1')).''";},$rdn);


At /usr/share/phpldapadmin/lib/functions.php line 2554 and /usr/share/phpldapadmin/lib/ds_ldap.php line 1125:

Replace

Code: Select all
preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn);


With

Code: Select all
preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',function(){return "''.chr(hexdec('\\1')).''";},$dn);


I am no PHP programmer, so this could very well be wrong. I'll try to contact the developer with these issues, but it seems as if this software is no longer under development, judging by the date of the latest version and the activity in the Sourceforge page... it's a pity since I couldn't find any other web-based management tools for OpenLDAP.
chema
 
Posts: 2
Joined: 2014-02-09 15:54

Re: phpldapadmin PHP error

Postby bluepouch » 2014-05-19 13:52

Thank you chema! I had the same problem (Installed phpldapadmin today on Ubuntu 13.10 via apt-get) and your fix worked like a charm :)
bluepouch
 
Posts: 1
Joined: 2014-05-19 13:50

Re: phpldapadmin PHP error

Postby mstrcdr » 2014-12-04 17:54

The information above is perfect for fixing the page so it renders.

I found there is at least one other place that needs the change so the creation templates render without errors.

At /usr/share/phpldapadmin/lib/TemplateRender.php line 2469:

Replace
Code: Select all
$default = $this->getServer()->getValue('appearance','password_hash');


With
Code: Select all
$default = $this->getServer()->getValue('appearance','pla_password_hash');


Hope this helps anyone else looking for this fix.
mstrcdr
 
Posts: 1
Joined: 2014-12-04 17:41

Re: phpldapadmin PHP error

Postby JohnRB » 2015-09-11 21:01

I posted this for any users searching out same error since the OP has already solved problem.

Here is a patch: https://bugs.debian.org/cgi-bin/bugrepo ... lity.patch

That I got from this bug report, worked like a charm for me: https://bugs.debian.org/cgi-bin/bugrepo ... bug=710854
JohnRB
 
Posts: 1
Joined: 2015-09-11 20:48


Return to System configuration

Who is online

Users browsing this forum: No registered users and 10 guests

fashionable