CB1.1 doesn't work with Joomla! 1.5's LDAP

16 years 2 months ago #57750 by pasamio
CommunityBuilder 1.1 isn't compatible with the LDAP authentication plugin in Joomla! 1.5 because it still tries to authenticate the user from the Users table circumventing the entire 1.5 authentication system. For users who have already been created within the system, confirmed and approved you can use a small hack to get CB to work properly with LDAP with a small hack:
sammoffatt.com.au/jauthtools/Compatibility/CommunityBuilder

The crux of the problem is that CB does its own authentication check over the user on the password which for LDAP users isn't stored in the Joomla! database (its stored in LDAP of course!). Once its happy that the user can login it runs the core Joomla! login procedure which will then work with LDAP.

My hack changes a statement to short circuit an if when the password is blank. This is still secure as the real work is done by Joomla! anyway to validate the user and set the session up.

Features like autocreation won't work either since Joomla! is only consulted after CB which means none of the Joomla! plugins get to run to create the user for CB to check let alone the entries into the CB copy of the user table to approve and confirm the user. This works in 1.0 because the JAuthTools plugin runs in the system space and intercepts the authentication request for CB before CB gets it and fills in the relevant details into the database.

Please Log in to join the conversation.

16 years 2 months ago #57763 by beat
Cool, thanks for the suggestion and solution proposal B) .

We would be delighted to make this work in CB core 1.2. :)

Question: this suggested fix works only if that user for that username has a row in jos_users and in jos_comprofiler ?

Is that "autocreation" feature meaning that the jos_users and jos_comprofiler entries are automatically created ?

Is there a way in 1.5.1 to have the authentication provided separately from login ?

Reason is that the CB plugins event "onDuringLogin" must be fired after authentication but before login.

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.

16 years 2 months ago #57768 by pasamio
Replied by pasamio on topic Re:CB1.1 doesn't work with Joomla! 1.5's LDAP
Yes, the fix only works when the user is approved and confirmed in jos_users and in jos_comprofiler. It works by killing off your authentication checks when the password is blank and letting the normal Joomla! login take over.

The autocreation feature creates the user in the jos_users database in 1.5 if they don't exist there already. This is done by the User - Joomla! plugin as a part of the normal login process. In 1.0 I handled it by myself manually inserting the values into jos_users and jos_comprofiler.

You can handle authentication in 1.5 for all plugins by doing this:
[code:1]
jimport( 'joomla.user.authentication');
$auth = & JAuthentication::getInstance();
$result = $auth->authenticate(Array('username'=>$username,'password'=>$password), Array());
if ($response->status === JAUTHENTICATE_STATUS_SUCCESS) {
// it worked
} else {
// it didn't ;«»)
}
[/code:1]

That will validate the passed username and password and return a JAuthResponse object with the first valid return value including their username, display name and email. Line 506 in /libraries/joomla/application/application.php is the Core Joomla! login routine which is slightly different to the above code (has the arrays already and is a bit longer) but it should give you an idea of how things work.

Once you've done an authenticate you should call the rest of the Core plugins as well, again check out the above section of code and you get an idea of what you need to call, should be onLoginUser on success and onLoginFailure for failure.

Triggering this will cause the User - Joomla! plugin to run which will autocreate the user in jos_users. You can decide if you want to provide autocreation for your own system at this point as well. For example you can capture non CB login events as well if you like though at the present moment you can't halt them, however you could manipulate the jos_user table to block the user before Joomla! tries to log the user in. You could achieve this by putting a CB user plugin ordered before the Joomla! one to intercept a login event and alter the core table. You would have to take responsibility for maintaining a copy of the true value yourself but I'm sure you can handle that, plus the on(Before|After)StoreUser can be used to capture events whenever a user is updated (check out /libraries/joomla/user/user.php)

So you've got lots of options :)

Please Log in to join the conversation.

16 years 2 months ago #57782 by jimesmythe
Replied by jimesmythe on topic Re:CB1.1 doesn't work with Joomla! 1.5's LDAP
just curious if this gives a fix to the LDAP login through CB and also if it will autocreate the accounts.

And when is CB 1.2 coming out.

Jimmy Smith

Please Log in to join the conversation.

16 years 2 months ago #57789 by beat
Thanks for the heads up and explanations, Sam B)

Will study that and see what we can do for CB 1.2 :)

Is there then a way after successful authentication to login without re-authenticating ? (to avoid e.g. 2 LDAP requests per login ;) ) ?

Also are there other fields from the LDAP directory which could be imported into the CB profile at auto-creation (or auto-update-) time ?

----

jimesmythe,

Sam's fix will allow login based on LDAP-stored passwords for users already registereed in joomla/CB.

The fix that we are discussing here might allow also autocreation of the accounts based on the trusted LDAP source. :)

----

CB 1.2 is still in development, although beta tests already started.

The big news is that CB 1.2 will run natively on Joomla 1.5 too :)

We don't have a release date yet, but it shouldn't be months. ;)

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.

16 years 2 months ago #57801 by jimesmythe
Replied by jimesmythe on topic Re:CB1.1 doesn't work with Joomla! 1.5's LDAP
That would actually be great so that i have to create their account; however, is there a wiki or something that tells exactly how to perform the patch.

Jimmy Smith

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.308 seconds

Facebook Twitter LinkedIn