I've got the ldap_integration module up and running on my test Drupal site, and it's happily checking the users credentials against the directory and snagging all sorts of useful user information (names, titles, email, etc.)

What I'm trying to figure out how to do is to get it to populate the "mail" field in Drupal's "users" database when a new user (who exists in LDAP) logs into Drupal for the first time. Right now that field only gets updated if someone visits and then saves their user profile (not a likely occurance). It does pre-populate the form's e-mail field, so the data's there, but it's just not in Drupal yet.

I've been slowly going over the code, but haven't found a good place to insert such a hack yet. Any suggestions?

Ken

CommentFileSizeAuthor
#1 ldap_integration.module-correctMapping32.58 KBpablobm

Comments

pablobm’s picture

StatusFileSize
new32.58 KB

Ooops. My fault, as usual. I forgot to update the line that does that job when I worked out the Drupal/LDAP mappings.

I'm having problems to access CVS at the moment, so I post here a solution for your problem. The change is in the function _ldap_integration_ldap_login(), towards the end of the file.

NukeHavoc’s picture

awesome -- I'll try that out ASAP.

Thanks!

pablobm’s picture

Assigned: Unassigned » pablobm
Category: feature » bug
Priority: Critical » Normal
Status: Active » Needs review
tclineks’s picture

Status: Needs review » Needs work

Changes should be posted as unified diffs for review.
Read drupal.org/patch for more

2root4u’s picture

I was also having this issue and your code fix helped. Another issue I had was the mapping in conf.php. For AD users (not sure about other LDAP setups), it would be useful to change the default conf.php from:


$GLOBALS['ldap_drupal_mappings'] = array(
        // ldap_attribute => drupal field
        // 'cn' => 'name',
        'mailAddress' => 'mail',
        'userPassword' => 'pass',
        //'signature' => 'signature',
        //'timeZome' => 'timezone'

to


$GLOBALS['ldap_drupal_mappings'] = array(
        // ldap_attribute => drupal field
        // 'cn' => 'name',
        'mail' => 'mail',
        'userPassword' => 'pass',
        //'signature' => 'signature',
        //'timeZome' => 'timezone'

This would have definitely saved me some time.

pablobm’s picture

Status: Needs work » Fixed

There's an attribute mapping interface now, so this is not relevant anymore.

Thus, I PabloBM hereby declare this issue... Fixed

Anonymous’s picture

Status: Fixed » Closed (fixed)
oliveaddict’s picture

Version: » 4.6.x-1.x-dev

Hello

Using ldap_integration 4.6.0 (10/10/2005 and 07/04/2006), the mail column in the users table is not being populated when a user logs in for the first time. Through Drupal, viewing "my account" shows the correct field under "Email", but the database cell is empty.

To test, I deleted some users, turned on query logging for MySQL and watched for the INSERT statement when the user was created. The 'mail' field passed is empty.

I am using ActiveDirectory 2003 with the following settings for mail in conf.php

ldap_drupal_mappings: 'mail' => 'mail'
ldap_attributes: 'mail' => array('mailto', 'textfield', t('Email'), 64, 64, '')

Any thoughts? Thank you.

oliveaddict’s picture

Status: Closed (fixed) » Active

In ldap_integration.module, if I change:

      $mail = $ldap->retrieveAttribute($dn, LDAP_EMAIL_ATTRIBUTE);

to:

      $mail = $ldap->retrieveAttribute($dn, 'mail');

... then, the email field gets written to the 'users' table during the new user INSERT. I realize this is an ugly hack and would rather pull the data from $ldap_drupal_mappings. I do not see LDAP_EMAIL_ATTRIBUTE anywhere else in the code.

Am I missing something?

Thank you

pablobm’s picture

Status: Active » Fixed

After a long time in oblivion, I checked this bug and seems to be fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)