vTiger 5.1.0 and LDAP-plugin: How to allow SQL-authenticated users to change their passwords

When using LDAP authentication with vTiger, sometimes you want some users to authenticate against the database instead. One example is the admin user, which by default works that way, but there may be other cases as well.

To allow for that you may populate an array in the LDAP config file (config.ldap.php) with users that should be authenticated against the database. It could look like this:

$AUTHCFG['sql_accounts']         = array("user1","admin");

This config means that users admin and user1 will authenticate with whatever password is stored in the SQL database.

The problem comes if user1 wishes to change his or her password in vTiger. If the system is set up for LDAP authentication no users, except for admin, which is an exception, will be able to change their passwords on their profile pages. The password field will only say LDAP Authentication, instead of showing a Change Password-button.

The reason for this is that the code creating the profile page checks which type of authentication that is used as standard, not which type that is used for this particular user.

To fix this you need to edit the file that contains the code creating the profile page: modules/Users/DetailView.php

Locate this section:

        global $AUTHCFG;
        $auth_type = strtoupper($AUTHCFG['authType']);

        // Allow to change the password of the local predefined 'admin' account
        if ($focus->user_name == 'admin') $auth_type = 'SQL';

        switch ($auth_type)
        {
        case 'AD':
                $buttons = "Active Directory authentification";
                break;
        case 'LDAP':
                $buttons = "LDAP authentification";
                break;
        default:
                $buttons = "";
                break;
        }

Comment out this line:

if ($focus->user_name == 'admin') $auth_type = 'SQL';

And instead add something like this:

// A bit of code to see wether the user authenticates through SQL
if (in_array($focus->user_name, $AUTHCFG['sql_accounts'])) $auth_type = 'SQL';

That should fix the problem!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.