ldap_sample addUser missing return true

Bug #1032770 reported by Bill Gosse
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PHPDevShell
New
Undecided
Unassigned

Bug Description

The ldap_sample class code contained LPAP Plugin docs needs a return statement that returns true added to the end of its addUser function. Without the return true statement the login will fail the first time even though the user successfully authenticated against the ldap server and was successfully added to the local databse.

Revision history for this message
Greg (gregfr) wrote :

Can you specify where you found this problem?

Revision history for this message
Bill Gosse (bill-gosse) wrote :

See final return statement added to the addUser function below. This is the code from the ldap_sample.class.php file which is provided in the curent release.

class ldap_sample extends AUTH_ldap
{
    protected $source = array(
        'url' => 'ldap://bender.terascala.com',
        'defaults' => array(
            'user_group' => 2,
            'user_role' => 2
        ),
        'namePattern' => '%<email address hidden>',
        'defaultGroups' => array(11),
        'defaultRoles' => array(10),
        'required' => true
    );

    public function addUser($username, $password, $sourceName = null)
    {

        /* @var $newUser PHPDS_importUser */
        $newUser = $this->factory('PHPDS_importUser');
        $userData = array('user_id' => 0, 'user_name' => $username, 'user_password'=> $sourceName);
        $userData = array_merge($this->source['defaults'], $userData);
        $newUser->import($userData);

        if (is_array($this->source['defaultGroups'])) {
            foreach($this->source['defaultGroups'] as $gID) $newUser->addGroup($gID);
        }
        if (is_array($this->source['defaultRoles'])) {
            foreach($this->source['defaultRoles'] as $rID) $newUser->addRole($rID);
        }

        $newUser->save();

        //Attention: The following return statement need added in order for this function to work correctly.
        return true;
    }
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.