Issue Details (XML | Word | Printable)

Key: MDL-6060
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Petr Skoda
Reporter: Imported
Votes: 1
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Automatically assign creator LDAP does not work if a comma is in the DN

Created: 10/Jul/06 09:58 AM   Updated: 05/Mar/07 08:20 PM
Return to search
Component/s: Authentication
Affects Version/s: 1.6
Fix Version/s: 1.8, 1.9

Environment: All
Issue Links:
Dependency
 

Database: Any
Participants: Imported, Iñaki Arenaza, Petr Skoda and Phil Rand
Security Level: None
Resolved date: 05/Mar/07
Affected Branches: MOODLE_16_STABLE
Fixed Branches: MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
Please look at the discussion from http://moodle.org/mod/forum/discuss.php?d=35865



LDAP creator does not work with MSAD when there is a comma in the DN that is not a part of the path.



In /auth/ldap/lib.php:



Near line 1386 the php function ldap_get_dn is used to obtain the dn of a user account if in this user?s dn there is a comma (my example is ?cn=Bromley, James,ou=tech center,dc=mydomain,dc=com?) it is escaped with only one backslash. Then it is fed to ldap_read near line 1261. The problem is ldap_read needs the comma escaped with two backslashes. So: ?cn=Bromley, James,ou=tech center,dc=mydomain,dc=com? needs to become ?cn=Bromley\, James,ou=tech center,dc=mydomain,dc=com?).



I could not find mention to this in the PHP website or on Mosilla?s website, except for another user pointing out in the comments of ldap_rename that things had to be escaped with two backslashes.



A particularly helpful moodler Iñaki Arenaza found the actual cause for it not working and sujested this work aroung until a patch was available, replace the if block for if ($CFG->ldap_memberattribute_isdn) with the following:



    if ($CFG->ldap_memberattribute_isdn) {

        $username=auth_ldap_find_userdn($ldapconnection, $username);

        if (! $username ) {

            return $result;

        }

        $username = preg_replace ('/\\,/', '\\\\,', $username);

    }





 James Bromley

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Phil Rand added a comment - 24/Jan/07 08:55 AM
There's a discrepancy between the preg_replace call displayed in the description here versus the discussion in the linked forum. The description as displayed from tracker in my firefox browser shows two backslashes replaced with four. The code fragment quoted in the linked discussion shows four blackslashes replaced with eight, and that is, indeed, what solved this problem for me in Moodle 1.7, lib.php,v 1.83.2.2.

By the way, in our case, our user account distinguished names come from the AD "display name", which we configured as last, pref, where pref is a nickname if present, or the given name if not.

So my DN is: CN=Rand\, Phil,CN=Users,DC=spu,DC=local


Iñaki Arenaza added a comment - 24/Jan/07 05:59 PM
I suspect the old bug tracker (this bug was imported from the old bugtracker) munged the original version of the preg_replace strings.

As you say, you need four slashes in the first string, and eight in the second one ( just like the one shown at http://moodle.org/mod/forum/discuss.php?d=35865#226068 )

Saludos. Iñaki.


Petr Skoda added a comment - 01/Mar/07 07:10 PM
this should be fixed in latest 1.8dev, could anybody confirm it please?

Petr Skoda added a comment - 05/Mar/07 08:20 PM
this should be fixed in cvs, please file a new report for 1.8 if needed

thanks!