I have disabled the "Do not store users' passwords during sessions" checkbox in "Administer -> Site configuration -> LDAP Authentication -> Settings -> Security Options". According to the documentation next to this setting, this should allow the ldapauth module to store the user's LDAP password in clear text during the session, in the session table of Drupal's database.

When I login as a LDAP user (uid > 1) and view the Drupal MySQL databse in phpMyAdmin, the session table does not contain any clear-text password. Where can I find it? I'm looking for it to establish SSO from Drupal to Moodle.

Comments

roball’s picture

Could someone please shine a light on this?

rmiddle’s picture

roball,

User Number 1 will always use drupal local datebase that way if something goes wrong with your ldap setup you can login as "root" to fix things. Create a user Number 2 and you should see there password in clear text.

Thanks
Robert

roball’s picture

Thank you Robert for replying. I know that the superadmin user (uid == 1) will always be authenticated by Drupal's built-in login method. That's why I wrote "When I login as a LDAP user (uid > 1) and view the Drupal MySQL database". My question is still where I could see the password in clear text.

rmiddle’s picture

sorry roball I miss read your message. The password is likely stored in a serialized format. Are you running the data stored in the table though unserialize and I would guess you will see the password right there.

Thanks
Robert

roball’s picture

Is the password supposed to be stored in the "session" field of the "sessions" table?

When I login as user with the uid 2 and view the "sessions" table afterwards, the row with the "uid" value 2 has the following content in the "session" field:

CiviCRM|a:4:{s:10:"lcMessages";s:5:"en_US";s:4:"ufID";s:1:"2";s:6:"userID";s:3:"105";s:8:"ufUniqID";s:0:"";}

I cannot see where the password should be.

Thanks for trying sorting this out.

rmiddle’s picture

based on that you password would be the field "ufUniqID". I would guess that is an MD4 hash of your password. i don't have cain and able handy but I am pretty sure it would take only a few min to crack that password hash.

Thanks
Robert

roball’s picture

I'm getting more confused. Where is the value of this "ufUniqID" field?? And according to the ldapauth module's documentation, Physically, these passwords are stored in the Drupal's session table in clear text.

There is not even a table called "session" in Drupal's MySQL database - the table I mentioned is called "sessions".

rmiddle’s picture

No your password is "ufUniqID". Yes it is sessions. The entire data structure is converged using "serialize" into 1 string that is stored inside that table. Serialize converts data from an array into a string that can be stored safely. I have looked at the output of serialize enough to know that the hash of your password is "ufUniqID" Anyone with a password cracker will be able to convert that back into a usable password to login with.

Thanks
Robert

PS. I would make sure you reset your password after this since anyone reading this will now be able to login to your site as that user.

roball’s picture

No, [ufUniqID] is one of the elements of the [CiviCRM] array, besides [ufID], [userID] and [lcMessages]. Its value is empty. This array is stored for all users in the sessions table, including the superadmin (uid=1). So it has nothing to do with the "clear text password" the ldapauth module is supposed to store somewhere (but it looks it does not).

Could anyone who is familiar with the ldapauth module please explain what the "Do not store users' passwords during sessions" option is really doing?

roball’s picture

rmiddle wrote:

PS. I would make sure you reset your password after this since anyone reading this will now be able to login to your site as that user.

Come on, even if that would be a hashed password (which it isn't for 100%), nobody could login. I haven't posted neither the username nor the URL. Nonsense.

miglius’s picture

I would suggest clearing the sessions table first and then logging as the ldap user. Maybe you were looking not at the latest entry for your user.

Once you done that you should see a string similar to "ldap_login|a:2:{s:2:"dn";s:32:"uid=a.a,ou=drupal6.debian,dc=mac";s:4:"pass";s:2:"zz";}" in a session column. This is a serialized array 'ldap_login' => array('dn' => 'uid=a.a,ou=drupal6.debian,dc=mac', 'pass' => 'zz'), where zz is a clear text password.

roball’s picture

Version: 6.x-1.x-dev » 6.x-1.0-alpha2
Component: Code » Documentation
Status: Fixed » Active

Thank you Miglius for your useful reply! As you suggested, I completely truncated the sessions table first and then logged in as the LDAP user. After reloading the table, one row came up, so it's belonging to that user for sure. However, still no "ldap_login|a:" entry in the session field.

Looking into the code of "ldapauth.module", I found that the version I am using (6.x-1.0-alpha2, containing CVS version 1.32.2.11) does not contain

  $_SESSION['ldap_login']['dn'] = $dn;
  $_SESSION['ldap_login']['pass'] = $pass;

as the latest available development snapshot (CVS version 1.32.2.19) does. After upgrading the LDAP integration module to that version, it finally worked as expected :-)

roball’s picture

Version: 6.x-1.0-alpha2 » 6.x-1.x-dev
Component: Documentation » Code
Status: Active » Fixed

Version: 6.x-1.0-alpha2 » 6.x-1.x-dev
Component: Documentation » Code
Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.