Author Topic: Strange rendering issue with LDAP->Active Directory  (Read 7261 times)

Offline Numbski

  • Newbie
  • *
  • Posts: 8
Strange rendering issue with LDAP->Active Directory
« on: March 13, 2009, 02:00:06 PM »
I have a suspicion as to what might be causing this, but I need to bounce it off of someone that knows RoundCube better than myself.  I have LDAP settings that look like this:

  'search_fields' => array('mail', 'cn', 'displayName', 'mailNickname'),
  'name_field'    => 'displayName',
  'email_field'   => 'mail',
  'surname_field' => 'sn',
  'firstname_field' => 'givenName',
  'sort'          => 'sn',
  'scope'         => 'sub',   // search mode: sub|base|list
  'filter'        => '(&(mailNickname=*)(sn=*)(!(msExchHideFromAddressLists=TRUE))),

So here's the desired outcome - I'd like the Display Names that appear by default to be literally the user's displayName attribute, and for those to be ordered by last name (sn).  It appears that the above works, HOWEVER there's a problem.  All of the fields in the Display Name column in RoundCube are blank!  The bottom of the screen reads: "Contacts 1 to 40 of 2000".  If I click on one of those blanks, a user appears - and as such, those blanks are ordered by last name.  Very strange!

Now, if I change name_field from displayName to cn, those fields are populated with the cn - but here that isn't useful, because those cn's are numeric. :(  (I didn't do it, HONEST!)  If I change it to company, the companies get listed.  I can change it to anything basically but displayName.  If I do that, the fields render blank.  Now the reason I suspecting is because our display names look like this:

Lastname, Firstname (US)

These are generated by a script that pulls Lastname from sn, Firstname from givenName, and (US) from c - or if c is null, it checks phone numbers and cross-references the formatting of the phone number to give us a 2-letter country code.

My suspicion is that the use of either that comma or the parenthesis is causing the issue.  Is there anyone that could confirm that?  For my part, I've been checking to see if commas or parens somehow violate RFC for displayName.  Help?

Offline Julius Caesar

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 498
    • http://www.de-keizer.net/
Strange rendering issue with LDAP->Active Directory
« Reply #1 on: March 14, 2009, 04:42:23 AM »
Quote from: Numbski;17694
I can change it to anything basically but displayName.  If I do that, the fields render blank.  Now the reason I suspecting is because our display names look like this:

Lastname, Firstname (US)

These are generated by a script that pulls Lastname from sn, Firstname from givenName, and (US) from c - or if c is null, it checks phone numbers and cross-references the formatting of the phone number to give us a 2-letter country code.

My suspicion is that the use of either that comma or the parenthesis is causing the issue.  Is there anyone that could confirm that?  For my part, I've been checking to see if commas or parens somehow violate RFC for displayName.  Help?


I've tried it on my LDAP server (openldap) and I have no problem with parenthesis or comma's. My question: Is the field 'displayName' filled by the script, or live generated?
Julius Caesar

You can download the Groupvice4 theme here.
Sie können Groupvice4 hier he

Offline Numbski

  • Newbie
  • *
  • Posts: 8
Strange rendering issue with LDAP->Active Directory
« Reply #2 on: March 16, 2009, 09:21:12 AM »
Quote from: Julius Caesar;17704
I've tried it on my LDAP server (openldap) and I have no problem with parenthesis or comma's. My question: Is the field 'displayName' filled by the script, or live generated?


I'm not entirely sure what you mean.  It's a real field if that's what you mean.  I can connect to AD with a perl script and run a query for displayName and get a real result.  What's even more bizarre is that the right-side fields display properly.  Lemme see if I can get a screen cap of what I'm talking about.


Offline Julius Caesar

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 498
    • http://www.de-keizer.net/
Strange rendering issue with LDAP->Active Directory
« Reply #4 on: March 16, 2009, 10:51:11 AM »
I think it's a bug in RoundCube. When I add a field 'displayName' to my LDAP-server and want to use it, the way you do, I'll get the same symptoms:

No display in the list and a normal display in the details.

Please submit a ticket @ trac.roundcube.net.
« Last Edit: March 16, 2009, 10:54:10 AM by Julius Caesar »
Julius Caesar

You can download the Groupvice4 theme here.
Sie können Groupvice4 hier he


Offline kisjani

  • Newbie
  • *
  • Posts: 1
Strange rendering issue with LDAP->Active Directory
« Reply #6 on: March 19, 2009, 06:54:22 PM »
Quote from: Julius Caesar;17789
I think it's a bug in RoundCube. When I add a field 'displayName' to my LDAP-server and want to use it, the way you do, I'll get the same symptoms:

No display in the list and a normal display in the details.

Please submit a ticket @ trac.roundcube.net.


Okay, I think I have the problem.
It is not working because of case sensitivity.
I use eDirectory and there the user's full name is stored under the fullName attribute. If I write
'name_field'    => 'fullName' //it does not work
'name_field'    => 'fullname' //it does work
I had the same problem, all of the fields in the Display Name column in RoundCube were blank, but when clicking on one of those blanks, the user appeared correctly. I'm not sure if writing the attribute name in lower case is working with OpenLDAP and ActiveDirectory, but I think it should. I have read this about attribute case sensitivity:
LDAP attribute names are case-insensitive. Thus two attribute names, such as "objectclass" and "objectClass", both would be interpreted to refer to the same attribute.
So it may be a bug in the roundcube code, but this info may help to use this function properly.

Offline i-zen

  • Newbie
  • *
  • Posts: 1
Strange rendering issue with LDAP->Active Directory
« Reply #7 on: March 22, 2009, 03:11:34 PM »
I have same issue with Active Directory.

Setting

'name_field'    => 'displayname'

as suggested by kisjani corrects the problem.

Offline michael.brunt

  • Newbie
  • *
  • Posts: 1
lowe case breaks other things
« Reply #8 on: June 26, 2009, 03:03:58 PM »
if I use displayname (no capitals) the Display Name field in the detailed contact info is blank.

Offline ajz

  • Newbie
  • *
  • Posts: 1
Solution
« Reply #9 on: July 29, 2009, 11:29:40 AM »
I've found a fix for this but.  I'm unable to register at the trac site, so hopefully one of the team members can apply this fix.

There's a problem with the _ldap2result() function in include/rcube_ldap.php.

The reason stems from a bug/quirk in PHP's LDAP libraries.  ldap_get_attributes() does not lowercase attribute names returned, but
ldap_get_entries() does.  The functions that get lists of names (list, search) use ldap_get_entries(), and therefore are returned lowercase attributes.  The requests that return single items such as clicking on an address book entry use the ldap_get_attributes() function.  The following code can be used to replace the _ldap2result() function in rcube_ldap.php. in the include folder


function _ldap2result($rec)
  {
    
$out = array();

    if (
$rec['dn'])
      
$out[$this->primary_key] = base64_encode($rec['dn']);

    foreach (
$this->fieldmap as $rf => $lf)
    {
      
// ldap_get_attributes() does not lowercase attribute names returned, but
      // ldap_get_entries() does.  This is confusing.  The following will lowercase
      // the attribute names to adjust the behavior.

      
if ($rec[$lf]['count']) {
        
$out[$rf] = $rec[$lf][0];
      } else {
        
$lclf strtolower($lf);
        if (
$rec[$lclf]['count']) {
          
$out[$rf] = $rec[$lclf][0];
        }
      }
    }

    return 
$out;
  }