Notice Undefined index CN using ldap

Notice Undefined index CN using ldap

by Kerry Koppert -
Number of replies: 5

I am attempting to setup a linux moodle server on our site using ldap authentication on a Windows 2003 Active Directory server. After finding that ldap_user_attribute did not default to cn, everything worked. I then changed this to sAMAccountName, set the ldap_memberattribute to memberOf and tried to prepopulate the user fields with ldap attributes i.e. sn and GivenName. Since the I get an error when a user logs in

Notice: Undefined index CN in /var/www/html/moodle/auth/ldap/lib.php on line 574

Warning Cannot add header information - headers already sent by (output started at /var... 574) in /var/www/html/moodle/lib/moodlelib.php on line 947

As far as I can see the offending line is array_push in

       //add found users to list
        for ($i=0;$i<$users['count'];$i++) {
            array_push($fresult, ($users[$i][$CFG->ldap_user_attribute][0]) );
        }

Can someone give me a clue as to what may be happening?

Average of ratings: -
In reply to Kerry Koppert

Re: Notice Undefined index CN using ldap

by Martín Langhoff -
Can you post your Moodle Auth-LDAP config and a brief explanation of how your LDAP repository looks like (user records, tree structure, etc)?
In reply to Martín Langhoff

Re: Notice Undefined index CN using ldap

by Kerry Koppert -

I know this doesn't answer your question, but it suddenely started working again.

In reply to Kerry Koppert

Re: Notice Undefined index CN using ldap

by Saul Montalvo Perales -
Hi Kerry, i've almost the same scenario as yours, we have Active Directory running on a Windows 2003 Server and we have moodle running on Red Hat Enterprise Linux, i´ve been testing lots of combinations of values of LDAP settings and i have no success on configuring netiher NTLM plugin nor LDAP.

I´ve noticed that you changed lots of default settings on the moodle, could you tell me if you had success on your implementation.

Thanks in advance




In reply to Saul Montalvo Perales

Re: Notice Undefined index CN using ldap

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm using these settings with AD running on W2003  (only filled in values are shown, there rest are left blank):

LDAP server settings
  Host URL: ldap://192.168.27.2
  Version: 3
  LDAP Encoding: utf-8

Bind settings
  Hide Passwords: Yes
  Distinguished Name: cn=ldap-user,cn=users,dc=windows2003,dc=local
  Password: ldap-user

User lookup settings
  User type: MS Active Directory
  Contexts: ou=Moodle,dc=windows2003,dc=local
  Search subcontexts: Yes
  Dereference aliases: No
  User attribute: sAMAccountName

Force change password:
  Force change password: No
  Use standard Change Password Page: No
  Password format: Plain text

LDAP password expiration settings.
  Expiration: No
  Grace logins: No

Enable user creation
  Create users externally: No

Cron synchronization script
  Removed ext user: Full delete internal

Data Mapping:
  First name: givenName
  Surname: sn
  Email address: mail
  City/town: l          (that's a lower case L)
  Country: c
  Description: description
  ID Number: sAMAccountName

Hope this helps.

Saludos. Iñaki.