LDAP confirmation and approval not working

15 years 1 month ago #91887 by eeDragon
When I log in with an LDAP username and password, the user tables get created correctly, but the user never gets confirmed or approved automatically. I have debugged this issue until I got to a suspected cause. There is code in place to make this work, but it fails to update the user table because the user id is <Undefined>.

CONFIGURATION:
I am using Joomla 1.5.9 and CB 1.2 with the LDAP plugins by Sam Moffatt.

Login Module: mod_cblogin
Plugins:
Authentication - Joomla (first)
Authentication - LDAP (next)
User - Joomla! (Auto Create Users is set)

DEBUGGER INFO
The call stack on login looks like:
administrator/components/com_comprofiler/library/cb/cb.tables.php.moscomprofilerUser->_loadBy_field : lineno 768
administrator/components/com_comprofiler/library/cb/cb.tables.php.moscomprofilerUser->loadByUsername : lineno 725
components/com_comprofiler/comprofiler.php.login : lineno 1611
components/com_comprofiler/comprofiler.php.require_once : lineno 132
libraries/joomla/application/component/helper.php.JComponentHelper->renderComponent : lineno 162
includes/application.php.JSite->dispatch : lineno 124
index.php.{main} : lineno 68

On line 764 of cb.tables.php we set an SQL query which looks like:
$query = SELECT * FROM #__users AS u LEFT JOIN #__comprofiler AS c ON c.id = u.id WHERE
u.`username` = 'dragon' LIMIT 1

When I get $arr back from loadAssoc() on line 766, it has the "id" field as <Uninitialized>.

Further up the stack in comProfiler.php I try to use this data in a $row->store() call to synchronize the comprofiler table with confirmed and approved set. Unfortunately, since the "id" is the table key, the store() fails.
By the way, if I run the same SQL query in phpMyAdmin, I get the same data back, but the "id" is correctly set.

Any suggestions on how to fix this?

Any Ideas?

Post edited by: eeDragon, at: 2009/03/17 02:39

Please Log in to join the conversation.

15 years 1 month ago #92093 by eeDragon
Replied by eeDragon on topic Re:LDAP confirmation and approval not working
OK, I figured this out.

I fixed this with a one line change in class moscomprofileruser:_mapUsers()

You'll find this at line 1386 (approx) in components/com_comprofiler/library/cb/cb.tables.php

I just added a set of $this->id at the top of the function, it now looks like this:

[code:1]function _mapUsers() {
global $_CB_framework;

$this->id = $_CB_framework->myId(); /* set my id in case this is creating a new entry */
if ( $this->_cmsUser === null ) {
$this->_cmsUser = $_CB_framework->_getCmsUserObject();
}
if ( $this->_comprofilerUser === null ) {
$this->_comprofilerUser = new moscomprofiler( $this->_db );
}
...
[/code:1]

Now I'm not sure if this has side effects in environments other than mine (1.5.9 with CB 1.2)
But it is automatically registering users with CB and with their confirmation and approval flags set.

I hope they roll this change into their next release.

Good Luck!

Post edited by: eeDragon, at: 2009/03/19 01:57

Post edited by: eeDragon, at: 2009/03/19 02:02

Please Log in to join the conversation.

15 years 1 month ago #92104 by beat
eeDragon wrote:

OK, I figured this out.

I fixed this with a one line change in class moscomprofileruser:_mapUsers()

You'll find this at line 1386 (approx) in components/com_comprofiler/library/cb/cb.tables.php

I just added a set of $this->id at the top of the function, it now looks like this:

[code:1]function _mapUsers() {
global $_CB_framework;

$this->id = $_CB_framework->myId(); /* set my id in case this is creating a new entry */
if ( $this->_cmsUser === null ) {
$this->_cmsUser = $_CB_framework->_getCmsUserObject();
}
if ( $this->_comprofilerUser === null ) {
$this->_comprofilerUser = new moscomprofiler( $this->_db );
}
...
[/code:1]

Now I'm not sure if this has side effects in environments other than mine (1.5.9 with CB 1.2)
But it is automatically registering users with CB and with their confirmation and approval flags set.

I hope they roll this change into their next release.

Good Luck!

Post edited by: eeDragon, at: 2009/03/19 01:57

Post edited by: eeDragon, at: 2009/03/19 02:02


Many thanks for your report and solution proposal.

Marked as #177 for check and fix in next CB release.

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

14 years 11 months ago #98632 by phummel
This is just a little FYI to the fix posted above / below. For me at-least the fix works, but if I want to allow users or even admins to update the user profiles, it gives an error message of;

"This username/password already in use. Please try another."

What I think is happening (I am just a user not a programmer, so I am not sure) is that this function "map users" is running on all updates as well as the initial mapping. This added line is attempting to add the username everytime an update is submitted and not allowing it to happen based on validation rules.

If I take out the added line I can edit users, but they are not automatically added to CB with the approved flag set.

In order to fix this I would think that the line added would be needed in the initial registration from LDAP, but not on all updates (or a separate function). I am not familiar with the programming aspect of CB so I do not know how to fix this, but I thought that I would just let the masses know my situation.

Thanks,

Pete

Please Log in to join the conversation.

14 years 10 months ago #102739 by MegaBurn
Replied by MegaBurn on topic Re:LDAP confirmation and approval not working
Is there an alternative to this fix? I think its breaking the "autogenerate random registration password" feature. When that feature is enabled and a new user registers, it returns the error phummel mentioned, "This username/password already in use. Please try another.". Then it immediately creates the account in Joomla, not LDAP, and without sending out the welcome email with the random password.

A parallel problem is the JAuthTools User-LDAP plugin does not support email confirmation or waiting for the user to login for the first time. LDAP accounts are created immediately upon registration, but at minimum I need email confirmation of some sort, auth code or random password.

I posted another thread about this on the Joomla forums, LDAP JAuthTools CB Problems , figured I would ask here too.


Thanks,
-Chris

Please Log in to join the conversation.

14 years 10 months ago #102996 by MegaBurn
Replied by MegaBurn on topic Re:LDAP confirmation and approval not working
Seems the only solution is remove the hack and import all preexisting LDAP users into Joomla.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.301 seconds

Facebook Twitter LinkedIn