I there a way to have drupal display the CN instead of the username in nodes (places like the Author)? Makes for a more friendly appearance.

CommentFileSizeAuthor
#5 ldapgroup_example.jpg72.18 KBscafmac

Comments

cgallo’s picture

This is what I did to retreive first name and last name from ldap.

In User management -> Profiles
Create single line textfield fname and lname

Under site configuration -> ldapdata
Map the drupal attributes to the ldap attributes
profile_fname to givenName
profile_lname to sn

Once data is mapped you can reference it a
$user->profile_fname
$user->profile_lname

Hope this helps.
cg

kk1’s picture

i configure ldap successfully and integrated with my organisation's Active directory,when the users login the site its displaying employ id which i would like to replace with the user's first name .How can i do it. Help me out!! here is snap shot chk out the sidebar login.

the above code i worked out but i did not understand where to add.

$user->profile_fname
$user->profile_lname

cpugeniusmv’s picture

Priority: Minor » Critical

You'll need to override theme_username in your theme's template.php file.

http://drupal.org/node/11811
http://drupal.org/node/55126

Panda_N_Shark’s picture

Hy there,

Can you put a pic how to configure

Under site configuration -> ldapdata
Map the drupal attributes to the ldap attributes
profile_fname to givenName
profile_lname to sn

I try different ways... but the fields never get values :s

scafmac’s picture

StatusFileSize
new72.18 KB

Here's an image - why don't you describe what you've tried - I'm not sure how cpugeniusmv did it, but this image shows how we've configured a similar setup.

What we did here is:

* create two new profile fields: profile_alumni_id & profile_alias
* entered their LDAP attribute names: employNumber & alias
* and indicated above that any updates should be saved to LDAP

You'll also notice mail, pass, & signature are listed - those are default drupal fields, but you still need to specify what LDAP attribute you map to. In our situation, we completely ignore the ldapdata.conf.php file. We also ignore the bottom section.

This module is a bit of a mess - let me know how it goes.

I've found that occasionally, when it just will not work as expected, selecting the 3rd radio button & starting over works helps.

Regards

scafmac’s picture

Oh yeah - you also probably need to define an administrative DN & password in the advanced section of the ldapdata admin page. Is there anything in the log about errors? Both the Drupal log & the web server log.

Panda_N_Shark’s picture

I there!

Thanks for the pic, what i want is that, i only want the fields to get data from ldap to drupal... but when i do update i get the folloing errors:

* warning: array_filter() [function.array-filter]: The first argument should be an array in /media/WORK/www/drupal/modules/ldap_integration/ldapdata.module on line 373.
* warning: array_filter() [function.array-filter]: The first argument should be an array in /media/WORK/www/drupal/modules/ldap_integration/ldapdata.module on line 382.

By the way, i still have the profile module return errors on first login...

Thanks for the help

scafmac’s picture

Priority: Critical » Normal

Anyone looking for the solution to the original issue - use comments #1 & #3.

Hey Panda_n_Shark,

With errors like that, I think you should create a new issue, unless you can find a similar one to comment on. Either way, this one isn't it.

With that said, if you are having problems with the profile module, the ldap data module will not work correctly. You said you had profile errors first. Try turning off the ldap groups module and get the profile module working by itself first. Now the DB might be fubared, in which case, you should uninstall the ldap groups module before re-enabling it.

Good luck

coderintherye’s picture

Status: Active » Fixed

Oh man! I wish I had seen this thread last month when I was recreating the solution. However, here is an alternative, programmatic way that could be implemented grab those name attributes within the module.

In discussion around the original point of this thread, in order to get the CN name, I did the following changes to the ldapdata.module file.

Lines 707 - 719 of the original ldapdata.module file (at the end of the ldap_user_view function) are as follows:

 if ($allowed_attrs) {
    foreach($allowed_attrs as $attribute) {
      $item = array();
      $item['title'] = $ldap_attributes[$attribute][2];
      $item['value'] = theme('ldapdata_ldap_attribute', $entry[strtolower($attribute)][0], $ldap_attributes[$attribute][0]);
      $item['class'] = 'attribute';
      $ret[LDAP_SETTINGS_GROUP_STRING][] = $item;
    }
  }

  $ldapdata_ldap->disconnect();

  return $ret;

On the blank line of 715 between the } closing the if statement and the $ldapdat_ldap->disconnect(); I added the line

variable_set($userfullname, $ret['LDAP attributes'][2]['value']);

(by the way it took a really long time to figure out that is where the data was coming from)

Now the problem here is that the array number of the attribute for the full name could vary widely depending on what your setup is in your LDAP, but maybe we could check the attribute name or something and then if it is name assign it to a name variable automatically.

Considering the original issue of this thread got derailed, a potential solution (although not complete) was posted, and I want to further discuss completely the mapping of the user name, I am closing this issue, and starting a new issue.

Status: Fixed » Closed (fixed)

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