<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/38/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=RedMorris</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/38/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=RedMorris"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/Special:Contributions/RedMorris"/>
	<updated>2026-04-16T17:15:40Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=error/gradereport_btec/outcomesdisabled&amp;diff=57844</id>
		<title>error/gradereport btec/outcomesdisabled</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=error/gradereport_btec/outcomesdisabled&amp;diff=57844"/>
		<updated>2009-06-10T08:48:03Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: New page: ==BTEC Grade Report Error==  This error has occurred because the system administrator has not enabled outcomes at the site level.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==BTEC Grade Report Error==&lt;br /&gt;
&lt;br /&gt;
This error has occurred because the system administrator has not enabled outcomes at the site level.&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=error/gradereport_btec/nooutcomedata&amp;diff=57843</id>
		<title>error/gradereport btec/nooutcomedata</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=error/gradereport_btec/nooutcomedata&amp;diff=57843"/>
		<updated>2009-06-10T08:44:58Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==BTEC Grade Report Error==&lt;br /&gt;
This error relates to one of three things. Either there are no users in the course, no outcomes in the course or no activities with outcomes.&lt;br /&gt;
&lt;br /&gt;
Each outcome name must conform to a standard in order for it to be automatically recognised as a BTEC criteria and calculated. The outcome name must contain a P, M or D immediatelly followed by a number. There may be preceeding or following text, but there cannot be a space between the letter and number. &lt;br /&gt;
&lt;br /&gt;
Each of the following are valid BTEC criteria outcome names:&lt;br /&gt;
*P1&lt;br /&gt;
*U12 - P3&lt;br /&gt;
*Unit 18 - M1 - Analysing and showing the differences between programming languages&lt;br /&gt;
&lt;br /&gt;
Shorter names are recommeded.&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=error/gradereport_btec/nooutcomedata&amp;diff=57841</id>
		<title>error/gradereport btec/nooutcomedata</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=error/gradereport_btec/nooutcomedata&amp;diff=57841"/>
		<updated>2009-06-10T08:41:48Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: New page: This error relates to one of three things. Either there are no users in the course, no outcomes in the course or no activities with outcomes.  Each outcome name must conform to a standard ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This error relates to one of three things. Either there are no users in the course, no outcomes in the course or no activities with outcomes.&lt;br /&gt;
&lt;br /&gt;
Each outcome name must conform to a standard in order for it to be automatically recognised as a BTEC criteria and calculated. The outcome name must contain a P, M or D immediatelly followed by a number. There may be preceeding or following text, but there cannot be a space between the letter and number. Each of the following are valid BTEC criteria outcome names&lt;br /&gt;
P1&lt;br /&gt;
U12 - P3&lt;br /&gt;
Unit 18 - M1 - Analysing and showing the differences between programming languages&lt;br /&gt;
&lt;br /&gt;
Shorter names are recommeded&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Development:Installing_and_upgrading_plugin_database_tables&amp;diff=54251</id>
		<title>Development:Installing and upgrading plugin database tables</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Development:Installing_and_upgrading_plugin_database_tables&amp;diff=54251"/>
		<updated>2009-04-14T09:13:50Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
If you have done the right thing, Moodle will automatically create the database tables for your plugin when you visite the Admin notifications page (.../admin/index.php). This process is controlled by three files within your plugin:&lt;br /&gt;
;version.php : This records the version of the plugin code&lt;br /&gt;
;db/install.xml : This is used when someone installs your plugin for the first time.&lt;br /&gt;
;db/upgrade.php : This is used when someone who had an older version of your plugin installed upgrades to the latest version.&lt;br /&gt;
&lt;br /&gt;
In addition, Moodle also stores in the database the currently installed version of each plugin.&lt;br /&gt;
&lt;br /&gt;
In Moodle 1.9 and before, this is stored in the mdl_config table, in a row with the name &#039;&#039;plugintype&#039;&#039;_&#039;&#039;pluginname&#039;&#039;_version. For example qtype_myqtype_version. The exception to this rule are modules and blocks. Installed module version numbers are stored in the mdl_modules table. Block version numbers are in mdl_block.&lt;br /&gt;
&lt;br /&gt;
In Moodle 2.0 an beyond, plugin version numbers are stored in the mdl_config_plugins table, with &#039;&#039;plugintype&#039;&#039;_&#039;&#039;pluginname&#039;&#039; in the plugin column, and &#039;version&#039; in the name column - with the same exception for modules and blocks.&lt;br /&gt;
&lt;br /&gt;
==A specific example==&lt;br /&gt;
&lt;br /&gt;
For the rest of this document, I will use a particular example, because it should make the explanation easier. You should be able to see how to generalise it.&lt;br /&gt;
&lt;br /&gt;
We will suppose you that you are making a new question type myqtype. This is plugin type qtype, and the code will be in the question/type/myqtype folder. The currently installed version number will be stored in the qtype_myqtype_version row of the mdl_config table.&lt;br /&gt;
&lt;br /&gt;
In addition, we will just consider the first two releases of the plugin. The first release will have version number 2008080100, and will just use one database table mdl_question_myqtype, with two columns col1 and col2. Then we will suppose that the second release is 2008080200, and that requires an extra column, newcol, to be added to the mdl_question_myqtype table.&lt;br /&gt;
&lt;br /&gt;
==The files you need for the first release==&lt;br /&gt;
&lt;br /&gt;
In what follows, the bits of code you need to replace are &#039;&#039;&#039;in bold&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
;version.php&lt;br /&gt;
 $plugin-&amp;gt;version  = 2008080100;&lt;br /&gt;
 $plugin-&amp;gt;requires = &#039;&#039;&#039;XXXXXXXXXX; // Copy the current value from the top-level version.php file.&#039;&#039;&#039;&lt;br /&gt;
;db/install.xml&lt;br /&gt;
:This file, which you should [[Development:XMLDB_defining_an_XML_structure#The_XMLDB_editor|create with the XMLDB editor]], should contain the definition for your mdl_question_myqtype table, with the two columns col1 and col2.&lt;br /&gt;
&lt;br /&gt;
At this stage, you do not need a db/upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==The files you need for the second release==&lt;br /&gt;
&lt;br /&gt;
;version.php&lt;br /&gt;
 $plugin-&amp;gt;version  = 2008080200;&lt;br /&gt;
 $plugin-&amp;gt;requires = &#039;&#039;&#039;XXXXXXXXXX; // Copy the current value from the top-level version.php file.&#039;&#039;&#039;&lt;br /&gt;
;db/install.xml : This file should now contain the updated definition for your mdl_question_myqtype table, with three columns col1, col2 and newcol. You modify this file using the XMLDB editor.&lt;br /&gt;
;db/upgrade.php&lt;br /&gt;
:This file should contain the code that people need to run to upgrade from version 2008080100 of your plugin. That is, the code to add a column newcol to the mdl_question_myqtype table. You don&#039;t have to write this code yourself as the XMLDB editor will generate it for you. The upgrade.php file should contain a single function xmldb_qtype_myqtype_upgrade that looks a bit like:&lt;br /&gt;
 function xmldb_qtype_myqtype_upgrade($oldversion = 0) {&lt;br /&gt;
     $result = true;&lt;br /&gt;
 &lt;br /&gt;
     /// Add a new column newcol to the mdl_question_myqtype&lt;br /&gt;
     if ($result &amp;amp;&amp;amp; $oldversion &amp;lt; 2008080200) {&lt;br /&gt;
         &#039;&#039;&#039;// Code to add the column, generated by the &#039;View PHP Code&#039; option of the XMLDB editor.&#039;&#039;&#039;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     return $result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Hint: If you are modifying or adding a field/table, get the XMLDB editor to generate the PHP update code for you &#039;&#039;&#039;after&#039;&#039;&#039; making the changes in the editor. If you are deleting one, you need to generate the PHP code &#039;&#039;&#039;before&#039;&#039;&#039; making the change - or you won&#039;t be able to select the field/table to write the code for, because it no longer exists.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==What happens when a user installs or upgrades your plugin==&lt;br /&gt;
&lt;br /&gt;
The process is triggered when an administrator goes to the Admin notifications page (.../admin/index.php). The code that does the work is the upgrade_plugins function in lib/adminlib.php and reading this code is the best way to find out exactly what happens. In pseudo-code, what it does is:&lt;br /&gt;
&lt;br /&gt;
 For each plugin of this type (e.g. all qtype plugins) {&lt;br /&gt;
     // For the body of this loop, suppose the current plugin being processed is myqtype.&lt;br /&gt;
 &lt;br /&gt;
     Check that question/type/myqtype/version.php, .../db/upgrade.php and .../db/install.php exist.&lt;br /&gt;
 &lt;br /&gt;
     if ($CFG-&amp;gt;qtype_myqtype_version exists, and is less than the number in version.php) {&lt;br /&gt;
         Call the upgrade function xmldb_qtype_myqtype_upgrade from&lt;br /&gt;
                 upgrade.php, passing the old version number ($CFG-&amp;gt;qtype_myqtype_version)&lt;br /&gt;
                 which says what is currently installed&lt;br /&gt;
         Update $CFG-&amp;gt;qtype_myqtype_version to the latest number from version.php&lt;br /&gt;
                 to record what is currently installed&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     else if ($CFG-&amp;gt;qtype_myqtype_version does not exist) {&lt;br /&gt;
         Create the tables from the definitions in install.xml&lt;br /&gt;
         Update $CFG-&amp;gt;qtype_myqtype_version to the latest number from version.php&lt;br /&gt;
                 to record what is currently installed&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Of course, it is a bit more complex that than. However, the code in the upgrade_plugins is quite clear, and I encourage you to go and have a look at it so you can see all the details of how it works.&lt;br /&gt;
&lt;br /&gt;
Let us now look at some worked examples:&lt;br /&gt;
&lt;br /&gt;
===User installs version 2008080100 of myqtype===&lt;br /&gt;
&lt;br /&gt;
To start with, the mdl_question_myqtype does not exist, and there will not be a qtype_myqtype_version row in the mdl_config table.&lt;br /&gt;
&lt;br /&gt;
# The user will unzip myqtype.zip into the question/type folder.&lt;br /&gt;
# The user will visit the Admin notifications page.&lt;br /&gt;
# This will trigger Moodle to search for plugings to upgrade. It will find that the code for the qtype_myqtype plugin is now present, but there is no trace of it in the database, so it will install the plugin from the install.xml file.&lt;br /&gt;
&lt;br /&gt;
At the end of this process, the mdl_question_myqtype table will exist with the two columns col1 and col2; and the qtype_myqtype_version row in the mdl_config table will contain 2008080100.&lt;br /&gt;
&lt;br /&gt;
===User upgrades from version 2008080100 to version 2008080200 of myqtype===&lt;br /&gt;
&lt;br /&gt;
To start with, the mdl_question_myqtype table will exist with the two columns col1 and col2; and the qtype_myqtype_version row in the mdl_config table will contain 2008080100.&lt;br /&gt;
&lt;br /&gt;
# The user will delete the old question/type/myqtype folder.&lt;br /&gt;
# The user will unzip the new myqtype.zip into the question/type folder.&lt;br /&gt;
# The user will visit the Admin notifications page.&lt;br /&gt;
# This will trigger Moodle to search for plugings to upgrade. It will find that the code for version 2008080200 the qtype_myqtype plugin is now present, but the installed version of the the database tables (qtype_myqtype_version) is 2008080100. Therefore, it will call xmldb_qtype_myqtype_upgrade from upgrade.php, passing 2008080100 as the $oldversion argument.&lt;br /&gt;
&lt;br /&gt;
At the end of this process, the mdl_question_myqtype table will now have three columns col1, col2 and newcol; and the qtype_myqtype_version row in the mdl_config table will contain 2008080200.&lt;br /&gt;
&lt;br /&gt;
===User installs version 2008080200 of myqtype into a clean Moodle install===&lt;br /&gt;
&lt;br /&gt;
To start with, the mdl_question_myqtype does not exist, and there will not be a qtype_myqtype_version row in the mdl_config table.&lt;br /&gt;
&lt;br /&gt;
# The user will unzip the 2008080200 version of myqtype.zip into the question/type folder.&lt;br /&gt;
# The user will visit the Admin notifications page.&lt;br /&gt;
# This will trigger Moodle to search for plugings to upgrade. It will find that the code for the qtype_myqtype plugin is now present, but there is no trace of it in the database, so it will install the plugin from the install.xml file.&lt;br /&gt;
&lt;br /&gt;
At the end of this process, the mdl_question_myqtype table will exist with three columns col1, col2 and newcol; and the qtype_myqtype_version row in the mdl_config table will contain 2008080200.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
The first time a user installs any version of your plugin, the install.xml file will be used to create all the required database tables. Therefore install.xml should always contain the definition of the up-to-date database structure. Moodle recognises this situation because there is a version.php file on disc, but there is no &#039;&#039;plugintype&#039;&#039;_&#039;&#039;pluginname&#039;&#039;_version value in the mdl_config table.&lt;br /&gt;
&lt;br /&gt;
If the user already had a version of your plugin installed, and then upgrades to a newer version, Moodle will detect this because the version.php file will contain a newer version number than the &#039;&#039;plugintype&#039;&#039;_&#039;&#039;pluginname&#039;&#039;_version value in the mdl_config table. In this case, Moodle will run the code in the upgrade.php file, passing in the old version number, so that the correct bits of upgrade can be run, as controlled by the if ($oldversion &amp;lt; XXXXXXXXXX) blocks of code.&lt;br /&gt;
&lt;br /&gt;
The contents of the install.xml and upgrade.php files should be generated using the XMLDB editor.&lt;br /&gt;
&lt;br /&gt;
==Database upgrades and stable branches==&lt;br /&gt;
&lt;br /&gt;
The simple rule is, never make any database changes on a stable branch. You only need to read this section in the rare situations where a database change on the stable branch is unavoidable.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning!!! advanced material follows.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Suppose, in order to fix a bug, you need to make a database change in Moodle 1.9.3+ (which must also be merged into HEAD). The root of the problem is that people may upgrade their Moodle in three different ways, which &lt;br /&gt;
&lt;br /&gt;
* Upgrade from &amp;lt;=1.9.3 to 1.9.4 - this executes the ugprade script on the 1.9 branch.&lt;br /&gt;
* Upgrade from &amp;lt;=1.9.3 directly to &amp;gt;=2.0 - this executes the upgrade script on the HEAD branch.&lt;br /&gt;
* Upgrade from 1.9.4 to &amp;gt;=2.0 - in this case, you must ensure that the upgrade on HEAD is not executed.&lt;br /&gt;
&lt;br /&gt;
The normal way to do this is ensure that your database upgrade is idempotent. That is, it does not matter if you do it twice. So for example, instead of doing&lt;br /&gt;
&lt;br /&gt;
        $dbman-&amp;gt;create_table($table);&lt;br /&gt;
&lt;br /&gt;
you should do&lt;br /&gt;
&lt;br /&gt;
        if (!$dbman-&amp;gt;table_exists($table)) {&lt;br /&gt;
            $dbman-&amp;gt;create_table($table);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
You should also think about what version numbers to put in your version.php file on each branch. Above all, test carefully.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB_Documentation|XMLDB_Documentation]]&lt;br /&gt;
* [[Development:Coding|Coding guidelines]]&lt;br /&gt;
* [[Development:DDL functions|DDL functions]]&lt;br /&gt;
* [[Development:XMLDB defining an XML structure|install.xml file documentation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=NTLM_authentication&amp;diff=33500</id>
		<title>NTLM authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=NTLM_authentication&amp;diff=33500"/>
		<updated>2008-03-12T11:55:47Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Installation on 1.9 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.9}}This document describes how to set up NTLM/Integrated Authentication in Moodle. &lt;br /&gt;
&lt;br /&gt;
This is integrated into Moodle 1.9 onwards.&lt;br /&gt;
&lt;br /&gt;
For earlier versions, it uses a modified version of LDAP Authentication.&lt;br /&gt;
The NTLM Authentication module is available in the Modules and Plugins database here:&lt;br /&gt;
http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Assumptions==&lt;br /&gt;
&lt;br /&gt;
#You are running MS Active Directory for Authentication.&lt;br /&gt;
#The Server hosting your website is a member of the Active Directory Domain that your users are also members of.&lt;br /&gt;
#You are able to define people inside your Network (and authenticated to the Domain) from an IP range or IP range of computers.&lt;br /&gt;
#You have &amp;quot;some&amp;quot; basic knowledge of php and are able to configure the index.php with the range of internal IP addresses.&lt;br /&gt;
#You are familar with or have read the LDAP authentication documentation.&lt;br /&gt;
#The Active Directory domain credentials of your users are returned as &#039;&#039;&#039;DOMAINNAME\username&#039;&#039;&#039; from your authentication service. If you are using the Winbind service from the Samba project, this can be untrue, depending on your Winbind configuration settings.&lt;br /&gt;
&lt;br /&gt;
If you can not modify your settings to satisfy this last assumption, then you will need to remove or comment out the line that reads:&lt;br /&gt;
    $username = substr(strrchr($username, &#039;\\&#039;), 1); //strip domain info&lt;br /&gt;
and add the relevant lines of code to extract the username part from the domain user credentials and store it in $username.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.9==&lt;br /&gt;
&lt;br /&gt;
No installation needed. See the Auth/LDAP settings for the NTLM config options. You only have to&lt;br /&gt;
&lt;br /&gt;
*Set the subnet mask&lt;br /&gt;
*On IIS: turn on Integrated Authentication&lt;br /&gt;
*On Apache - use one of the 3 methods outlined below&lt;br /&gt;
&lt;br /&gt;
If you have used previous versions of NTLM in your Moodle database you will need to make two further changes. &lt;br /&gt;
&lt;br /&gt;
#The type of authentication held against each user now needs to be ldap, and ntlm will not be recognised and Moodle will fall through and try to use CAS. To edit the fields open up a sql query for your Moodle server and use the following query &amp;quot;update mdl_user set auth = &#039;ldap&#039; where auth = &#039;ntlm&#039; &amp;quot;&lt;br /&gt;
#If you had a previous .htaccess file in the auth/ntlm directory, you will need to move it to the auth/ldap directory. Regardless of whether it is in a .htaccess file of the httpd.conf, the &amp;lt;Files&amp;gt; line now needs to refer to ntlmsso_magic.php. If it is in the httpd.conf, the &amp;lt;Directory&amp;gt; will need to change too. This is covered later on for new installs, but is one of the fundamental changes that needs to be made for those upgrading.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.6/1.7==&lt;br /&gt;
#Copy the folder AUTH/NTLM into the AUTH folder of your moodle installation.&lt;br /&gt;
#Configure the IP/Subnet Mask in the Config screen.&lt;br /&gt;
[https://docs.moodle.org/en/NTLM_authentication#Configuring IP/Subnet Mask see below for more help]&lt;br /&gt;
If the IP/Subnet Mask does not give enough complexity for your network, Modify the auth/ntlm/index.php file - for instructions on doing this, view the comments in the file.&lt;br /&gt;
#Turn Integrated Authentication ON and Anonymous Authentication OFF for the moodle\auth\ntlm\oncampuslogin.php file. [https://docs.moodle.org/en/NTLM_authentication#How_to_Turn_Integrated_Authentication_on see below for more detailed instructions]&lt;br /&gt;
#Visit the admin page of your moodle installation - you should see notification that the NTLM_AUTH module has been installed.&lt;br /&gt;
#go to the configuration &amp;gt; variables page, find the dbsessions setting (in 1.8 on admin page server \ sessions page), and set it to &amp;quot;YES&amp;quot; then save the page.&lt;br /&gt;
#go to the Authentication admin page and select auth_ntlmtitle as your authentication method Note: - this doesn&#039;t display full text as I haven&#039;t created a language file for this module - you will also see auth_ntlmdescription instead of a proper description - you don&#039;t need to worry about this, as you will be the only one who ever sees this.&lt;br /&gt;
#Configure this page with your normal LDAP settings. NOTE: the Alternate Login URL at the bottom of this page (or on the main authentication page in 1.8 - and needs to be set manually to the oncampus url)has been set to the NTLM page. - if you wish uninstall this auth module, you must reset this variable on the new authentication type page. eg - if you wish to revert back to manual authentication, then change to manual, and then make sure you delete the alternate login url at the bottom of the page.&lt;br /&gt;
#(OPTIONAL) modify the offcampuslogin page to give errors when students try to prefix their usercode with your domain.&lt;br /&gt;
around line 216 find this code, uncomment all the lines and replace the letters &#039;DOM&#039; with your domain:&lt;br /&gt;
&lt;br /&gt;
    if (empty($errormsg)) {&lt;br /&gt;
        if (strstr(strtolower($frm-&amp;gt;username), &amp;quot;DOM\\&amp;quot;) &amp;lt;&amp;gt; false) { //NAD - DOM messages.&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; DOM\\ is not required!&amp;quot;;&lt;br /&gt;
        } else if (strpos($frm-&amp;gt;username, &amp;quot;@&amp;quot;) &amp;lt;&amp;gt; false) {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; enter your username - not your e-mail address.&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.5==&lt;br /&gt;
&lt;br /&gt;
See the README in the auth/ntml package.&lt;br /&gt;
&lt;br /&gt;
==How to Turn Integrated Authentication on==&lt;br /&gt;
The File ntlmsso_magic.php (1.9 or above) or oncampuslogin.php (1.8 or below) MUST have NTLM/Integrated Authentication enabled at the server or the page will not work.&lt;br /&gt;
===IIS Configuration===&lt;br /&gt;
Open up IIS, and find the auth/ldap/ntlmsso_magic.php (1.9 or above) or auth/ntlm/oncampuslogin.php (1.8 or below) file, &lt;br /&gt;
#right click on the file, choose properties&lt;br /&gt;
#under the &amp;quot;file security&amp;quot; tab, click on the Authentication and Access control &amp;quot;edit&amp;quot; button&lt;br /&gt;
#untick &amp;quot;Enable Anonymous Access&amp;quot; and tick &amp;quot;Integrated Windows Authentication&amp;quot;&lt;br /&gt;
===APACHE Configuration===&lt;br /&gt;
There are currently 3 possible methods for this:&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM part of Samba (Linux)====&lt;br /&gt;
&lt;br /&gt;
* Get the plugin here: http://samba.org/ftp/unpacked/lorikeet/mod_auth_ntlm_winbind/ and follow the instructions inside the README file. You&#039;ll need to install the Apache development packages in addition to the core C develpment packages.&lt;br /&gt;
* Once you have compiled it, put it inside Apache&#039;s modules subdirectory (this location depends on a number of factors, like compiling Apache yourself, using different Linux distributions packages, an so on), and load and enable the module in Apache&#039;s configuration. For example, if your Apache modules are under &amp;lt;code&amp;gt;/usr/lib/apache2/modules&amp;lt;/code&amp;gt;, you&#039;ll need something like this in your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;IfModule !mod_auth_ntlm_winbind.c&amp;gt;&lt;br /&gt;
       LoadModule auth_ntlm_winbind_module /usr/lib/apache2/modules/mod_auth_ntlm_winbind.so&lt;br /&gt;
   &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install the Samba &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; daemon package. This packages relies on Samba&#039;s configuration file to get some important settings (like the Windows domain name, uid and gid range mappings, and so on). In addition to that, you&#039;ll need to make your Linux/Unix machine part of the domain. Otherwise winbind won&#039;t be able to pull user and groups informationi from the domain controllers. You should read the Samba documentation to perform this step, but the most important part is having something like the following lines in your &amp;lt;code&amp;gt;smb.conf&amp;lt;/code&amp;gt; file (in addition to what you already have there):&lt;br /&gt;
&lt;br /&gt;
  workgroup = DOMAINNAME&lt;br /&gt;
  password server = *&lt;br /&gt;
  security = domain&lt;br /&gt;
  encrypt passwords = true&lt;br /&gt;
  idmap uid = 10000-20000&lt;br /&gt;
  idmap gid = 10000-20000&lt;br /&gt;
&lt;br /&gt;
: and executing the command (as root):&lt;br /&gt;
&lt;br /&gt;
  # net join DOMAINNAME -U Administrator&lt;br /&gt;
&lt;br /&gt;
: where &#039;&#039;&#039;DOMAINNAME&#039;&#039;&#039; is the NetBIOS windows domain name, and &#039;&#039;&#039;Administrator&#039;&#039;&#039; an account with enough privileges to add new machines to the domain.&amp;lt;br/&amp;gt; You&#039;ll need to type this account&#039;s password for the command to succeed.&lt;br /&gt;
&lt;br /&gt;
: Also, make sure you have disabled &amp;quot;Microsoft Network Server: digitally sign communications (always)&amp;quot; in your Domain Controllers Security Policy, unless you are using a version of Samba that can sign SMB packets.&lt;br /&gt;
&lt;br /&gt;
* Restart the &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; service to apply the changes and test that it&#039;s running ok by executing:&lt;br /&gt;
&lt;br /&gt;
  $ wbinfo -u&lt;br /&gt;
&lt;br /&gt;
: You should get the full list of Windows domain users. If you use &#039;&#039;&#039;&amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt;&#039;&#039;&#039; instead, you&#039;ll get the domain groups list.&lt;br /&gt;
&lt;br /&gt;
* Check that your &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; package installed the authentication helper command &amp;lt;code&amp;gt;ntlm_auth&amp;lt;/code&amp;gt;, as we&#039;ll need it later. We&#039;ll assume the helper is located at &amp;lt;code&amp;gt;/usr/bin/ntlm_auth&amp;lt;/code&amp;gt;. If yours is at a different location, make sure you adjust the path in the example below.&lt;br /&gt;
&lt;br /&gt;
* Add something like this to your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;). We&#039;ll assume that your Moodle &amp;lt;code&amp;gt;$CFG-&amp;gt;dirroot&amp;lt;/code&amp;gt; directory is located at &amp;lt;code&amp;gt;/var/www/moodle&amp;lt;/code&amp;gt; in the example:&lt;br /&gt;
: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ldap/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ntlm/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
* Check the permissions of the Winbind pipe directory (Ubuntu places it under &amp;lt;code&amp;gt;/var/run/samba/winbindd_privileged&amp;lt;/code&amp;gt;, yours may be placed at a different location). Apache will need to be able to enter that directory, so we need to make sure it has the right permissions. So have a look at the permissions of that directory and note the name of the group assigned to it. The following example is from a Ubuntu 7.10 machine:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ald /var/run/samba/winbindd_privileged&lt;br /&gt;
  drwxr-x--- 2 root winbindd_priv 60 2007-11-17 16:18 /var/run/samba/winbindd_privileged/&lt;br /&gt;
&lt;br /&gt;
:so we see the group is &amp;lt;code&amp;gt;winbindd_priv&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Instead of modifying the directory permissions (which could break other services that use winbind) we are goint to make the Apache user (&amp;lt;code&amp;gt;www-data&amp;lt;/code&amp;gt; in our example, but could be &amp;lt;code&amp;gt;httpd&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;nobody&amp;lt;/code&amp;gt;, etc.) is part of the appropiate group. Execute the following as root:&lt;br /&gt;
&lt;br /&gt;
  # adduser www-data winbindd_priv&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt; is available in Debian and Ubuntu at least. If your distribution doesn&#039;t have &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt;, you can edit &amp;lt;code&amp;gt;/etc/group&amp;lt;/code&amp;gt; manually to achive the same effect.&lt;br /&gt;
&lt;br /&gt;
* Restart the Apache service to apply the changes. Have a look at Apache&#039;s error log to see that everything is ok.&lt;br /&gt;
&lt;br /&gt;
* Couple of gotchas - in Fedora Core, keep alive is turned OFF by default in the httpd.conf - see this bug for further info: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=188138&amp;lt;br /&amp;gt;&lt;br /&gt;
* Email Dan if you get this working - I&#039;m keen to hear how people go using the samba winbind option!&lt;br /&gt;
::-- Hi Dan! I made it work using Ubuntu 7.04. That&#039;s what I&#039;ve used to update the documentation. [[User:Iñaki Arenaza|Iñaki Arenaza]] 10:43, 30 September 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM Auth Module for Apache====&lt;br /&gt;
#get the Module from: http://modntlm.sourceforge.net/&lt;br /&gt;
#use something like this in your httpd.conf: http://moodle.org/mod/forum/discuss.php?d=45887#211074&lt;br /&gt;
&lt;br /&gt;
====Using the mod_auth_sspi Module for Apache 2 on Windows====&lt;br /&gt;
NOTE: This setup is currently being used in a live production environment, and is therefore suitable for such use provided it is correctly configured and tested.&lt;br /&gt;
&lt;br /&gt;
This is the recommended method for Apache 2 on Windows, however it will &#039;&#039;&#039;not&#039;&#039;&#039; work on Linux/UNIX systems.&lt;br /&gt;
It provides better stability and higher performance than other NTLM modules.&lt;br /&gt;
&lt;br /&gt;
* Download the mod_auth_sspi Module from: http://sourceforge.net/projects/mod-auth-sspi/. At the moment of writing this (2007.09.30), the current version is mod_auth_sspi 1.0.4, which has two different ZIP files to download:&lt;br /&gt;
&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.0.58.zip :   Use this file if you are using Apache 2.0.x.&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.2.2.zip :   Use this file if you are using Apache 2.2.x.&lt;br /&gt;
&lt;br /&gt;
* Unzip the right file and copy mod_auth_sspi.so (it&#039;s inside &#039;&#039;&#039;bin&#039;&#039;&#039; subdirectory) to your Apache modules directory.&lt;br /&gt;
* Edit your Apache 2 configuration file (httpd.conf) to load the module.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;IfModule !mod_auth_sspi.c&amp;gt;&lt;br /&gt;
        LoadModule sspi_auth_module modules/mod_auth_sspi.so&lt;br /&gt;
    &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Choose one of the two methods below&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 1&#039;&#039;&#039;: This method is recommended for servers that will host a single Moodle instance. Configure NTLM from the main configuration file, add the following to httpd.conf (substitute &amp;quot;C:\moodle&amp;quot; with the path to your Moodle installation e.g. &amp;quot;C:\my-moodle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ldap&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ntlm&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 2&#039;&#039;&#039;: The alternative method is to use a .htaccess file&lt;br /&gt;
:This method is recommended for servers that will host multiple Moodle instances. It allows additional Moodle instances to be configured without restarting apache, and also makes the solution a little more portable. We need to add a directive to the main httpd.conf to allow configuration of authentication within .htaccess files.&lt;br /&gt;
    &amp;lt;Directory C:\moodle&amp;gt;&lt;br /&gt;
        AllowOverride AuthConfig&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ldap&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ntlm&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This enables the Moodle folder to be moved to any apache webserver that is configured to allow authentication configuration through .htaccess&lt;br /&gt;
&lt;br /&gt;
For further help and discussion: http://moodle.org/mod/forum/discuss.php?d=56565&lt;br /&gt;
&lt;br /&gt;
==Configuring IP/Subnet Mask==&lt;br /&gt;
Subnet masks are based on binary patterns so need a bit of knowledge to understand. The best way to find out what IP/Subnet masks to use is to ask your Network Admin. &lt;br /&gt;
* &#039;&#039;&#039;(pre-1.9 only)&#039;&#039;&#039; Once you have configured your IP/Subnet masks, you can use the check_ip.php page to test if you have set these ranges up correctly.&lt;br /&gt;
* The new way of specifiying subnets is even easier/more flexible than before 1.9. Just type them one after the other, separated by commas. You can use several syntaxes:&lt;br /&gt;
** Type the network-number/prefix-length combination. E.g. 192.168.1.0/24&lt;br /&gt;
** Type the network &#039;prefix&#039;, ending in a period character. E.g. 192.168.1.&lt;br /&gt;
** Type the network address range (&#039;&#039;&#039;this only works for the last address octect&#039;&#039;&#039;). E.g. 192.168.1.1-254&lt;br /&gt;
:All the three examples refer to the same subnetwork.&lt;br /&gt;
* So assuming you need to specify the following subnetworks:&lt;br /&gt;
** 10.1.0/255.255.0.0&lt;br /&gt;
** 10.2.0.0/255.255.0.0&lt;br /&gt;
** 172.16.0.0/255.255.0.0&lt;br /&gt;
** 192.168.100.0/255.255.255.240&lt;br /&gt;
:You can type:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.0/28&lt;br /&gt;
: or:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.240-255&lt;br /&gt;
:or even:&lt;br /&gt;
  10.1., 10.2., 172.16., 192.168.100.0/28&lt;br /&gt;
:(the last one cannot be expressed as a network &#039;prefix&#039; as the netmask does not fall in an octect boundary).&lt;br /&gt;
&lt;br /&gt;
==Notes/Tips==&lt;br /&gt;
# (pre-1.9 only) When using IIS, dbsessions is required to be set to &amp;quot;YES&amp;quot; because when Integrated authentication is turned on for the oncampuslogin.php page, and dbsessions is set to &amp;quot;NO&amp;quot; then the server impersonates the user to write the session in the moodledata\sessions folder. The recommended fix is to set dbsessions to &amp;quot;YES&amp;quot; so that sessions are stored in the db. The non-recommended alternative method is to allow domain users write access to the sessions directory.&lt;br /&gt;
# (pre-1.9 only) If you forget to change the internal IP addresses in index.php to your own, you can just use the offcampuslogin url to login using your admin account. eg: http://yoursite.com/moodle/auth/ntlm/offcampuslogin.php&lt;br /&gt;
#If you are using Firefox, you will need to follow these steps:&lt;br /&gt;
:*Load Firefox and type about:config in the address box. The configuration settings page should be displayed.&lt;br /&gt;
:*In the Filter box, type the word &amp;quot;ntlm&amp;quot; to filter the NTLM strings. You should see three settings displayed.&lt;br /&gt;
:*Double-click on &amp;quot;network.automatic-ntlm-auth.trusted-uris&amp;quot;.&lt;br /&gt;
:*In the box, enter the full URL of your Moodle server. For example &amp;lt;pre&amp;gt;http://moodle.mydomain.com&amp;lt;/pre&amp;gt;&lt;br /&gt;
:*Close Firefox and restart.&lt;br /&gt;
&lt;br /&gt;
==Specific File information== &lt;br /&gt;
(mainly for developers)&lt;br /&gt;
#auth\ntlm\index.php&amp;lt;br /&amp;gt;This is the page used for the Alternate Login URL setting on the config page for the NTLM plugin.&amp;lt;br&amp;gt;The index.php file handles which login page to use based on the IP address of the user.&amp;lt;br&amp;gt;if inside your network, they should be directed to the oncampuslogin.php screen.&amp;lt;br&amp;gt;if outside your network, they should be directed to the offcampuslogin.php screen.&amp;lt;br&amp;gt;you will need to modify the if statements in this file to match the IP ranges inside your network.&lt;br /&gt;
#auth\ntlm\index_form.html&amp;lt;br /&amp;gt;this is a copy of the file login\index_form.php.&amp;lt;br /&amp;gt; The only change in this file from the standard one is that the form action=&amp;quot;index.php&amp;quot; is changed to form action=&amp;quot;offcampuslogin.php&amp;quot; this is because anyone who is displayed the form will be an offcampus user.&lt;br /&gt;
#auth\ntlm\offcampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file moodle\login\index.php with a couple of minor modifications.&amp;lt;br /&amp;gt;the modifications to this file involve the setting of a variable ($onoroffcampus = &amp;quot;offcampus&amp;quot;;) this is used by the auth plugin to define which page is being used for authentication. the other modification is for displaying extra error messages to the user. - with all the authentication methods we have students are constantly confused about how to enter their credentials if you use NTLM authentication elsewhere at your site you will be aware of the users having to enter the domain\username when authenticating. - this code block sits around line 215 in the file.&lt;br /&gt;
#auth\ntlm\oncampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file login\index.php&amp;lt;br /&amp;gt;This file has been modified to get the details of the authenticated user via NTLM.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=45887 NTLM Authentication] forum discussion&lt;br /&gt;
*[http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314 Download the NTLM Authentication Module]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=80104 Merging AD NTLM SSO into auth/ldap] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Authentification NTLM]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=NTLM_authentication&amp;diff=33499</id>
		<title>NTLM authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=NTLM_authentication&amp;diff=33499"/>
		<updated>2008-03-12T11:54:29Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Installation on 1.9 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.9}}This document describes how to set up NTLM/Integrated Authentication in Moodle. &lt;br /&gt;
&lt;br /&gt;
This is integrated into Moodle 1.9 onwards.&lt;br /&gt;
&lt;br /&gt;
For earlier versions, it uses a modified version of LDAP Authentication.&lt;br /&gt;
The NTLM Authentication module is available in the Modules and Plugins database here:&lt;br /&gt;
http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Assumptions==&lt;br /&gt;
&lt;br /&gt;
#You are running MS Active Directory for Authentication.&lt;br /&gt;
#The Server hosting your website is a member of the Active Directory Domain that your users are also members of.&lt;br /&gt;
#You are able to define people inside your Network (and authenticated to the Domain) from an IP range or IP range of computers.&lt;br /&gt;
#You have &amp;quot;some&amp;quot; basic knowledge of php and are able to configure the index.php with the range of internal IP addresses.&lt;br /&gt;
#You are familar with or have read the LDAP authentication documentation.&lt;br /&gt;
#The Active Directory domain credentials of your users are returned as &#039;&#039;&#039;DOMAINNAME\username&#039;&#039;&#039; from your authentication service. If you are using the Winbind service from the Samba project, this can be untrue, depending on your Winbind configuration settings.&lt;br /&gt;
&lt;br /&gt;
If you can not modify your settings to satisfy this last assumption, then you will need to remove or comment out the line that reads:&lt;br /&gt;
    $username = substr(strrchr($username, &#039;\\&#039;), 1); //strip domain info&lt;br /&gt;
and add the relevant lines of code to extract the username part from the domain user credentials and store it in $username.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.9==&lt;br /&gt;
&lt;br /&gt;
No installation needed. See the Auth/LDAP settings for the NTLM config options. You only have to&lt;br /&gt;
&lt;br /&gt;
*Set the subnet mask&lt;br /&gt;
*On IIS: turn on Integrated Authentication&lt;br /&gt;
*On Apache - use one of the 3 methods outlined below&lt;br /&gt;
&lt;br /&gt;
If you have used previous versions of NTLM in your Moodle database you will need to make two further changes. &lt;br /&gt;
&lt;br /&gt;
#The type of authentication held against each user now needs to be ldap, and ntlm will not be recognised and Moodle will fall through and try to use CAS. To edit the fields open up a sql query for your Moodle server and use the following:&lt;br /&gt;
&lt;br /&gt;
update mdl_user &lt;br /&gt;
set auth = &#039;ldap&#039;&lt;br /&gt;
where auth = &#039;ntlm&#039;&lt;br /&gt;
&lt;br /&gt;
#If you had a previous .htaccess file in the auth/ntlm directory, you will need to move it to the auth/ldap directory. Regardless of whether it is in a .htaccess file of the httpd.conf, the &amp;lt;Files&amp;gt; line now needs to refer to ntlmsso_magic.php. If it is in the httpd.conf, the &amp;lt;Directory&amp;gt; will need to change too. &lt;br /&gt;
This is covered later on for new installs, but is one of the fundamental changes that needs to be made for those upgrading.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.6/1.7==&lt;br /&gt;
#Copy the folder AUTH/NTLM into the AUTH folder of your moodle installation.&lt;br /&gt;
#Configure the IP/Subnet Mask in the Config screen.&lt;br /&gt;
[https://docs.moodle.org/en/NTLM_authentication#Configuring IP/Subnet Mask see below for more help]&lt;br /&gt;
If the IP/Subnet Mask does not give enough complexity for your network, Modify the auth/ntlm/index.php file - for instructions on doing this, view the comments in the file.&lt;br /&gt;
#Turn Integrated Authentication ON and Anonymous Authentication OFF for the moodle\auth\ntlm\oncampuslogin.php file. [https://docs.moodle.org/en/NTLM_authentication#How_to_Turn_Integrated_Authentication_on see below for more detailed instructions]&lt;br /&gt;
#Visit the admin page of your moodle installation - you should see notification that the NTLM_AUTH module has been installed.&lt;br /&gt;
#go to the configuration &amp;gt; variables page, find the dbsessions setting (in 1.8 on admin page server \ sessions page), and set it to &amp;quot;YES&amp;quot; then save the page.&lt;br /&gt;
#go to the Authentication admin page and select auth_ntlmtitle as your authentication method Note: - this doesn&#039;t display full text as I haven&#039;t created a language file for this module - you will also see auth_ntlmdescription instead of a proper description - you don&#039;t need to worry about this, as you will be the only one who ever sees this.&lt;br /&gt;
#Configure this page with your normal LDAP settings. NOTE: the Alternate Login URL at the bottom of this page (or on the main authentication page in 1.8 - and needs to be set manually to the oncampus url)has been set to the NTLM page. - if you wish uninstall this auth module, you must reset this variable on the new authentication type page. eg - if you wish to revert back to manual authentication, then change to manual, and then make sure you delete the alternate login url at the bottom of the page.&lt;br /&gt;
#(OPTIONAL) modify the offcampuslogin page to give errors when students try to prefix their usercode with your domain.&lt;br /&gt;
around line 216 find this code, uncomment all the lines and replace the letters &#039;DOM&#039; with your domain:&lt;br /&gt;
&lt;br /&gt;
    if (empty($errormsg)) {&lt;br /&gt;
        if (strstr(strtolower($frm-&amp;gt;username), &amp;quot;DOM\\&amp;quot;) &amp;lt;&amp;gt; false) { //NAD - DOM messages.&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; DOM\\ is not required!&amp;quot;;&lt;br /&gt;
        } else if (strpos($frm-&amp;gt;username, &amp;quot;@&amp;quot;) &amp;lt;&amp;gt; false) {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; enter your username - not your e-mail address.&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.5==&lt;br /&gt;
&lt;br /&gt;
See the README in the auth/ntml package.&lt;br /&gt;
&lt;br /&gt;
==How to Turn Integrated Authentication on==&lt;br /&gt;
The File ntlmsso_magic.php (1.9 or above) or oncampuslogin.php (1.8 or below) MUST have NTLM/Integrated Authentication enabled at the server or the page will not work.&lt;br /&gt;
===IIS Configuration===&lt;br /&gt;
Open up IIS, and find the auth/ldap/ntlmsso_magic.php (1.9 or above) or auth/ntlm/oncampuslogin.php (1.8 or below) file, &lt;br /&gt;
#right click on the file, choose properties&lt;br /&gt;
#under the &amp;quot;file security&amp;quot; tab, click on the Authentication and Access control &amp;quot;edit&amp;quot; button&lt;br /&gt;
#untick &amp;quot;Enable Anonymous Access&amp;quot; and tick &amp;quot;Integrated Windows Authentication&amp;quot;&lt;br /&gt;
===APACHE Configuration===&lt;br /&gt;
There are currently 3 possible methods for this:&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM part of Samba (Linux)====&lt;br /&gt;
&lt;br /&gt;
* Get the plugin here: http://samba.org/ftp/unpacked/lorikeet/mod_auth_ntlm_winbind/ and follow the instructions inside the README file. You&#039;ll need to install the Apache development packages in addition to the core C develpment packages.&lt;br /&gt;
* Once you have compiled it, put it inside Apache&#039;s modules subdirectory (this location depends on a number of factors, like compiling Apache yourself, using different Linux distributions packages, an so on), and load and enable the module in Apache&#039;s configuration. For example, if your Apache modules are under &amp;lt;code&amp;gt;/usr/lib/apache2/modules&amp;lt;/code&amp;gt;, you&#039;ll need something like this in your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;IfModule !mod_auth_ntlm_winbind.c&amp;gt;&lt;br /&gt;
       LoadModule auth_ntlm_winbind_module /usr/lib/apache2/modules/mod_auth_ntlm_winbind.so&lt;br /&gt;
   &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install the Samba &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; daemon package. This packages relies on Samba&#039;s configuration file to get some important settings (like the Windows domain name, uid and gid range mappings, and so on). In addition to that, you&#039;ll need to make your Linux/Unix machine part of the domain. Otherwise winbind won&#039;t be able to pull user and groups informationi from the domain controllers. You should read the Samba documentation to perform this step, but the most important part is having something like the following lines in your &amp;lt;code&amp;gt;smb.conf&amp;lt;/code&amp;gt; file (in addition to what you already have there):&lt;br /&gt;
&lt;br /&gt;
  workgroup = DOMAINNAME&lt;br /&gt;
  password server = *&lt;br /&gt;
  security = domain&lt;br /&gt;
  encrypt passwords = true&lt;br /&gt;
  idmap uid = 10000-20000&lt;br /&gt;
  idmap gid = 10000-20000&lt;br /&gt;
&lt;br /&gt;
: and executing the command (as root):&lt;br /&gt;
&lt;br /&gt;
  # net join DOMAINNAME -U Administrator&lt;br /&gt;
&lt;br /&gt;
: where &#039;&#039;&#039;DOMAINNAME&#039;&#039;&#039; is the NetBIOS windows domain name, and &#039;&#039;&#039;Administrator&#039;&#039;&#039; an account with enough privileges to add new machines to the domain.&amp;lt;br/&amp;gt; You&#039;ll need to type this account&#039;s password for the command to succeed.&lt;br /&gt;
&lt;br /&gt;
: Also, make sure you have disabled &amp;quot;Microsoft Network Server: digitally sign communications (always)&amp;quot; in your Domain Controllers Security Policy, unless you are using a version of Samba that can sign SMB packets.&lt;br /&gt;
&lt;br /&gt;
* Restart the &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; service to apply the changes and test that it&#039;s running ok by executing:&lt;br /&gt;
&lt;br /&gt;
  $ wbinfo -u&lt;br /&gt;
&lt;br /&gt;
: You should get the full list of Windows domain users. If you use &#039;&#039;&#039;&amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt;&#039;&#039;&#039; instead, you&#039;ll get the domain groups list.&lt;br /&gt;
&lt;br /&gt;
* Check that your &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; package installed the authentication helper command &amp;lt;code&amp;gt;ntlm_auth&amp;lt;/code&amp;gt;, as we&#039;ll need it later. We&#039;ll assume the helper is located at &amp;lt;code&amp;gt;/usr/bin/ntlm_auth&amp;lt;/code&amp;gt;. If yours is at a different location, make sure you adjust the path in the example below.&lt;br /&gt;
&lt;br /&gt;
* Add something like this to your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;). We&#039;ll assume that your Moodle &amp;lt;code&amp;gt;$CFG-&amp;gt;dirroot&amp;lt;/code&amp;gt; directory is located at &amp;lt;code&amp;gt;/var/www/moodle&amp;lt;/code&amp;gt; in the example:&lt;br /&gt;
: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ldap/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ntlm/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
* Check the permissions of the Winbind pipe directory (Ubuntu places it under &amp;lt;code&amp;gt;/var/run/samba/winbindd_privileged&amp;lt;/code&amp;gt;, yours may be placed at a different location). Apache will need to be able to enter that directory, so we need to make sure it has the right permissions. So have a look at the permissions of that directory and note the name of the group assigned to it. The following example is from a Ubuntu 7.10 machine:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ald /var/run/samba/winbindd_privileged&lt;br /&gt;
  drwxr-x--- 2 root winbindd_priv 60 2007-11-17 16:18 /var/run/samba/winbindd_privileged/&lt;br /&gt;
&lt;br /&gt;
:so we see the group is &amp;lt;code&amp;gt;winbindd_priv&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Instead of modifying the directory permissions (which could break other services that use winbind) we are goint to make the Apache user (&amp;lt;code&amp;gt;www-data&amp;lt;/code&amp;gt; in our example, but could be &amp;lt;code&amp;gt;httpd&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;nobody&amp;lt;/code&amp;gt;, etc.) is part of the appropiate group. Execute the following as root:&lt;br /&gt;
&lt;br /&gt;
  # adduser www-data winbindd_priv&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt; is available in Debian and Ubuntu at least. If your distribution doesn&#039;t have &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt;, you can edit &amp;lt;code&amp;gt;/etc/group&amp;lt;/code&amp;gt; manually to achive the same effect.&lt;br /&gt;
&lt;br /&gt;
* Restart the Apache service to apply the changes. Have a look at Apache&#039;s error log to see that everything is ok.&lt;br /&gt;
&lt;br /&gt;
* Couple of gotchas - in Fedora Core, keep alive is turned OFF by default in the httpd.conf - see this bug for further info: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=188138&amp;lt;br /&amp;gt;&lt;br /&gt;
* Email Dan if you get this working - I&#039;m keen to hear how people go using the samba winbind option!&lt;br /&gt;
::-- Hi Dan! I made it work using Ubuntu 7.04. That&#039;s what I&#039;ve used to update the documentation. [[User:Iñaki Arenaza|Iñaki Arenaza]] 10:43, 30 September 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM Auth Module for Apache====&lt;br /&gt;
#get the Module from: http://modntlm.sourceforge.net/&lt;br /&gt;
#use something like this in your httpd.conf: http://moodle.org/mod/forum/discuss.php?d=45887#211074&lt;br /&gt;
&lt;br /&gt;
====Using the mod_auth_sspi Module for Apache 2 on Windows====&lt;br /&gt;
NOTE: This setup is currently being used in a live production environment, and is therefore suitable for such use provided it is correctly configured and tested.&lt;br /&gt;
&lt;br /&gt;
This is the recommended method for Apache 2 on Windows, however it will &#039;&#039;&#039;not&#039;&#039;&#039; work on Linux/UNIX systems.&lt;br /&gt;
It provides better stability and higher performance than other NTLM modules.&lt;br /&gt;
&lt;br /&gt;
* Download the mod_auth_sspi Module from: http://sourceforge.net/projects/mod-auth-sspi/. At the moment of writing this (2007.09.30), the current version is mod_auth_sspi 1.0.4, which has two different ZIP files to download:&lt;br /&gt;
&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.0.58.zip :   Use this file if you are using Apache 2.0.x.&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.2.2.zip :   Use this file if you are using Apache 2.2.x.&lt;br /&gt;
&lt;br /&gt;
* Unzip the right file and copy mod_auth_sspi.so (it&#039;s inside &#039;&#039;&#039;bin&#039;&#039;&#039; subdirectory) to your Apache modules directory.&lt;br /&gt;
* Edit your Apache 2 configuration file (httpd.conf) to load the module.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;IfModule !mod_auth_sspi.c&amp;gt;&lt;br /&gt;
        LoadModule sspi_auth_module modules/mod_auth_sspi.so&lt;br /&gt;
    &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Choose one of the two methods below&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 1&#039;&#039;&#039;: This method is recommended for servers that will host a single Moodle instance. Configure NTLM from the main configuration file, add the following to httpd.conf (substitute &amp;quot;C:\moodle&amp;quot; with the path to your Moodle installation e.g. &amp;quot;C:\my-moodle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ldap&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ntlm&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 2&#039;&#039;&#039;: The alternative method is to use a .htaccess file&lt;br /&gt;
:This method is recommended for servers that will host multiple Moodle instances. It allows additional Moodle instances to be configured without restarting apache, and also makes the solution a little more portable. We need to add a directive to the main httpd.conf to allow configuration of authentication within .htaccess files.&lt;br /&gt;
    &amp;lt;Directory C:\moodle&amp;gt;&lt;br /&gt;
        AllowOverride AuthConfig&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ldap&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ntlm&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This enables the Moodle folder to be moved to any apache webserver that is configured to allow authentication configuration through .htaccess&lt;br /&gt;
&lt;br /&gt;
For further help and discussion: http://moodle.org/mod/forum/discuss.php?d=56565&lt;br /&gt;
&lt;br /&gt;
==Configuring IP/Subnet Mask==&lt;br /&gt;
Subnet masks are based on binary patterns so need a bit of knowledge to understand. The best way to find out what IP/Subnet masks to use is to ask your Network Admin. &lt;br /&gt;
* &#039;&#039;&#039;(pre-1.9 only)&#039;&#039;&#039; Once you have configured your IP/Subnet masks, you can use the check_ip.php page to test if you have set these ranges up correctly.&lt;br /&gt;
* The new way of specifiying subnets is even easier/more flexible than before 1.9. Just type them one after the other, separated by commas. You can use several syntaxes:&lt;br /&gt;
** Type the network-number/prefix-length combination. E.g. 192.168.1.0/24&lt;br /&gt;
** Type the network &#039;prefix&#039;, ending in a period character. E.g. 192.168.1.&lt;br /&gt;
** Type the network address range (&#039;&#039;&#039;this only works for the last address octect&#039;&#039;&#039;). E.g. 192.168.1.1-254&lt;br /&gt;
:All the three examples refer to the same subnetwork.&lt;br /&gt;
* So assuming you need to specify the following subnetworks:&lt;br /&gt;
** 10.1.0/255.255.0.0&lt;br /&gt;
** 10.2.0.0/255.255.0.0&lt;br /&gt;
** 172.16.0.0/255.255.0.0&lt;br /&gt;
** 192.168.100.0/255.255.255.240&lt;br /&gt;
:You can type:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.0/28&lt;br /&gt;
: or:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.240-255&lt;br /&gt;
:or even:&lt;br /&gt;
  10.1., 10.2., 172.16., 192.168.100.0/28&lt;br /&gt;
:(the last one cannot be expressed as a network &#039;prefix&#039; as the netmask does not fall in an octect boundary).&lt;br /&gt;
&lt;br /&gt;
==Notes/Tips==&lt;br /&gt;
# (pre-1.9 only) When using IIS, dbsessions is required to be set to &amp;quot;YES&amp;quot; because when Integrated authentication is turned on for the oncampuslogin.php page, and dbsessions is set to &amp;quot;NO&amp;quot; then the server impersonates the user to write the session in the moodledata\sessions folder. The recommended fix is to set dbsessions to &amp;quot;YES&amp;quot; so that sessions are stored in the db. The non-recommended alternative method is to allow domain users write access to the sessions directory.&lt;br /&gt;
# (pre-1.9 only) If you forget to change the internal IP addresses in index.php to your own, you can just use the offcampuslogin url to login using your admin account. eg: http://yoursite.com/moodle/auth/ntlm/offcampuslogin.php&lt;br /&gt;
#If you are using Firefox, you will need to follow these steps:&lt;br /&gt;
:*Load Firefox and type about:config in the address box. The configuration settings page should be displayed.&lt;br /&gt;
:*In the Filter box, type the word &amp;quot;ntlm&amp;quot; to filter the NTLM strings. You should see three settings displayed.&lt;br /&gt;
:*Double-click on &amp;quot;network.automatic-ntlm-auth.trusted-uris&amp;quot;.&lt;br /&gt;
:*In the box, enter the full URL of your Moodle server. For example &amp;lt;pre&amp;gt;http://moodle.mydomain.com&amp;lt;/pre&amp;gt;&lt;br /&gt;
:*Close Firefox and restart.&lt;br /&gt;
&lt;br /&gt;
==Specific File information== &lt;br /&gt;
(mainly for developers)&lt;br /&gt;
#auth\ntlm\index.php&amp;lt;br /&amp;gt;This is the page used for the Alternate Login URL setting on the config page for the NTLM plugin.&amp;lt;br&amp;gt;The index.php file handles which login page to use based on the IP address of the user.&amp;lt;br&amp;gt;if inside your network, they should be directed to the oncampuslogin.php screen.&amp;lt;br&amp;gt;if outside your network, they should be directed to the offcampuslogin.php screen.&amp;lt;br&amp;gt;you will need to modify the if statements in this file to match the IP ranges inside your network.&lt;br /&gt;
#auth\ntlm\index_form.html&amp;lt;br /&amp;gt;this is a copy of the file login\index_form.php.&amp;lt;br /&amp;gt; The only change in this file from the standard one is that the form action=&amp;quot;index.php&amp;quot; is changed to form action=&amp;quot;offcampuslogin.php&amp;quot; this is because anyone who is displayed the form will be an offcampus user.&lt;br /&gt;
#auth\ntlm\offcampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file moodle\login\index.php with a couple of minor modifications.&amp;lt;br /&amp;gt;the modifications to this file involve the setting of a variable ($onoroffcampus = &amp;quot;offcampus&amp;quot;;) this is used by the auth plugin to define which page is being used for authentication. the other modification is for displaying extra error messages to the user. - with all the authentication methods we have students are constantly confused about how to enter their credentials if you use NTLM authentication elsewhere at your site you will be aware of the users having to enter the domain\username when authenticating. - this code block sits around line 215 in the file.&lt;br /&gt;
#auth\ntlm\oncampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file login\index.php&amp;lt;br /&amp;gt;This file has been modified to get the details of the authenticated user via NTLM.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=45887 NTLM Authentication] forum discussion&lt;br /&gt;
*[http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314 Download the NTLM Authentication Module]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=80104 Merging AD NTLM SSO into auth/ldap] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Authentification NTLM]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=NTLM_authentication&amp;diff=33498</id>
		<title>NTLM authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=NTLM_authentication&amp;diff=33498"/>
		<updated>2008-03-12T11:53:41Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Installation on 1.9 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.9}}This document describes how to set up NTLM/Integrated Authentication in Moodle. &lt;br /&gt;
&lt;br /&gt;
This is integrated into Moodle 1.9 onwards.&lt;br /&gt;
&lt;br /&gt;
For earlier versions, it uses a modified version of LDAP Authentication.&lt;br /&gt;
The NTLM Authentication module is available in the Modules and Plugins database here:&lt;br /&gt;
http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Assumptions==&lt;br /&gt;
&lt;br /&gt;
#You are running MS Active Directory for Authentication.&lt;br /&gt;
#The Server hosting your website is a member of the Active Directory Domain that your users are also members of.&lt;br /&gt;
#You are able to define people inside your Network (and authenticated to the Domain) from an IP range or IP range of computers.&lt;br /&gt;
#You have &amp;quot;some&amp;quot; basic knowledge of php and are able to configure the index.php with the range of internal IP addresses.&lt;br /&gt;
#You are familar with or have read the LDAP authentication documentation.&lt;br /&gt;
#The Active Directory domain credentials of your users are returned as &#039;&#039;&#039;DOMAINNAME\username&#039;&#039;&#039; from your authentication service. If you are using the Winbind service from the Samba project, this can be untrue, depending on your Winbind configuration settings.&lt;br /&gt;
&lt;br /&gt;
If you can not modify your settings to satisfy this last assumption, then you will need to remove or comment out the line that reads:&lt;br /&gt;
    $username = substr(strrchr($username, &#039;\\&#039;), 1); //strip domain info&lt;br /&gt;
and add the relevant lines of code to extract the username part from the domain user credentials and store it in $username.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.9==&lt;br /&gt;
&lt;br /&gt;
No installation needed. See the Auth/LDAP settings for the NTLM config options. You only have to&lt;br /&gt;
&lt;br /&gt;
*Set the subnet mask&lt;br /&gt;
*On IIS: turn on Integrated Authentication&lt;br /&gt;
*On Apache - use one of the 3 methods outlined below&lt;br /&gt;
&lt;br /&gt;
If you have used previous versions of NTLM in your Moodle database you will need to make two further changes. &lt;br /&gt;
&lt;br /&gt;
1 - The type of authentication held against each user now needs to be ldap, and ntlm will not be recognised and Moodle will fall through and try to use CAS. To edit the fields open up a sql query for your Moodle server and use the following:&lt;br /&gt;
&lt;br /&gt;
update mdl_user &lt;br /&gt;
set auth = &#039;ldap&#039;&lt;br /&gt;
where auth = &#039;ntlm&#039;&lt;br /&gt;
&lt;br /&gt;
2 - If you had a previous .htaccess file in the auth/ntlm directory, you will need to move it to the auth/ldap directory. Regardless of whether it is in a .htaccess file of the httpd.conf, the &amp;lt;Files&amp;gt; line now needs to refer to ntlmsso_magic.php. If it is in the httpd.conf, the &amp;lt;Directory&amp;gt; will need to change too. &lt;br /&gt;
This is covered later on for new installs, but is one of the fundamental changes that needs to be made for those upgrading.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.6/1.7==&lt;br /&gt;
#Copy the folder AUTH/NTLM into the AUTH folder of your moodle installation.&lt;br /&gt;
#Configure the IP/Subnet Mask in the Config screen.&lt;br /&gt;
[https://docs.moodle.org/en/NTLM_authentication#Configuring IP/Subnet Mask see below for more help]&lt;br /&gt;
If the IP/Subnet Mask does not give enough complexity for your network, Modify the auth/ntlm/index.php file - for instructions on doing this, view the comments in the file.&lt;br /&gt;
#Turn Integrated Authentication ON and Anonymous Authentication OFF for the moodle\auth\ntlm\oncampuslogin.php file. [https://docs.moodle.org/en/NTLM_authentication#How_to_Turn_Integrated_Authentication_on see below for more detailed instructions]&lt;br /&gt;
#Visit the admin page of your moodle installation - you should see notification that the NTLM_AUTH module has been installed.&lt;br /&gt;
#go to the configuration &amp;gt; variables page, find the dbsessions setting (in 1.8 on admin page server \ sessions page), and set it to &amp;quot;YES&amp;quot; then save the page.&lt;br /&gt;
#go to the Authentication admin page and select auth_ntlmtitle as your authentication method Note: - this doesn&#039;t display full text as I haven&#039;t created a language file for this module - you will also see auth_ntlmdescription instead of a proper description - you don&#039;t need to worry about this, as you will be the only one who ever sees this.&lt;br /&gt;
#Configure this page with your normal LDAP settings. NOTE: the Alternate Login URL at the bottom of this page (or on the main authentication page in 1.8 - and needs to be set manually to the oncampus url)has been set to the NTLM page. - if you wish uninstall this auth module, you must reset this variable on the new authentication type page. eg - if you wish to revert back to manual authentication, then change to manual, and then make sure you delete the alternate login url at the bottom of the page.&lt;br /&gt;
#(OPTIONAL) modify the offcampuslogin page to give errors when students try to prefix their usercode with your domain.&lt;br /&gt;
around line 216 find this code, uncomment all the lines and replace the letters &#039;DOM&#039; with your domain:&lt;br /&gt;
&lt;br /&gt;
    if (empty($errormsg)) {&lt;br /&gt;
        if (strstr(strtolower($frm-&amp;gt;username), &amp;quot;DOM\\&amp;quot;) &amp;lt;&amp;gt; false) { //NAD - DOM messages.&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; DOM\\ is not required!&amp;quot;;&lt;br /&gt;
        } else if (strpos($frm-&amp;gt;username, &amp;quot;@&amp;quot;) &amp;lt;&amp;gt; false) {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; enter your username - not your e-mail address.&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.5==&lt;br /&gt;
&lt;br /&gt;
See the README in the auth/ntml package.&lt;br /&gt;
&lt;br /&gt;
==How to Turn Integrated Authentication on==&lt;br /&gt;
The File ntlmsso_magic.php (1.9 or above) or oncampuslogin.php (1.8 or below) MUST have NTLM/Integrated Authentication enabled at the server or the page will not work.&lt;br /&gt;
===IIS Configuration===&lt;br /&gt;
Open up IIS, and find the auth/ldap/ntlmsso_magic.php (1.9 or above) or auth/ntlm/oncampuslogin.php (1.8 or below) file, &lt;br /&gt;
#right click on the file, choose properties&lt;br /&gt;
#under the &amp;quot;file security&amp;quot; tab, click on the Authentication and Access control &amp;quot;edit&amp;quot; button&lt;br /&gt;
#untick &amp;quot;Enable Anonymous Access&amp;quot; and tick &amp;quot;Integrated Windows Authentication&amp;quot;&lt;br /&gt;
===APACHE Configuration===&lt;br /&gt;
There are currently 3 possible methods for this:&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM part of Samba (Linux)====&lt;br /&gt;
&lt;br /&gt;
* Get the plugin here: http://samba.org/ftp/unpacked/lorikeet/mod_auth_ntlm_winbind/ and follow the instructions inside the README file. You&#039;ll need to install the Apache development packages in addition to the core C develpment packages.&lt;br /&gt;
* Once you have compiled it, put it inside Apache&#039;s modules subdirectory (this location depends on a number of factors, like compiling Apache yourself, using different Linux distributions packages, an so on), and load and enable the module in Apache&#039;s configuration. For example, if your Apache modules are under &amp;lt;code&amp;gt;/usr/lib/apache2/modules&amp;lt;/code&amp;gt;, you&#039;ll need something like this in your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;IfModule !mod_auth_ntlm_winbind.c&amp;gt;&lt;br /&gt;
       LoadModule auth_ntlm_winbind_module /usr/lib/apache2/modules/mod_auth_ntlm_winbind.so&lt;br /&gt;
   &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install the Samba &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; daemon package. This packages relies on Samba&#039;s configuration file to get some important settings (like the Windows domain name, uid and gid range mappings, and so on). In addition to that, you&#039;ll need to make your Linux/Unix machine part of the domain. Otherwise winbind won&#039;t be able to pull user and groups informationi from the domain controllers. You should read the Samba documentation to perform this step, but the most important part is having something like the following lines in your &amp;lt;code&amp;gt;smb.conf&amp;lt;/code&amp;gt; file (in addition to what you already have there):&lt;br /&gt;
&lt;br /&gt;
  workgroup = DOMAINNAME&lt;br /&gt;
  password server = *&lt;br /&gt;
  security = domain&lt;br /&gt;
  encrypt passwords = true&lt;br /&gt;
  idmap uid = 10000-20000&lt;br /&gt;
  idmap gid = 10000-20000&lt;br /&gt;
&lt;br /&gt;
: and executing the command (as root):&lt;br /&gt;
&lt;br /&gt;
  # net join DOMAINNAME -U Administrator&lt;br /&gt;
&lt;br /&gt;
: where &#039;&#039;&#039;DOMAINNAME&#039;&#039;&#039; is the NetBIOS windows domain name, and &#039;&#039;&#039;Administrator&#039;&#039;&#039; an account with enough privileges to add new machines to the domain.&amp;lt;br/&amp;gt; You&#039;ll need to type this account&#039;s password for the command to succeed.&lt;br /&gt;
&lt;br /&gt;
: Also, make sure you have disabled &amp;quot;Microsoft Network Server: digitally sign communications (always)&amp;quot; in your Domain Controllers Security Policy, unless you are using a version of Samba that can sign SMB packets.&lt;br /&gt;
&lt;br /&gt;
* Restart the &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; service to apply the changes and test that it&#039;s running ok by executing:&lt;br /&gt;
&lt;br /&gt;
  $ wbinfo -u&lt;br /&gt;
&lt;br /&gt;
: You should get the full list of Windows domain users. If you use &#039;&#039;&#039;&amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt;&#039;&#039;&#039; instead, you&#039;ll get the domain groups list.&lt;br /&gt;
&lt;br /&gt;
* Check that your &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; package installed the authentication helper command &amp;lt;code&amp;gt;ntlm_auth&amp;lt;/code&amp;gt;, as we&#039;ll need it later. We&#039;ll assume the helper is located at &amp;lt;code&amp;gt;/usr/bin/ntlm_auth&amp;lt;/code&amp;gt;. If yours is at a different location, make sure you adjust the path in the example below.&lt;br /&gt;
&lt;br /&gt;
* Add something like this to your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;). We&#039;ll assume that your Moodle &amp;lt;code&amp;gt;$CFG-&amp;gt;dirroot&amp;lt;/code&amp;gt; directory is located at &amp;lt;code&amp;gt;/var/www/moodle&amp;lt;/code&amp;gt; in the example:&lt;br /&gt;
: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ldap/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ntlm/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
* Check the permissions of the Winbind pipe directory (Ubuntu places it under &amp;lt;code&amp;gt;/var/run/samba/winbindd_privileged&amp;lt;/code&amp;gt;, yours may be placed at a different location). Apache will need to be able to enter that directory, so we need to make sure it has the right permissions. So have a look at the permissions of that directory and note the name of the group assigned to it. The following example is from a Ubuntu 7.10 machine:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ald /var/run/samba/winbindd_privileged&lt;br /&gt;
  drwxr-x--- 2 root winbindd_priv 60 2007-11-17 16:18 /var/run/samba/winbindd_privileged/&lt;br /&gt;
&lt;br /&gt;
:so we see the group is &amp;lt;code&amp;gt;winbindd_priv&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Instead of modifying the directory permissions (which could break other services that use winbind) we are goint to make the Apache user (&amp;lt;code&amp;gt;www-data&amp;lt;/code&amp;gt; in our example, but could be &amp;lt;code&amp;gt;httpd&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;nobody&amp;lt;/code&amp;gt;, etc.) is part of the appropiate group. Execute the following as root:&lt;br /&gt;
&lt;br /&gt;
  # adduser www-data winbindd_priv&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt; is available in Debian and Ubuntu at least. If your distribution doesn&#039;t have &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt;, you can edit &amp;lt;code&amp;gt;/etc/group&amp;lt;/code&amp;gt; manually to achive the same effect.&lt;br /&gt;
&lt;br /&gt;
* Restart the Apache service to apply the changes. Have a look at Apache&#039;s error log to see that everything is ok.&lt;br /&gt;
&lt;br /&gt;
* Couple of gotchas - in Fedora Core, keep alive is turned OFF by default in the httpd.conf - see this bug for further info: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=188138&amp;lt;br /&amp;gt;&lt;br /&gt;
* Email Dan if you get this working - I&#039;m keen to hear how people go using the samba winbind option!&lt;br /&gt;
::-- Hi Dan! I made it work using Ubuntu 7.04. That&#039;s what I&#039;ve used to update the documentation. [[User:Iñaki Arenaza|Iñaki Arenaza]] 10:43, 30 September 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM Auth Module for Apache====&lt;br /&gt;
#get the Module from: http://modntlm.sourceforge.net/&lt;br /&gt;
#use something like this in your httpd.conf: http://moodle.org/mod/forum/discuss.php?d=45887#211074&lt;br /&gt;
&lt;br /&gt;
====Using the mod_auth_sspi Module for Apache 2 on Windows====&lt;br /&gt;
NOTE: This setup is currently being used in a live production environment, and is therefore suitable for such use provided it is correctly configured and tested.&lt;br /&gt;
&lt;br /&gt;
This is the recommended method for Apache 2 on Windows, however it will &#039;&#039;&#039;not&#039;&#039;&#039; work on Linux/UNIX systems.&lt;br /&gt;
It provides better stability and higher performance than other NTLM modules.&lt;br /&gt;
&lt;br /&gt;
* Download the mod_auth_sspi Module from: http://sourceforge.net/projects/mod-auth-sspi/. At the moment of writing this (2007.09.30), the current version is mod_auth_sspi 1.0.4, which has two different ZIP files to download:&lt;br /&gt;
&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.0.58.zip :   Use this file if you are using Apache 2.0.x.&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.2.2.zip :   Use this file if you are using Apache 2.2.x.&lt;br /&gt;
&lt;br /&gt;
* Unzip the right file and copy mod_auth_sspi.so (it&#039;s inside &#039;&#039;&#039;bin&#039;&#039;&#039; subdirectory) to your Apache modules directory.&lt;br /&gt;
* Edit your Apache 2 configuration file (httpd.conf) to load the module.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;IfModule !mod_auth_sspi.c&amp;gt;&lt;br /&gt;
        LoadModule sspi_auth_module modules/mod_auth_sspi.so&lt;br /&gt;
    &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Choose one of the two methods below&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 1&#039;&#039;&#039;: This method is recommended for servers that will host a single Moodle instance. Configure NTLM from the main configuration file, add the following to httpd.conf (substitute &amp;quot;C:\moodle&amp;quot; with the path to your Moodle installation e.g. &amp;quot;C:\my-moodle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ldap&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ntlm&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 2&#039;&#039;&#039;: The alternative method is to use a .htaccess file&lt;br /&gt;
:This method is recommended for servers that will host multiple Moodle instances. It allows additional Moodle instances to be configured without restarting apache, and also makes the solution a little more portable. We need to add a directive to the main httpd.conf to allow configuration of authentication within .htaccess files.&lt;br /&gt;
    &amp;lt;Directory C:\moodle&amp;gt;&lt;br /&gt;
        AllowOverride AuthConfig&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ldap&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ntlm&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This enables the Moodle folder to be moved to any apache webserver that is configured to allow authentication configuration through .htaccess&lt;br /&gt;
&lt;br /&gt;
For further help and discussion: http://moodle.org/mod/forum/discuss.php?d=56565&lt;br /&gt;
&lt;br /&gt;
==Configuring IP/Subnet Mask==&lt;br /&gt;
Subnet masks are based on binary patterns so need a bit of knowledge to understand. The best way to find out what IP/Subnet masks to use is to ask your Network Admin. &lt;br /&gt;
* &#039;&#039;&#039;(pre-1.9 only)&#039;&#039;&#039; Once you have configured your IP/Subnet masks, you can use the check_ip.php page to test if you have set these ranges up correctly.&lt;br /&gt;
* The new way of specifiying subnets is even easier/more flexible than before 1.9. Just type them one after the other, separated by commas. You can use several syntaxes:&lt;br /&gt;
** Type the network-number/prefix-length combination. E.g. 192.168.1.0/24&lt;br /&gt;
** Type the network &#039;prefix&#039;, ending in a period character. E.g. 192.168.1.&lt;br /&gt;
** Type the network address range (&#039;&#039;&#039;this only works for the last address octect&#039;&#039;&#039;). E.g. 192.168.1.1-254&lt;br /&gt;
:All the three examples refer to the same subnetwork.&lt;br /&gt;
* So assuming you need to specify the following subnetworks:&lt;br /&gt;
** 10.1.0/255.255.0.0&lt;br /&gt;
** 10.2.0.0/255.255.0.0&lt;br /&gt;
** 172.16.0.0/255.255.0.0&lt;br /&gt;
** 192.168.100.0/255.255.255.240&lt;br /&gt;
:You can type:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.0/28&lt;br /&gt;
: or:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.240-255&lt;br /&gt;
:or even:&lt;br /&gt;
  10.1., 10.2., 172.16., 192.168.100.0/28&lt;br /&gt;
:(the last one cannot be expressed as a network &#039;prefix&#039; as the netmask does not fall in an octect boundary).&lt;br /&gt;
&lt;br /&gt;
==Notes/Tips==&lt;br /&gt;
# (pre-1.9 only) When using IIS, dbsessions is required to be set to &amp;quot;YES&amp;quot; because when Integrated authentication is turned on for the oncampuslogin.php page, and dbsessions is set to &amp;quot;NO&amp;quot; then the server impersonates the user to write the session in the moodledata\sessions folder. The recommended fix is to set dbsessions to &amp;quot;YES&amp;quot; so that sessions are stored in the db. The non-recommended alternative method is to allow domain users write access to the sessions directory.&lt;br /&gt;
# (pre-1.9 only) If you forget to change the internal IP addresses in index.php to your own, you can just use the offcampuslogin url to login using your admin account. eg: http://yoursite.com/moodle/auth/ntlm/offcampuslogin.php&lt;br /&gt;
#If you are using Firefox, you will need to follow these steps:&lt;br /&gt;
:*Load Firefox and type about:config in the address box. The configuration settings page should be displayed.&lt;br /&gt;
:*In the Filter box, type the word &amp;quot;ntlm&amp;quot; to filter the NTLM strings. You should see three settings displayed.&lt;br /&gt;
:*Double-click on &amp;quot;network.automatic-ntlm-auth.trusted-uris&amp;quot;.&lt;br /&gt;
:*In the box, enter the full URL of your Moodle server. For example &amp;lt;pre&amp;gt;http://moodle.mydomain.com&amp;lt;/pre&amp;gt;&lt;br /&gt;
:*Close Firefox and restart.&lt;br /&gt;
&lt;br /&gt;
==Specific File information== &lt;br /&gt;
(mainly for developers)&lt;br /&gt;
#auth\ntlm\index.php&amp;lt;br /&amp;gt;This is the page used for the Alternate Login URL setting on the config page for the NTLM plugin.&amp;lt;br&amp;gt;The index.php file handles which login page to use based on the IP address of the user.&amp;lt;br&amp;gt;if inside your network, they should be directed to the oncampuslogin.php screen.&amp;lt;br&amp;gt;if outside your network, they should be directed to the offcampuslogin.php screen.&amp;lt;br&amp;gt;you will need to modify the if statements in this file to match the IP ranges inside your network.&lt;br /&gt;
#auth\ntlm\index_form.html&amp;lt;br /&amp;gt;this is a copy of the file login\index_form.php.&amp;lt;br /&amp;gt; The only change in this file from the standard one is that the form action=&amp;quot;index.php&amp;quot; is changed to form action=&amp;quot;offcampuslogin.php&amp;quot; this is because anyone who is displayed the form will be an offcampus user.&lt;br /&gt;
#auth\ntlm\offcampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file moodle\login\index.php with a couple of minor modifications.&amp;lt;br /&amp;gt;the modifications to this file involve the setting of a variable ($onoroffcampus = &amp;quot;offcampus&amp;quot;;) this is used by the auth plugin to define which page is being used for authentication. the other modification is for displaying extra error messages to the user. - with all the authentication methods we have students are constantly confused about how to enter their credentials if you use NTLM authentication elsewhere at your site you will be aware of the users having to enter the domain\username when authenticating. - this code block sits around line 215 in the file.&lt;br /&gt;
#auth\ntlm\oncampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file login\index.php&amp;lt;br /&amp;gt;This file has been modified to get the details of the authenticated user via NTLM.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=45887 NTLM Authentication] forum discussion&lt;br /&gt;
*[http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314 Download the NTLM Authentication Module]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=80104 Merging AD NTLM SSO into auth/ldap] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Authentification NTLM]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=18263</id>
		<title>LDAP authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=18263"/>
		<updated>2006-11-29T15:17:44Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document describes how to set up LDAP authentication in Moodle. You can find a [[#Basic Scenario|Basic Scenario]], where everything is simple and straightforward, and that should be enough for most installations. If your installation is a little bigger and you are using multiple LDAP servers, or multiple locations (contexts) for your users in your LDAP tree, then have a look at the [[#Advanced Scenarios|Advanced Scenarios]].&lt;br /&gt;
&lt;br /&gt;
==Basic Scenario==&lt;br /&gt;
&lt;br /&gt;
===Assumptions===&lt;br /&gt;
&lt;br /&gt;
# Your Moodle site is located at &#039;&#039;&#039;http://your.moodle.site/&#039;&#039;&#039;&lt;br /&gt;
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to &#039;&#039;&#039;http://your.moodle.site/admin/phpinfo.php&#039;&#039;&#039; (logged in as user &#039;admin&#039;).&lt;br /&gt;
# Your LDAP server has &#039;&#039;&#039;192.168.1.100&#039;&#039;&#039; as its IP address.&lt;br /&gt;
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.&lt;br /&gt;
# You don&#039;t want your users to change their passwords the first time they log in into Moodle.&lt;br /&gt;
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).&lt;br /&gt;
# You are using a top level distinguished name (DN) of &#039;&#039;&#039;dc=my,dc=organization,dc=domain&#039;&#039;&#039; as the root of your LDAP tree. &lt;br /&gt;
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won&#039;t hurt if you use it even if your LDAP server doesn&#039;t need it. Make sure &#039;&#039;&#039;this account and its password don&#039;t expire&#039;&#039;&#039;, and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don&#039;t be afraid of making it as hard to guess as possible. Let&#039;s say this user account has a DN of &#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;, and password &#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;.&lt;br /&gt;
# All of your Moodle users are in an organizational unit (OU) called &#039;&#039;&#039;moodleusers&#039;&#039;&#039;, which is right under your LDAP root. That OU has a DN of &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039;.&lt;br /&gt;
# You &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want your LDAP users&#039; passwords to be stored in Moodle at all.&lt;br /&gt;
&lt;br /&gt;
===Configuring Moodle authentication===&lt;br /&gt;
&lt;br /&gt;
Log in as an admin user and go to Administration &amp;gt;&amp;gt; Users &amp;gt;&amp;gt; Authentication. In the drop down listbox titled  &amp;quot;Choose an authentication method&amp;quot; select &amp;quot;Use an LDAP Server&amp;quot;. You will get a page similar to this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::: [[Image:auth_ldap_config_screenshot.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you just have to fill in the values. Let&#039;s go step by step.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| ldap_host_url&lt;br /&gt;
| As the IP of your LDAP server is 192.168.1.100, type &amp;quot;&#039;&#039;&#039;ldap://192.168.1.100&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_version&lt;br /&gt;
| Unless you are using a really old LDAP server, &#039;&#039;&#039;version 3&#039;&#039;&#039; is the one you should choose.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_preventpassindb&lt;br /&gt;
| As you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to store the users&#039;s password in Moodle&#039;s database, choose &#039;&#039;&#039;Yes&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_dn&lt;br /&gt;
| This is the distinguished name of the bind user defined above. Just type &amp;quot;&#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_pw&lt;br /&gt;
| This is the bind user password defined above. Type &amp;quot;&#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_type&lt;br /&gt;
| Choose: &lt;br /&gt;
* &#039;&#039;&#039;Novel Edirectory&#039;&#039;&#039; if your LDAP server is running Novell&#039;s eDdirectory.&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307)&#039;&#039;&#039; if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP).&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307bis)&#039;&#039;&#039; if your LDAP server is running a RFC-2307bis compatible LDAP server.&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount (v.3.0.7)&#039;&#039;&#039; if your LDAP server is running with SAMBA&#039;s 3.x LDAP schema extension and you want to use it.&lt;br /&gt;
* &#039;&#039;&#039;MS ActiveDirectory&#039;&#039;&#039; if your LDAP server is running Microsoft&#039;s Active Directory (MS-AD)&lt;br /&gt;
|-&lt;br /&gt;
| ldap_contexts&lt;br /&gt;
| The DN of the context (container) where all of your Moodle users are found. Type &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_search_sub&lt;br /&gt;
| If you have any sub organizational units (subcontexts) hanging from &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; and you want Moodle to search there too, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. Otherwise, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_opt_deref&lt;br /&gt;
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to &#039;dereference&#039; the alias and fetch the real value from the original location, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. If you don&#039;t want Moodle to dereference it, set this to &#039;&#039;&#039;no&#039;&#039;&#039;. If you are using MS-AD, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_attribute&lt;br /&gt;
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in&amp;lt;/u&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By the way, it&#039;s usually &#039;&#039;&#039;cn&#039;&#039;&#039; (Novell eDirectory and MS-AD) or &#039;&#039;&#039;uid&#039;&#039;&#039; (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could use &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039; (the pre-Windows 2000 logon account name) if you need too.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_memberattribute&lt;br /&gt;
| The attribute used to list the members of a given group. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By the way, the usual values are &#039;&#039;&#039;member&#039;&#039;&#039; and &#039;&#039;&#039;memberUid&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_objectclass&lt;br /&gt;
| The type of LDAP object used to search for users. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the default values for each of the &#039;&#039;ldap_user_type&#039;&#039; values:&lt;br /&gt;
* &#039;&#039;&#039;User&#039;&#039;&#039; for Novel eDirectory&lt;br /&gt;
* &#039;&#039;&#039;posixAccount&#039;&#039;&#039; for RFC-2037 and RFC-2037bis&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount&#039;&#039;&#039; for SAMBA 3.0.x LDAP extension&lt;br /&gt;
* &#039;&#039;&#039;user&#039;&#039;&#039; for MS-AD&lt;br /&gt;
|-&lt;br /&gt;
| Force change password&lt;br /&gt;
| Set this to &#039;&#039;Yes&#039;&#039; if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to &#039;&#039;no&#039;&#039;. Bear in mind the password they are forced to change is the one stored in your LDAP server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;As you don&#039;t want your users to change their passwords in their first login, leave this set to &#039;&#039;No&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Use standard Change Password Page&lt;br /&gt;
|&lt;br /&gt;
* Setting this to &#039;&#039;Yes&#039;&#039; makes Moodle use it&#039;s own standard password change page, everytime users want to change their passwords.&lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; makes Moodle use the the page specified in the field called &amp;quot;Change password URL&amp;quot; (at the bottom of the configuration page).&lt;br /&gt;
&lt;br /&gt;
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is true at least for MS-AD).&lt;br /&gt;
&lt;br /&gt;
Also, code for changing passwords from Moodle for anything but Novell eDirectory is almost not tested, so this may or may not work for other LDAP servers.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration&lt;br /&gt;
| &lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; will make Moodle not to check if the password of the user has expired or not.&lt;br /&gt;
* Setting this to &#039;&#039;LDAP&#039;&#039; will make Moodle check if the LDAP password of the user has expired or not, and warn her a number of days before the password expires.&lt;br /&gt;
&lt;br /&gt;
Current code only deals with Novell eDirectory LDAP server, but there is a patch floating around to make it work with MS-AD too (search in the authentication forum).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server (or use the patch), choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration_warning&lt;br /&gt;
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_exprireattr&lt;br /&gt;
| The LDAP user attribute used to check password expiration. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_gracelogins&lt;br /&gt;
| This setting is specific to Novell eDirectory. If set to &#039;&#039;Yes&#039;&#039;, enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server and want to allow gracelogin support, choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_graceattr&lt;br /&gt;
| This setting is currently not used in the code (and is specific to Novell eDirectory). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_create_context&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| ldap_creators&lt;br /&gt;
| The DN of the group that contains all of your Moodle creators. This is typically a posixGroup with a &amp;quot;memberUid&amp;quot; attribute for each user you want to be a creator.  If your group is called &#039;&#039;creators&#039;&#039;, type &#039;&#039;&#039;cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.  Each memberUid attribute contains the CN of a user who is authorized to be a creator.  Do not use the user&#039;s full DN (e.g.,  not &#039;&#039;&#039;memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain&#039;&#039;&#039;, but rather &#039;&#039;&#039;memberUid: JoeTeacher&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
In eDirectory, the objectClass for a group is (by default) not &#039;&#039;&#039;posixGroup&#039;&#039;&#039; but &#039;&#039;&#039;groupOfNames,&#039;&#039;&#039; whose member attribute is &#039;&#039;&#039;member,&#039;&#039;&#039; not &#039;&#039;&#039;memberUid,&#039;&#039;&#039; and whose value is the full DN of the user in question.  Although you can probably modify Moodle&#039;s code to use this field, a better solution is just to add a new &#039;&#039;&#039;objectClass&#039;&#039;&#039; attribute of &#039;&#039;&#039;posixGroup&#039;&#039;&#039; to your creators group and put the CNs for each creator in a &#039;&#039;&#039;memberUid&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is &#039;ou=staff,dc=my,dc=org&#039; then your group should then be &#039;cn=creators,ou=staff,dc=my,dc=org&#039;. If some of the users are from other contexts and have been added to the same security group, you&#039;ll have to add these as separate contexts after the first one using the same format.&lt;br /&gt;
|-&lt;br /&gt;
| First name&lt;br /&gt;
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually &#039;&#039;&#039;givenName&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Surname&lt;br /&gt;
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually &#039;&#039;&#039;sn&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Email address&lt;br /&gt;
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually &#039;&#039;&#039;mail&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 1&lt;br /&gt;
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually &#039;&#039;&#039;telephoneNumber&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 2&lt;br /&gt;
|  The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be &#039;&#039;&#039;homePhone&#039;&#039;&#039;, &#039;&#039;&#039;mobile&#039;&#039;&#039;, &#039;&#039;&#039;pager&#039;&#039;&#039;, &#039;&#039;&#039;facsimileTelephoneNumber&#039;&#039;&#039; or even others.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Department&lt;br /&gt;
| The name of the attribute that holds the department name of your users in your LDAP server. This is usully &#039;&#039;&#039;departmentNumber&#039;&#039;&#039; (for posixAccount and maybe eDirectory) or &#039;&#039;&#039;department&#039;&#039;&#039; (for MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Address&lt;br /&gt;
| The name of the attribute that holds the street address of your users in your LDAP server. This is usully &#039;&#039;&#039;streetAddress&#039;&#039;&#039; or &#039;&#039;&#039;street&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| City/town&lt;br /&gt;
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usully &#039;&#039;&#039;l&#039;&#039;&#039; (lowercase L) or &#039;&#039;&#039;localityName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| Country&lt;br /&gt;
| The name of the attribute that holds the couuntry of your users in your LDAP server. This is usully &#039;&#039;&#039;c&#039;&#039;&#039; or &#039;&#039;&#039;countryName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Description&lt;br /&gt;
| &#039;&#039;&#039;description&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ID Number&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Language&lt;br /&gt;
| &#039;&#039;&#039;preferredLanguage&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Instructions&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the fields are common to all authentication methods and will not be discussed here.&lt;br /&gt;
&lt;br /&gt;
==Active Directory Troubleshooting Help==&lt;br /&gt;
&lt;br /&gt;
===Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled.===&lt;br /&gt;
This usually means that the main ldap dll or one of the supporting dlls are missing.&lt;br /&gt;
Let&#039;s start with the main one itself. &lt;br /&gt;
Use the &amp;quot;Configuration File (php.ini) Path&amp;quot; field on http://(moodleserver)/admin/phpinfo.php to determine which php.ini is being used and open it. Find the line &#039;extension=php_ldap.dll&#039; and take out the semi-colon if it is there. That semi-colon will stop it loading the module all together! &lt;br /&gt;
While you have that file open, search for &#039;extension_dir&#039; and note which folder it is set to. Open that folder and ensure the php_ldap.dll file is in there. If it isn&#039;t then put it in there.&lt;br /&gt;
If that still hasn&#039;t fixed it you are missing a supporting dll, but you don&#039;t get told that. To see what dlls are missing open the Command Propmt and navigate to the php directory and execute the following line &#039;php -m&#039;. You should get some error messages now. Ugly, but at least they give you information! Find the dlls listed and copy them to the php directory. Run &#039;php -m&#039; again and you should be error free and the message in Moodle should be gone now.&lt;br /&gt;
&lt;br /&gt;
===LDAP-module cannot connect any LDAP servers : Server: &#039;ldap://my.ldap.server/&#039; Connection: &#039;Resource id #26&#039; Bind result: &#039;&#039;===&lt;br /&gt;
Getting this message when you are trying to log in is a result of incorrect details for the Bind user, or the user account having insufficient permissions in Active Directory. The best way to test and resolve this is use ldp.exe to test binding until it suceeds. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open the program and Connect to AD, giving the server name, then from the Connection menu choose Bind. Enter the details you think are correct and you will probably find that an error is returned. Try adjusting the accounts priveleges or another account until you are returned an &amp;quot;Authenticated as&amp;quot; message.&lt;br /&gt;
Once you are sure your account can be used to bind to AD, check that the DN of that users name is correct. Expand the tree on the left until you find the user you used to bind. Right click on that item and choose Copy DN. Go to the User Authentication page in Moodle and paste the value into the ldap_bind_dn field. Add the password and you can now feel safe your user is binding sucessfully.&lt;br /&gt;
&lt;br /&gt;
===Getting correct CNs for Contexts and Creators===&lt;br /&gt;
For those not familiar with AD this could be very confusing, and not that easy for some who are familiar with it. Again, ldp.exe is your friend. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open it up and expand the tree on the left until you find the group or user you want to use and right click on it and select Copy DN. Go back to the Moodle User Authentication page and paste that value into either ldap_contexts or ldap_creators.&lt;br /&gt;
&lt;br /&gt;
===Getting the right user_attribute===&lt;br /&gt;
By default, Moodle uses an accounts cn (full name) to verify against, but most networks don&#039;t use a full given name for logon as it&#039;s too easy to guess and you can easily have two people with the same name. If this is the case for you too you need to tell Moodle to look at another field for the logon id.&lt;br /&gt;
In ldp.exe navigate the tree on the left to find a user account, preferably your own. Double-click the item in the tree and full-details will be loaded into the screen on the right. Look down the details until you find your logon id and note the item listed against it. For me, and a lot of people, it is sAMAccountName. Copy this name and paste it into the ldap_user_attribute on the Moodle User Authentication page.&lt;br /&gt;
There are instructions on installing ldp.exe below.&lt;br /&gt;
&lt;br /&gt;
===Installing ldp.exe Server Tool===&lt;br /&gt;
ldp.exe comes as part of the Server Tools on most versions of Windows Server. Find your Windows Server installation disc and find a folder on it called Support\Tools. In there will be a SupTools.msi which will install the server tools if run. You should now have a folder under Program Files called Support Tools, in which will be ldp.exe. ldp.exe is also available in the Windows XP Support Tools, which you can download from Microsoft [http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&amp;amp;displaylang=en here]. Alternatively, a single download of ldp.exe is available [http://www.computerperformance.co.uk/w2k3/utilities/ldp.htm here].&lt;br /&gt;
&lt;br /&gt;
===Example Active Directory Configuration===&lt;br /&gt;
Below is an example configuration for Active Directory. As detailed above, the values may vary based on your local Active Directory configuration, but should provide a good starting point for most cases.&lt;br /&gt;
&lt;br /&gt;
 ldap_host_url = ldap://ads.example.com&lt;br /&gt;
 ldap_version = 3&lt;br /&gt;
 ldap_preventpassindb = yes&lt;br /&gt;
 ldap_bind_dn = bind-user@example.com&lt;br /&gt;
 ldap_bind_pw = bind-password&lt;br /&gt;
 ldap_user_type = MS ActiveDirectory&lt;br /&gt;
 ldap_contexts = ou=moodleusers,dc=example,dc=com&lt;br /&gt;
 ldap_user_attribute = sAMAccountName&lt;br /&gt;
&lt;br /&gt;
==Advanced Scenarios==&lt;br /&gt;
&lt;br /&gt;
===Using multiple LDAP Servers===&lt;br /&gt;
Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax :&lt;br /&gt;
ldap://my.first.server ; ldap://my.second.server ; ...&lt;br /&gt;
&lt;br /&gt;
Of course, this will only work if all the servers share the same directory information, using a replication or synchronization mecanism once introduced in eDirectory and now generalized to the main LDAP-compatible directories.&lt;br /&gt;
&lt;br /&gt;
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.&lt;br /&gt;
&lt;br /&gt;
===Using multiple user locations (contexts) in your LDAP tree===&lt;br /&gt;
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a &#039;&#039;&#039;ou=people,dc=my,dc=organization,dc=domain&#039;&#039;&#039; or &#039;&#039;&#039;ou=people,o=myorg&#039;&#039;&#039; container. &lt;br /&gt;
&lt;br /&gt;
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like &#039;&#039;&#039;ou=students,ou=dept1,o=myorg&#039;&#039;&#039; and &#039;&#039;&#039;ou=students,ou=dept2,o=myorg&#039;&#039;&#039; ...&lt;br /&gt;
&lt;br /&gt;
Then there is an alternative :&lt;br /&gt;
* Look at the &#039;&#039;&#039;o=myorg&#039;&#039;&#039; level with the ldap_search_sub attribute set to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
* Set the ldap_context to &#039;&#039;&#039;ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree &#039;&#039;&#039;and&#039;&#039;&#039; on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same &#039;&#039;common name&#039;&#039; (cn), while having different &#039;&#039;distinguished names&#039;&#039;. Then only the second solution will have a deterministic result (returning allways the same user).&lt;br /&gt;
&lt;br /&gt;
===Using LDAPS (LDAP + SSL)===&lt;br /&gt;
====MS Active Directory + SSL ====&lt;br /&gt;
&lt;br /&gt;
If the Certificate Authority is not installed you&#039;ll have to install it first as follows:&lt;br /&gt;
# Click &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Control Panel&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Add or Remove programs.&#039;&#039;&#039;&lt;br /&gt;
# Click &#039;&#039;&#039;Add/Remove Windows Components&#039;&#039;&#039; and select &#039;&#039;&#039;Certificate Services.&#039;&#039;&#039;&lt;br /&gt;
# Follow the procedure provided to install the &#039;&#039;&#039;Certificate Authority&#039;&#039;&#039;. Enterprise level is a good choice.&lt;br /&gt;
&lt;br /&gt;
Verify that SSL has been enabled on the server by installing suptools.msi from Windows installation cd&#039;s \Support\tools directory. After support tools installation:&lt;br /&gt;
# Select &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Run&#039;&#039;&#039;, write &#039;&#039;&#039;ldp&#039;&#039;&#039; in the Open field.&lt;br /&gt;
# From the ldp window select &#039;&#039;&#039;Connection&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Connect&#039;&#039;&#039; and supply valid hostname and port number &#039;&#039;&#039;636&#039;&#039;&#039;. Also select the SSL check box.&lt;br /&gt;
&lt;br /&gt;
If successful, you should get information about the connection.&lt;br /&gt;
&lt;br /&gt;
Next step is to tell PHP&#039;s OpenLDAP extension to disable SSL certificate checking. On Windows servers you&#039;re most likely using pre-compiled PHP version, where you must create a path &#039;&#039;C:\OpenLDAP\sysconf&#039;&#039;. In this path create a file called &amp;quot;ldap.conf&amp;quot; with content:&lt;br /&gt;
&lt;br /&gt;
 TLS_REQCERT never.&lt;br /&gt;
&lt;br /&gt;
Now you should be able to use &#039;&#039;&#039;ldaps://&#039;&#039;&#039; when connecting to MS-AD.&lt;br /&gt;
&lt;br /&gt;
==Appendices==&lt;br /&gt;
&lt;br /&gt;
===Child Domains and the Global Catalog in MS Active Directory===&lt;br /&gt;
&lt;br /&gt;
Moodle currently only has limited support for multiple domain controllers; specifically it expects each of the LDAP servers listed to contain identical sets of information. If you have users in multiple domains this presents an issue. One solution when working with MS-AD is to use the Global Catalog. The Global Catalog is designed to be a read-only, partial representation of an entire MS-AD forest, designed for searching the entire directory when the domain of the required object is not known.&lt;br /&gt;
&lt;br /&gt;
For example your organisation has a main domain example.org, staff and students are contained in two child domains staff.example.org and students.example.org. The 3 domains (example.org, staff.example.org and students.example.org) each have a domain controller (dc01, dc02 and dc03 respectively.) Each domain controller contains a full, writable, representation of only the objects that belong to its domain. However, assuming that the Global Catalog has been enabled (see below) on one of the domain controllers (for example dc01) a query to the Global Catalog would reveal matching objects from all three domains. The Global Catalog is automatically maintained through replication across the active directory forest, it can also be enabled on multiple servers (if, for example, you need redundancy / load balancing.)&lt;br /&gt;
&lt;br /&gt;
To make use of this in Moodle to allow logins from multiple domains is simple. The Global Catalog runs on port 3268 as opposed to 389 for standard LDAP queries. As a result, still assuming the Global Catalog is running on dc01, the &#039;&#039;&#039;&#039;ldap_host_url&#039;&#039;&#039;&#039; would be &#039;&#039;ldap://dc01.example.org:3268&#039;&#039;. The rest of the settings are the same as for other MS-AS Auth setups.&lt;br /&gt;
&lt;br /&gt;
You should use the &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting to indicate the locations of individuals you wish to grant access. To extend the example above a little: In the example.org domain users are all in the&#039;&#039; &#039;Users&#039; &#039;&#039;OU, in the staff.example.org domain users are in two OUs at the root of the domain,&#039;&#039; &#039;Support Staff&#039; &#039;&#039;and&#039;&#039; &#039;Teaching Staff&#039; &#039;&#039;, and in the students.example.org domain students are in an OU indicating the year that they enrolled, all of which are under the&#039;&#039; &#039;Students&#039; &#039;&#039;OU. As a result our &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting may look a little like this:&#039;&#039; &#039;OU=Users,DC=example,DC=org; OU=Support Staff,DC=staff,DC=example,DC=org; OU=Teaching Staff,DC=staff,DC=example,DC=org; OU=Students,DC=students,DC=example,DC=org&#039;&#039;.&#039; The &#039;&#039;&#039;&#039;ldap_search_sub&#039;&#039;&#039;&#039; option should be set to&#039;&#039; &#039;Yes&#039; &#039;&#039;to allow moodle to search within the child OUs.&lt;br /&gt;
&lt;br /&gt;
Its worth noting that the Global Catalog only contains a partial representation of the attributes of each object, as defined in the Partial Attribute Set supplied by Microsoft. However common information likely to be of use to a general Moodle installation (Forename, Surname, Email Address, sAMAccountName etc) is included in the set. For specific needs the schema can be altered to remove or add various attributes.&lt;br /&gt;
&lt;br /&gt;
In most cases the Global Catalog is read-only, update queries must be made over the standard LDAP ports to the domain controller that holds the object in question (in our example, updating a student&#039;s details would require an LDAP query to the students.example.org domain controller - dc03, it would not be possible to update details by querying the Global Catalog.) The exception to this would be in an environment where there is only a single domain in the active directory forest; in this case the Global Catalog holds a writable full set of attributes for each object in the domain. However, for the purposes of Moodle authorisation, there would be no need to use the Global Catalog in this case.&lt;br /&gt;
&lt;br /&gt;
====Enabling the Global Catalog====&lt;br /&gt;
&lt;br /&gt;
The Global Catalog is available on Windows 2000 and Windows 2003 Active Directory servers. To enable, open the ‘Active Directory Sites and Services’ MMC (Microsoft Management Console) snap-in. Extend ‘Sites’ and then the name of the Site containing the active directory forest you wish to use. Expand the server you wish to enable the Global Catalog on, right click ‘NTDS settings’ and select the ‘Properties’ tab. To enable, simply click the ‘Global Catalog’ checkbox. Under a Windows 2000 server it is necessary to restart the server (although it won’t prompt you to); under Windows 2003 server it is not necessary to restart the server. In either case you will generally have to wait for the AD forest to replicate before the Global Catalog offers a representation of the entire AD forest. Changes made in Active Directory will also be subject to a short delay due to the latency involved with replication. If your AD servers are firewalled port 3268 will need to be opened for Global Catalog servers.&lt;br /&gt;
If your organisation uses Microsoft Exchange then it its highly likely that at least one Domain Controller will already have Global Catalog enabled – Exchange 2000 and 2003 rely on the Global Catalog for address information, users also access the Global Catalog when using the GAL (Global Address List)&lt;br /&gt;
&lt;br /&gt;
====ldap auth_user_create() only suports Novell====&lt;br /&gt;
&lt;br /&gt;
After configuring user authentication with ldap I realized ldap only support edir (Novell) when combining ldap an email user confirmation. For example in my case (I use openldap) I have the following error after filling the user form:&lt;br /&gt;
&lt;br /&gt;
auth: ldap auth_user_create() does not support selected usertype:&amp;quot;rfc2307&amp;quot; (..yet)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion&lt;br /&gt;
* [[LDAP enrolment]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[es:LDAP_authentication]]&lt;br /&gt;
[[fr:Utiliser un serveur LDAP]]&lt;br /&gt;
[[zh:LDAP认证]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=18262</id>
		<title>LDAP authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=18262"/>
		<updated>2006-11-29T15:17:24Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document describes how to set up LDAP authentication in Moodle. You can find a [[#Basic Scenario|Basic Scenario]], where everything is simple and straightforward, and that should be enough for most installations. If your installation is a little bigger and you are using multiple LDAP servers, or multiple locations (contexts) for your users in your LDAP tree, then have a look at the [[#Advanced Scenarios|Advanced Scenarios]].&lt;br /&gt;
&lt;br /&gt;
==Basic Scenario==&lt;br /&gt;
&lt;br /&gt;
===Assumptions===&lt;br /&gt;
&lt;br /&gt;
# Your Moodle site is located at &#039;&#039;&#039;http://your.moodle.site/&#039;&#039;&#039;&lt;br /&gt;
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to &#039;&#039;&#039;http://your.moodle.site/admin/phpinfo.php&#039;&#039;&#039; (logged in as user &#039;admin&#039;).&lt;br /&gt;
# Your LDAP server has &#039;&#039;&#039;192.168.1.100&#039;&#039;&#039; as its IP address.&lt;br /&gt;
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.&lt;br /&gt;
# You don&#039;t want your users to change their passwords the first time they log in into Moodle.&lt;br /&gt;
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).&lt;br /&gt;
# You are using a top level distinguished name (DN) of &#039;&#039;&#039;dc=my,dc=organization,dc=domain&#039;&#039;&#039; as the root of your LDAP tree. &lt;br /&gt;
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won&#039;t hurt if you use it even if your LDAP server doesn&#039;t need it. Make sure &#039;&#039;&#039;this account and its password don&#039;t expire&#039;&#039;&#039;, and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don&#039;t be afraid of making it as hard to guess as possible. Let&#039;s say this user account has a DN of &#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;, and password &#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;.&lt;br /&gt;
# All of your Moodle users are in an organizational unit (OU) called &#039;&#039;&#039;moodleusers&#039;&#039;&#039;, which is right under your LDAP root. That OU has a DN of &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039;.&lt;br /&gt;
# You &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want your LDAP users&#039; passwords to be stored in Moodle at all.&lt;br /&gt;
&lt;br /&gt;
===Configuring Moodle authentication===&lt;br /&gt;
&lt;br /&gt;
Log in as an admin user and go to Administration &amp;gt;&amp;gt; Users &amp;gt;&amp;gt; Authentication. In the drop down listbox titled  &amp;quot;Choose an authentication method&amp;quot; select &amp;quot;Use an LDAP Server&amp;quot;. You will get a page similar to this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::: [[Image:auth_ldap_config_screenshot.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you just have to fill in the values. Let&#039;s go step by step.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| ldap_host_url&lt;br /&gt;
| As the IP of your LDAP server is 192.168.1.100, type &amp;quot;&#039;&#039;&#039;ldap://192.168.1.100&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_version&lt;br /&gt;
| Unless you are using a really old LDAP server, &#039;&#039;&#039;version 3&#039;&#039;&#039; is the one you should choose.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_preventpassindb&lt;br /&gt;
| As you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to store the users&#039;s password in Moodle&#039;s database, choose &#039;&#039;&#039;Yes&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_dn&lt;br /&gt;
| This is the distinguished name of the bind user defined above. Just type &amp;quot;&#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_pw&lt;br /&gt;
| This is the bind user password defined above. Type &amp;quot;&#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_type&lt;br /&gt;
| Choose: &lt;br /&gt;
* &#039;&#039;&#039;Novel Edirectory&#039;&#039;&#039; if your LDAP server is running Novell&#039;s eDdirectory.&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307)&#039;&#039;&#039; if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP).&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307bis)&#039;&#039;&#039; if your LDAP server is running a RFC-2307bis compatible LDAP server.&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount (v.3.0.7)&#039;&#039;&#039; if your LDAP server is running with SAMBA&#039;s 3.x LDAP schema extension and you want to use it.&lt;br /&gt;
* &#039;&#039;&#039;MS ActiveDirectory&#039;&#039;&#039; if your LDAP server is running Microsoft&#039;s Active Directory (MS-AD)&lt;br /&gt;
|-&lt;br /&gt;
| ldap_contexts&lt;br /&gt;
| The DN of the context (container) where all of your Moodle users are found. Type &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_search_sub&lt;br /&gt;
| If you have any sub organizational units (subcontexts) hanging from &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; and you want Moodle to search there too, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. Otherwise, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_opt_deref&lt;br /&gt;
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to &#039;dereference&#039; the alias and fetch the real value from the original location, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. If you don&#039;t want Moodle to dereference it, set this to &#039;&#039;&#039;no&#039;&#039;&#039;. If you are using MS-AD, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_attribute&lt;br /&gt;
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in&amp;lt;/u&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By the way, it&#039;s usually &#039;&#039;&#039;cn&#039;&#039;&#039; (Novell eDirectory and MS-AD) or &#039;&#039;&#039;uid&#039;&#039;&#039; (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could use &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039; (the pre-Windows 2000 logon account name) if you need too.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_memberattribute&lt;br /&gt;
| The attribute used to list the members of a given group. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By the way, the usual values are &#039;&#039;&#039;member&#039;&#039;&#039; and &#039;&#039;&#039;memberUid&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_objectclass&lt;br /&gt;
| The type of LDAP object used to search for users. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the default values for each of the &#039;&#039;ldap_user_type&#039;&#039; values:&lt;br /&gt;
* &#039;&#039;&#039;User&#039;&#039;&#039; for Novel eDirectory&lt;br /&gt;
* &#039;&#039;&#039;posixAccount&#039;&#039;&#039; for RFC-2037 and RFC-2037bis&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount&#039;&#039;&#039; for SAMBA 3.0.x LDAP extension&lt;br /&gt;
* &#039;&#039;&#039;user&#039;&#039;&#039; for MS-AD&lt;br /&gt;
|-&lt;br /&gt;
| Force change password&lt;br /&gt;
| Set this to &#039;&#039;Yes&#039;&#039; if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to &#039;&#039;no&#039;&#039;. Bear in mind the password they are forced to change is the one stored in your LDAP server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;As you don&#039;t want your users to change their passwords in their first login, leave this set to &#039;&#039;No&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Use standard Change Password Page&lt;br /&gt;
|&lt;br /&gt;
* Setting this to &#039;&#039;Yes&#039;&#039; makes Moodle use it&#039;s own standard password change page, everytime users want to change their passwords.&lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; makes Moodle use the the page specified in the field called &amp;quot;Change password URL&amp;quot; (at the bottom of the configuration page).&lt;br /&gt;
&lt;br /&gt;
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is true at least for MS-AD).&lt;br /&gt;
&lt;br /&gt;
Also, code for changing passwords from Moodle for anything but Novell eDirectory is almost not tested, so this may or may not work for other LDAP servers.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration&lt;br /&gt;
| &lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; will make Moodle not to check if the password of the user has expired or not.&lt;br /&gt;
* Setting this to &#039;&#039;LDAP&#039;&#039; will make Moodle check if the LDAP password of the user has expired or not, and warn her a number of days before the password expires.&lt;br /&gt;
&lt;br /&gt;
Current code only deals with Novell eDirectory LDAP server, but there is a patch floating around to make it work with MS-AD too (search in the authentication forum).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server (or use the patch), choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration_warning&lt;br /&gt;
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_exprireattr&lt;br /&gt;
| The LDAP user attribute used to check password expiration. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_gracelogins&lt;br /&gt;
| This setting is specific to Novell eDirectory. If set to &#039;&#039;Yes&#039;&#039;, enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server and want to allow gracelogin support, choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_graceattr&lt;br /&gt;
| This setting is currently not used in the code (and is specific to Novell eDirectory). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_create_context&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| ldap_creators&lt;br /&gt;
| The DN of the group that contains all of your Moodle creators. This is typically a posixGroup with a &amp;quot;memberUid&amp;quot; attribute for each user you want to be a creator.  If your group is called &#039;&#039;creators&#039;&#039;, type &#039;&#039;&#039;cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.  Each memberUid attribute contains the CN of a user who is authorized to be a creator.  Do not use the user&#039;s full DN (e.g.,  not &#039;&#039;&#039;memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain&#039;&#039;&#039;, but rather &#039;&#039;&#039;memberUid: JoeTeacher&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
In eDirectory, the objectClass for a group is (by default) not &#039;&#039;&#039;posixGroup&#039;&#039;&#039; but &#039;&#039;&#039;groupOfNames,&#039;&#039;&#039; whose member attribute is &#039;&#039;&#039;member,&#039;&#039;&#039; not &#039;&#039;&#039;memberUid,&#039;&#039;&#039; and whose value is the full DN of the user in question.  Although you can probably modify Moodle&#039;s code to use this field, a better solution is just to add a new &#039;&#039;&#039;objectClass&#039;&#039;&#039; attribute of &#039;&#039;&#039;posixGroup&#039;&#039;&#039; to your creators group and put the CNs for each creator in a &#039;&#039;&#039;memberUid&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is &#039;ou=staff,dc=my,dc=org&#039; then your group should then be &#039;cn=creators,ou=staff,dc=my,dc=org&#039;. If some of the users are from other contexts and have been added to the same security group, you&#039;ll have to add these as separate contexts after the first one using the same format.&lt;br /&gt;
|-&lt;br /&gt;
| First name&lt;br /&gt;
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually &#039;&#039;&#039;givenName&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Surname&lt;br /&gt;
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually &#039;&#039;&#039;sn&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Email address&lt;br /&gt;
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually &#039;&#039;&#039;mail&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 1&lt;br /&gt;
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually &#039;&#039;&#039;telephoneNumber&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 2&lt;br /&gt;
|  The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be &#039;&#039;&#039;homePhone&#039;&#039;&#039;, &#039;&#039;&#039;mobile&#039;&#039;&#039;, &#039;&#039;&#039;pager&#039;&#039;&#039;, &#039;&#039;&#039;facsimileTelephoneNumber&#039;&#039;&#039; or even others.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Department&lt;br /&gt;
| The name of the attribute that holds the department name of your users in your LDAP server. This is usully &#039;&#039;&#039;departmentNumber&#039;&#039;&#039; (for posixAccount and maybe eDirectory) or &#039;&#039;&#039;department&#039;&#039;&#039; (for MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Address&lt;br /&gt;
| The name of the attribute that holds the street address of your users in your LDAP server. This is usully &#039;&#039;&#039;streetAddress&#039;&#039;&#039; or &#039;&#039;&#039;street&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| City/town&lt;br /&gt;
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usully &#039;&#039;&#039;l&#039;&#039;&#039; (lowercase L) or &#039;&#039;&#039;localityName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| Country&lt;br /&gt;
| The name of the attribute that holds the couuntry of your users in your LDAP server. This is usully &#039;&#039;&#039;c&#039;&#039;&#039; or &#039;&#039;&#039;countryName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Description&lt;br /&gt;
| &#039;&#039;&#039;description&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ID Number&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Language&lt;br /&gt;
| &#039;&#039;&#039;preferredLanguage&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Instructions&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the fields are common to all authentication methods and will not be discussed here.&lt;br /&gt;
&lt;br /&gt;
==Active Directory Troubleshooting Help==&lt;br /&gt;
&lt;br /&gt;
===Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled.===&lt;br /&gt;
This usually means that the main ldap dll or one of the supporting dlls are missing.&lt;br /&gt;
Let&#039;s start with the main one itself. &lt;br /&gt;
Use the &amp;quot;Configuration File (php.ini) Path&amp;quot; field on http://[moodleserver]/admin/phpinfo.php to determine which php.ini is being used and open it. Find the line &#039;extension=php_ldap.dll&#039; and take out the semi-colon if it is there. That semi-colon will stop it loading the module all together! &lt;br /&gt;
While you have that file open, search for &#039;extension_dir&#039; and note which folder it is set to. Open that folder and ensure the php_ldap.dll file is in there. If it isn&#039;t then put it in there.&lt;br /&gt;
If that still hasn&#039;t fixed it you are missing a supporting dll, but you don&#039;t get told that. To see what dlls are missing open the Command Propmt and navigate to the php directory and execute the following line &#039;php -m&#039;. You should get some error messages now. Ugly, but at least they give you information! Find the dlls listed and copy them to the php directory. Run &#039;php -m&#039; again and you should be error free and the message in Moodle should be gone now.&lt;br /&gt;
&lt;br /&gt;
===LDAP-module cannot connect any LDAP servers : Server: &#039;ldap://my.ldap.server/&#039; Connection: &#039;Resource id #26&#039; Bind result: &#039;&#039;===&lt;br /&gt;
Getting this message when you are trying to log in is a result of incorrect details for the Bind user, or the user account having insufficient permissions in Active Directory. The best way to test and resolve this is use ldp.exe to test binding until it suceeds. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open the program and Connect to AD, giving the server name, then from the Connection menu choose Bind. Enter the details you think are correct and you will probably find that an error is returned. Try adjusting the accounts priveleges or another account until you are returned an &amp;quot;Authenticated as&amp;quot; message.&lt;br /&gt;
Once you are sure your account can be used to bind to AD, check that the DN of that users name is correct. Expand the tree on the left until you find the user you used to bind. Right click on that item and choose Copy DN. Go to the User Authentication page in Moodle and paste the value into the ldap_bind_dn field. Add the password and you can now feel safe your user is binding sucessfully.&lt;br /&gt;
&lt;br /&gt;
===Getting correct CNs for Contexts and Creators===&lt;br /&gt;
For those not familiar with AD this could be very confusing, and not that easy for some who are familiar with it. Again, ldp.exe is your friend. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open it up and expand the tree on the left until you find the group or user you want to use and right click on it and select Copy DN. Go back to the Moodle User Authentication page and paste that value into either ldap_contexts or ldap_creators.&lt;br /&gt;
&lt;br /&gt;
===Getting the right user_attribute===&lt;br /&gt;
By default, Moodle uses an accounts cn (full name) to verify against, but most networks don&#039;t use a full given name for logon as it&#039;s too easy to guess and you can easily have two people with the same name. If this is the case for you too you need to tell Moodle to look at another field for the logon id.&lt;br /&gt;
In ldp.exe navigate the tree on the left to find a user account, preferably your own. Double-click the item in the tree and full-details will be loaded into the screen on the right. Look down the details until you find your logon id and note the item listed against it. For me, and a lot of people, it is sAMAccountName. Copy this name and paste it into the ldap_user_attribute on the Moodle User Authentication page.&lt;br /&gt;
There are instructions on installing ldp.exe below.&lt;br /&gt;
&lt;br /&gt;
===Installing ldp.exe Server Tool===&lt;br /&gt;
ldp.exe comes as part of the Server Tools on most versions of Windows Server. Find your Windows Server installation disc and find a folder on it called Support\Tools. In there will be a SupTools.msi which will install the server tools if run. You should now have a folder under Program Files called Support Tools, in which will be ldp.exe. ldp.exe is also available in the Windows XP Support Tools, which you can download from Microsoft [http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&amp;amp;displaylang=en here]. Alternatively, a single download of ldp.exe is available [http://www.computerperformance.co.uk/w2k3/utilities/ldp.htm here].&lt;br /&gt;
&lt;br /&gt;
===Example Active Directory Configuration===&lt;br /&gt;
Below is an example configuration for Active Directory. As detailed above, the values may vary based on your local Active Directory configuration, but should provide a good starting point for most cases.&lt;br /&gt;
&lt;br /&gt;
 ldap_host_url = ldap://ads.example.com&lt;br /&gt;
 ldap_version = 3&lt;br /&gt;
 ldap_preventpassindb = yes&lt;br /&gt;
 ldap_bind_dn = bind-user@example.com&lt;br /&gt;
 ldap_bind_pw = bind-password&lt;br /&gt;
 ldap_user_type = MS ActiveDirectory&lt;br /&gt;
 ldap_contexts = ou=moodleusers,dc=example,dc=com&lt;br /&gt;
 ldap_user_attribute = sAMAccountName&lt;br /&gt;
&lt;br /&gt;
==Advanced Scenarios==&lt;br /&gt;
&lt;br /&gt;
===Using multiple LDAP Servers===&lt;br /&gt;
Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax :&lt;br /&gt;
ldap://my.first.server ; ldap://my.second.server ; ...&lt;br /&gt;
&lt;br /&gt;
Of course, this will only work if all the servers share the same directory information, using a replication or synchronization mecanism once introduced in eDirectory and now generalized to the main LDAP-compatible directories.&lt;br /&gt;
&lt;br /&gt;
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.&lt;br /&gt;
&lt;br /&gt;
===Using multiple user locations (contexts) in your LDAP tree===&lt;br /&gt;
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a &#039;&#039;&#039;ou=people,dc=my,dc=organization,dc=domain&#039;&#039;&#039; or &#039;&#039;&#039;ou=people,o=myorg&#039;&#039;&#039; container. &lt;br /&gt;
&lt;br /&gt;
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like &#039;&#039;&#039;ou=students,ou=dept1,o=myorg&#039;&#039;&#039; and &#039;&#039;&#039;ou=students,ou=dept2,o=myorg&#039;&#039;&#039; ...&lt;br /&gt;
&lt;br /&gt;
Then there is an alternative :&lt;br /&gt;
* Look at the &#039;&#039;&#039;o=myorg&#039;&#039;&#039; level with the ldap_search_sub attribute set to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
* Set the ldap_context to &#039;&#039;&#039;ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree &#039;&#039;&#039;and&#039;&#039;&#039; on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same &#039;&#039;common name&#039;&#039; (cn), while having different &#039;&#039;distinguished names&#039;&#039;. Then only the second solution will have a deterministic result (returning allways the same user).&lt;br /&gt;
&lt;br /&gt;
===Using LDAPS (LDAP + SSL)===&lt;br /&gt;
====MS Active Directory + SSL ====&lt;br /&gt;
&lt;br /&gt;
If the Certificate Authority is not installed you&#039;ll have to install it first as follows:&lt;br /&gt;
# Click &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Control Panel&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Add or Remove programs.&#039;&#039;&#039;&lt;br /&gt;
# Click &#039;&#039;&#039;Add/Remove Windows Components&#039;&#039;&#039; and select &#039;&#039;&#039;Certificate Services.&#039;&#039;&#039;&lt;br /&gt;
# Follow the procedure provided to install the &#039;&#039;&#039;Certificate Authority&#039;&#039;&#039;. Enterprise level is a good choice.&lt;br /&gt;
&lt;br /&gt;
Verify that SSL has been enabled on the server by installing suptools.msi from Windows installation cd&#039;s \Support\tools directory. After support tools installation:&lt;br /&gt;
# Select &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Run&#039;&#039;&#039;, write &#039;&#039;&#039;ldp&#039;&#039;&#039; in the Open field.&lt;br /&gt;
# From the ldp window select &#039;&#039;&#039;Connection&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Connect&#039;&#039;&#039; and supply valid hostname and port number &#039;&#039;&#039;636&#039;&#039;&#039;. Also select the SSL check box.&lt;br /&gt;
&lt;br /&gt;
If successful, you should get information about the connection.&lt;br /&gt;
&lt;br /&gt;
Next step is to tell PHP&#039;s OpenLDAP extension to disable SSL certificate checking. On Windows servers you&#039;re most likely using pre-compiled PHP version, where you must create a path &#039;&#039;C:\OpenLDAP\sysconf&#039;&#039;. In this path create a file called &amp;quot;ldap.conf&amp;quot; with content:&lt;br /&gt;
&lt;br /&gt;
 TLS_REQCERT never.&lt;br /&gt;
&lt;br /&gt;
Now you should be able to use &#039;&#039;&#039;ldaps://&#039;&#039;&#039; when connecting to MS-AD.&lt;br /&gt;
&lt;br /&gt;
==Appendices==&lt;br /&gt;
&lt;br /&gt;
===Child Domains and the Global Catalog in MS Active Directory===&lt;br /&gt;
&lt;br /&gt;
Moodle currently only has limited support for multiple domain controllers; specifically it expects each of the LDAP servers listed to contain identical sets of information. If you have users in multiple domains this presents an issue. One solution when working with MS-AD is to use the Global Catalog. The Global Catalog is designed to be a read-only, partial representation of an entire MS-AD forest, designed for searching the entire directory when the domain of the required object is not known.&lt;br /&gt;
&lt;br /&gt;
For example your organisation has a main domain example.org, staff and students are contained in two child domains staff.example.org and students.example.org. The 3 domains (example.org, staff.example.org and students.example.org) each have a domain controller (dc01, dc02 and dc03 respectively.) Each domain controller contains a full, writable, representation of only the objects that belong to its domain. However, assuming that the Global Catalog has been enabled (see below) on one of the domain controllers (for example dc01) a query to the Global Catalog would reveal matching objects from all three domains. The Global Catalog is automatically maintained through replication across the active directory forest, it can also be enabled on multiple servers (if, for example, you need redundancy / load balancing.)&lt;br /&gt;
&lt;br /&gt;
To make use of this in Moodle to allow logins from multiple domains is simple. The Global Catalog runs on port 3268 as opposed to 389 for standard LDAP queries. As a result, still assuming the Global Catalog is running on dc01, the &#039;&#039;&#039;&#039;ldap_host_url&#039;&#039;&#039;&#039; would be &#039;&#039;ldap://dc01.example.org:3268&#039;&#039;. The rest of the settings are the same as for other MS-AS Auth setups.&lt;br /&gt;
&lt;br /&gt;
You should use the &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting to indicate the locations of individuals you wish to grant access. To extend the example above a little: In the example.org domain users are all in the&#039;&#039; &#039;Users&#039; &#039;&#039;OU, in the staff.example.org domain users are in two OUs at the root of the domain,&#039;&#039; &#039;Support Staff&#039; &#039;&#039;and&#039;&#039; &#039;Teaching Staff&#039; &#039;&#039;, and in the students.example.org domain students are in an OU indicating the year that they enrolled, all of which are under the&#039;&#039; &#039;Students&#039; &#039;&#039;OU. As a result our &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting may look a little like this:&#039;&#039; &#039;OU=Users,DC=example,DC=org; OU=Support Staff,DC=staff,DC=example,DC=org; OU=Teaching Staff,DC=staff,DC=example,DC=org; OU=Students,DC=students,DC=example,DC=org&#039;&#039;.&#039; The &#039;&#039;&#039;&#039;ldap_search_sub&#039;&#039;&#039;&#039; option should be set to&#039;&#039; &#039;Yes&#039; &#039;&#039;to allow moodle to search within the child OUs.&lt;br /&gt;
&lt;br /&gt;
Its worth noting that the Global Catalog only contains a partial representation of the attributes of each object, as defined in the Partial Attribute Set supplied by Microsoft. However common information likely to be of use to a general Moodle installation (Forename, Surname, Email Address, sAMAccountName etc) is included in the set. For specific needs the schema can be altered to remove or add various attributes.&lt;br /&gt;
&lt;br /&gt;
In most cases the Global Catalog is read-only, update queries must be made over the standard LDAP ports to the domain controller that holds the object in question (in our example, updating a student&#039;s details would require an LDAP query to the students.example.org domain controller - dc03, it would not be possible to update details by querying the Global Catalog.) The exception to this would be in an environment where there is only a single domain in the active directory forest; in this case the Global Catalog holds a writable full set of attributes for each object in the domain. However, for the purposes of Moodle authorisation, there would be no need to use the Global Catalog in this case.&lt;br /&gt;
&lt;br /&gt;
====Enabling the Global Catalog====&lt;br /&gt;
&lt;br /&gt;
The Global Catalog is available on Windows 2000 and Windows 2003 Active Directory servers. To enable, open the ‘Active Directory Sites and Services’ MMC (Microsoft Management Console) snap-in. Extend ‘Sites’ and then the name of the Site containing the active directory forest you wish to use. Expand the server you wish to enable the Global Catalog on, right click ‘NTDS settings’ and select the ‘Properties’ tab. To enable, simply click the ‘Global Catalog’ checkbox. Under a Windows 2000 server it is necessary to restart the server (although it won’t prompt you to); under Windows 2003 server it is not necessary to restart the server. In either case you will generally have to wait for the AD forest to replicate before the Global Catalog offers a representation of the entire AD forest. Changes made in Active Directory will also be subject to a short delay due to the latency involved with replication. If your AD servers are firewalled port 3268 will need to be opened for Global Catalog servers.&lt;br /&gt;
If your organisation uses Microsoft Exchange then it its highly likely that at least one Domain Controller will already have Global Catalog enabled – Exchange 2000 and 2003 rely on the Global Catalog for address information, users also access the Global Catalog when using the GAL (Global Address List)&lt;br /&gt;
&lt;br /&gt;
====ldap auth_user_create() only suports Novell====&lt;br /&gt;
&lt;br /&gt;
After configuring user authentication with ldap I realized ldap only support edir (Novell) when combining ldap an email user confirmation. For example in my case (I use openldap) I have the following error after filling the user form:&lt;br /&gt;
&lt;br /&gt;
auth: ldap auth_user_create() does not support selected usertype:&amp;quot;rfc2307&amp;quot; (..yet)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion&lt;br /&gt;
* [[LDAP enrolment]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[es:LDAP_authentication]]&lt;br /&gt;
[[fr:Utiliser un serveur LDAP]]&lt;br /&gt;
[[zh:LDAP认证]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=RSS_feeds&amp;diff=18234</id>
		<title>RSS feeds</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=RSS_feeds&amp;diff=18234"/>
		<updated>2006-11-28T14:48:10Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: /* Turn RSS feeds on */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;RSS&#039;&#039;&#039; (&#039;&#039;&#039;Really Simple Syndication&#039;&#039;&#039;, depending on who you ask) allows certain web browsers and specialized programs to automatically check for updates to a page.&lt;br /&gt;
&lt;br /&gt;
== Turn RSS feeds on==&lt;br /&gt;
&lt;br /&gt;
To enable RSS as administrator, go to Configuration and under Variables: Miscellaneous set enablerssfeeds to Yes. In v1.7 this option moved to the Server menu. Then in Configuration: Modules you can enable an RSS feed for each module. Finally, in the settings for each individual instance of a particular module you must enable the RSS feed and specify the settings (e.g. how many articles to display, what kind of article).&lt;br /&gt;
&lt;br /&gt;
== Subscribing to RSS feeds==&lt;br /&gt;
To subscribe to an RSS feed from moodle, click on the orange &#039;RSS&#039; button and copy the address from your browser bar to your RSS reader software. Although most web browsers will automatically detect an RSS feed (IE7 and Firefox), moodle does not seem to be sending them the correct information (as of 1.5 - is this fixed in 1.6?)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[RSS in Forums]]&lt;br /&gt;
* [[RSS in Glossaries]]&lt;br /&gt;
* [[RSS feeds block]]&lt;br /&gt;
*[http://news.bbc.co.uk/1/hi/help/3223484.stm BBC: An introduction to RSS Feed (Really Simple Syndication)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/RSS_%28file_format%29 Wikipedia &amp;quot;RSS (file format)&amp;quot; ]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:RSS]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=17000</id>
		<title>LDAP authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=17000"/>
		<updated>2006-10-13T15:31:05Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: Corrected ldap.exe to ldp.exe&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document describes how to set up LDAP authentication in Moodle. You can find a [[#Basic Scenario|Basic Scenario]], where everything is simple and straightforward, and that should be enough for most installations. If your installation is a little bigger and you are using multiple LDAP servers, or multiple locations (contexts) for your users in your LDAP tree, then have a look at the [[#Advanced Scenarios|Advanced Scenarios]].&lt;br /&gt;
&lt;br /&gt;
==Basic Scenario==&lt;br /&gt;
&lt;br /&gt;
===Assumptions===&lt;br /&gt;
&lt;br /&gt;
# Your Moodle site is located at &#039;&#039;&#039;http://your.moodle.site/&#039;&#039;&#039;&lt;br /&gt;
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to &#039;&#039;&#039;http://your.moodle.site/admin/phpinfo.php&#039;&#039;&#039; (logged in as user &#039;admin&#039;).&lt;br /&gt;
# Your LDAP server has &#039;&#039;&#039;192.168.1.100&#039;&#039;&#039; as its IP address.&lt;br /&gt;
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.&lt;br /&gt;
# You don&#039;t want your users to change their passwords the first time they log in into Moodle.&lt;br /&gt;
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).&lt;br /&gt;
# You are using a top level distinguished name (DN) of &#039;&#039;&#039;dc=my,dc=organization,dc=domain&#039;&#039;&#039; as the root of your LDAP tree. &lt;br /&gt;
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won&#039;t hurt if you use it even if your LDAP server doesn&#039;t need it. Make sure &#039;&#039;&#039;this account and its password don&#039;t expire&#039;&#039;&#039;, and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don&#039;t be afraid of making it as hard to guess as possible. Let&#039;s say this user account has a DN of &#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;, and password &#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;.&lt;br /&gt;
# All of your Moodle users are in an organizational unit (OU) called &#039;&#039;&#039;moodleusers&#039;&#039;&#039;, which is right under your LDAP root. That OU has a DN of &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039;.&lt;br /&gt;
# You &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want your LDAP users&#039; passwords to be stored in Moodle at all.&lt;br /&gt;
&lt;br /&gt;
===Configuring Moodle authentication===&lt;br /&gt;
&lt;br /&gt;
Log in as an admin user and go to Administration &amp;gt;&amp;gt; Users &amp;gt;&amp;gt; Authentication. In the drop down listbox titled  &amp;quot;Choose an authentication method&amp;quot; select &amp;quot;Use an LDAP Server&amp;quot;. You will get a page similar to this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::: [[Image:auth_ldap_config_screenshot.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you just have to fill in the values. Let&#039;s go step by step.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| ldap_host_url&lt;br /&gt;
| As the IP of your LDAP server is 192.168.1.100, type &amp;quot;&#039;&#039;&#039;ldap://192.168.1.100&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_version&lt;br /&gt;
| Unless you are using a really old LDAP server, &#039;&#039;&#039;version 3&#039;&#039;&#039; is the one you should choose.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_preventpassindb&lt;br /&gt;
| As you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to store the users&#039;s password in Moodle&#039;s database, choose &#039;&#039;&#039;Yes&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_dn&lt;br /&gt;
| This is the distinguished name of the bind user defined above. Just type &amp;quot;&#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_pw&lt;br /&gt;
| This is the bind user password defined above. Type &amp;quot;&#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_type&lt;br /&gt;
| Choose: &lt;br /&gt;
* &#039;&#039;&#039;Novel Edirectory&#039;&#039;&#039; if your LDAP server is running Novell&#039;s eDdirectory.&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307)&#039;&#039;&#039; if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP).&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307bis)&#039;&#039;&#039; if your LDAP server is running a RFC-2307bis compatible LDAP server.&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount (v.3.0.7)&#039;&#039;&#039; if your LDAP server is running with SAMBA&#039;s 3.x LDAP schema extension and you want to use it.&lt;br /&gt;
* &#039;&#039;&#039;MS ActiveDirectory&#039;&#039;&#039; if your LDAP server is running Microsoft&#039;s Active Directory (MS-AD)&lt;br /&gt;
|-&lt;br /&gt;
| ldap_contexts&lt;br /&gt;
| The DN of the context (container) where all of your Moodle users are found. Type &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_search_sub&lt;br /&gt;
| If you have any sub organizational units (subcontexts) hanging from &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; and you want Moodle to search there too, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. Otherwise, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_opt_deref&lt;br /&gt;
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to &#039;dereference&#039; the alias and fetch the real value from the original location, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. If you don&#039;t want Moodle to dereference it, set this to &#039;&#039;&#039;no&#039;&#039;&#039;. If you are using MS-AD, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_attribute&lt;br /&gt;
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in&amp;lt;/u&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By the way, it&#039;s usually &#039;&#039;&#039;cn&#039;&#039;&#039; (Novell eDirectory and MS-AD) or &#039;&#039;&#039;uid&#039;&#039;&#039; (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could use &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039; (the pre-Windows 2000 logon account name) if you need too.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_memberattribute&lt;br /&gt;
| The attribute used to list the members of a given group. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By the way, the usual values are &#039;&#039;&#039;member&#039;&#039;&#039; and &#039;&#039;&#039;memberUid&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_objectclass&lt;br /&gt;
| The type of LDAP object used to search for users. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the default values for each of the &#039;&#039;ldap_user_type&#039;&#039; values:&lt;br /&gt;
* &#039;&#039;&#039;User&#039;&#039;&#039; for Novel eDirectory&lt;br /&gt;
* &#039;&#039;&#039;posixAccount&#039;&#039;&#039; for RFC-2037 and RFC-2037bis&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount&#039;&#039;&#039; for SAMBA 3.0.x LDAP extension&lt;br /&gt;
* &#039;&#039;&#039;user&#039;&#039;&#039; for MS-AD&lt;br /&gt;
|-&lt;br /&gt;
| Force change password&lt;br /&gt;
| Set this to &#039;&#039;Yes&#039;&#039; if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to &#039;&#039;no&#039;&#039;. Bear in mind the password they are forced to change is the one stored in your LDAP server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;As you don&#039;t want your users to change their passwords in their first login, leave this set to &#039;&#039;No&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Use standard Change Password Page&lt;br /&gt;
|&lt;br /&gt;
* Setting this to &#039;&#039;Yes&#039;&#039; makes Moodle use it&#039;s own standard password change page, everytime users want to change their passwords.&lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; makes Moodle use the the page specified in the field called &amp;quot;Change password URL&amp;quot; (at the bottom of the configuration page).&lt;br /&gt;
&lt;br /&gt;
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is true at least for MS-AD).&lt;br /&gt;
&lt;br /&gt;
Also, code for changing passwords from Moodle for anything but Novell eDirectory is almost not tested, so this may or may not work for other LDAP servers.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration&lt;br /&gt;
| &lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; will make Moodle not to check if the password of the user has expired or not.&lt;br /&gt;
* Setting this to &#039;&#039;LDAP&#039;&#039; will make Moodle check if the LDAP password of the user has expired or not, and warn her a number of days before the password expires.&lt;br /&gt;
&lt;br /&gt;
Current code only deals with Novell eDirectory LDAP server, but there is a patch floating around to make it work with MS-AD too (search in the authentication forum).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server (or use the patch), choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration_warning&lt;br /&gt;
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_exprireattr&lt;br /&gt;
| The LDAP user attribute used to check password expiration. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_gracelogins&lt;br /&gt;
| This setting is specific to Novell eDirectory. If set to &#039;&#039;Yes&#039;&#039;, enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server and want to allow gracelogin support, choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_graceattr&lt;br /&gt;
| This setting is currently not used in the code (and is specific to Novell eDirectory). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_create_context&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| ldap_creators&lt;br /&gt;
| The DN of the group that contains all of your Moodle creators. This is typically a posixGroup with a &amp;quot;memberUid&amp;quot; attribute for each user you want to be a creator.  If your group is called &#039;&#039;creators&#039;&#039;, type &#039;&#039;&#039;cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.  Each memberUid attribute contains the CN of a user who is authorized to be a creator.  Do not use the user&#039;s full DN (e.g.,  not &#039;&#039;&#039;memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain&#039;&#039;&#039;, but rather &#039;&#039;&#039;memberUid: JoeTeacher&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
In eDirectory, the objectClass for a group is (by default) not &#039;&#039;&#039;posixGroup&#039;&#039;&#039; but &#039;&#039;&#039;groupOfNames,&#039;&#039;&#039; whose member attribute is &#039;&#039;&#039;member,&#039;&#039;&#039; not &#039;&#039;&#039;memberUid,&#039;&#039;&#039; and whose value is the full DN of the user in question.  Although you can probably modify Moodle&#039;s code to use this field, a better solution is just to add a new &#039;&#039;&#039;objectClass&#039;&#039;&#039; attribute of &#039;&#039;&#039;posixGroup&#039;&#039;&#039; to your creators group and put the CNs for each creator in a &#039;&#039;&#039;memberUid&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is &#039;ou=staff,dc=my,dc=org&#039; then your group should then be &#039;cn=creators,ou=staff,dc=my,dc=org&#039;. If some of the users are from other contexts and have been added to the same security group, you&#039;ll have to add these as separate contexts after the first one using the same format.&lt;br /&gt;
|-&lt;br /&gt;
| First name&lt;br /&gt;
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually &#039;&#039;&#039;givenName&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Surname&lt;br /&gt;
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually &#039;&#039;&#039;sn&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Email address&lt;br /&gt;
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually &#039;&#039;&#039;mail&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 1&lt;br /&gt;
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually &#039;&#039;&#039;telephoneNumber&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 2&lt;br /&gt;
|  The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be &#039;&#039;&#039;homePhone&#039;&#039;&#039;, &#039;&#039;&#039;mobile&#039;&#039;&#039;, &#039;&#039;&#039;pager&#039;&#039;&#039;, &#039;&#039;&#039;facsimileTelephoneNumber&#039;&#039;&#039; or even others.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Department&lt;br /&gt;
| The name of the attribute that holds the department name of your users in your LDAP server. This is usully &#039;&#039;&#039;departmentNumber&#039;&#039;&#039; (for posixAccount and maybe eDirectory) or &#039;&#039;&#039;department&#039;&#039;&#039; (for MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Address&lt;br /&gt;
| The name of the attribute that holds the street address of your users in your LDAP server. This is usully &#039;&#039;&#039;streetAddress&#039;&#039;&#039; or &#039;&#039;&#039;street&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| City/town&lt;br /&gt;
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usully &#039;&#039;&#039;l&#039;&#039;&#039; (lowercase L) or &#039;&#039;&#039;localityName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| Country&lt;br /&gt;
| The name of the attribute that holds the couuntry of your users in your LDAP server. This is usully &#039;&#039;&#039;c&#039;&#039;&#039; or &#039;&#039;&#039;countryName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Description&lt;br /&gt;
| &#039;&#039;&#039;description&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ID Number&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Language&lt;br /&gt;
| &#039;&#039;&#039;preferredLanguage&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Instructions&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the fields are common to all authentication methods and will not be discussed here.&lt;br /&gt;
&lt;br /&gt;
==Active Directory Troubleshooting Help==&lt;br /&gt;
&lt;br /&gt;
===Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled.===&lt;br /&gt;
This usually means that the main ldap dll or one of the supporting dlls are missing.&lt;br /&gt;
Let&#039;s start with the main one itself. &lt;br /&gt;
Use the &amp;quot;Configuration File (php.ini) Path&amp;quot; field on http://s-moodle1/admin/phpinfo.php to determine which php.ini is being used and open it. Find the line &#039;extension=php_ldap.dll&#039; and take out the semi-colon if it is there. That semi-colon will stop it loading the module all together! &lt;br /&gt;
While you have that file open, search for &#039;extension_dir&#039; and note which folder it is set to. Open that folder and ensure the php_ldap.dll file is in there. If it isn&#039;t then put it in there.&lt;br /&gt;
If that still hasn&#039;t fixed it you are missing a supporting dll, but you don&#039;t get told that. To see what dlls are missing open the Command Propmt and navigate to the php directory and execute the following line &#039;php -m&#039;. You should get some error messages now. Ugly, but at least they give you information! Find the dlls listed and copy them to the php directory. Run &#039;php -m&#039; again and you should be error free and the message in Moodle should be gone now.&lt;br /&gt;
&lt;br /&gt;
===LDAP-module cannot connect any LDAP servers : Server: &#039;ldap://my.ldap.server/&#039; Connection: &#039;Resource id #26&#039; Bind result: &#039;&#039;===&lt;br /&gt;
Getting this message when you are trying to log in is a result of incorrect details for the Bind user, or the user account having insufficient permissions in Active Directory. The best way to test and resolve this is use ldp.exe to test binding until it suceeds. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open the program and Connect to AD, giving the server name, then from the Connection menu choose Bind. Enter the details you think are correct and you will probably find that an error is returned. Try adjusting the accounts priveleges or another account until you are returned an &amp;quot;Authenticated as&amp;quot; message.&lt;br /&gt;
Once you are sure your account can be used to bind to AD, check that the DN of that users name is correct. Expand the tree on the left until you find the user you used to bind. Right click on that item and choose Copy DN. Go to the User Authentication page in Moodle and paste the value into the ldap_bind_dn field. Add the password and you can now feel safe your user is binding sucessfully.&lt;br /&gt;
&lt;br /&gt;
===Getting correct CNs for Contexts and Creators===&lt;br /&gt;
For those not familiar with AD this could be very confusing, and not that easy for some who are familiar with it. Again, ldp.exe is your friend. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open it up and expand the tree on the left until you find the group or user you want to use and right click on it and select Copy DN. Go back to the Moodle User Authentication page and paste that value into either ldap_contexts or ldap_creators.&lt;br /&gt;
&lt;br /&gt;
===Getting the right user_attribute===&lt;br /&gt;
By default, Moodle uses an accounts cn (full name) to verify against, but most networks don&#039;t use a full given name for logon as it&#039;s too easy to guess and you can easily have two people with the same name. If this is the case for you too you need to tell Moodle to look at another field for the logon id.&lt;br /&gt;
In ldp.exe navigate the tree on the left to find a user account, preferably your own. Double-click the item in the tree and full-details will be loaded into the screen on the right. Look down the details until you find your logon id and note the item listed against it. For me, and a lot of people, it is sAMAccountName. Copy this name and paste it into the ldap_user_attribute on the Moodle User Authentication page.&lt;br /&gt;
There are instructions on installing ldp.exe below.&lt;br /&gt;
&lt;br /&gt;
===Installing ldp.exe Server Tool===&lt;br /&gt;
ldp.exe comes as part of the Server Tools on most versions of Windows Server. Find your Windows Server installation disc and find a folder on it called Support\Tools. In there will be a SupTools.msi which will install the server tools if run. You should now have a folder under Program Files called Support Tools, in which will be ldp.exe&lt;br /&gt;
&lt;br /&gt;
==Advanced Scenarios==&lt;br /&gt;
&lt;br /&gt;
===Using multiple LDAP Servers===&lt;br /&gt;
Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax :&lt;br /&gt;
ldap://my.first.server ; ldap://my.second.server ; ...&lt;br /&gt;
&lt;br /&gt;
Of course, this will only work if all the servers share the same directory information, using a replication or synchronization mecanism once introduced in eDirectory and now generalized to the main LDAP-compatible directories.&lt;br /&gt;
&lt;br /&gt;
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.&lt;br /&gt;
&lt;br /&gt;
===Using multiple user locations (contexts) in your LDAP tree===&lt;br /&gt;
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a &#039;&#039;&#039;ou=people,dc=my,dc=organization,dc=domain&#039;&#039;&#039; or &#039;&#039;&#039;ou=people,o=myorg&#039;&#039;&#039; container. &lt;br /&gt;
&lt;br /&gt;
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like &#039;&#039;&#039;ou=students,ou=dept1,o=myorg&#039;&#039;&#039; and &#039;&#039;&#039;ou=students,ou=dept2,o=myorg&#039;&#039;&#039; ...&lt;br /&gt;
&lt;br /&gt;
Then there is an alternative :&lt;br /&gt;
* Look at the &#039;&#039;&#039;o=myorg&#039;&#039;&#039; level with the ldap_search_sub attribute set to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
* Set the ldap_context to &#039;&#039;&#039;ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree &#039;&#039;&#039;and&#039;&#039;&#039; on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same &#039;&#039;common name&#039;&#039; (cn), while having different &#039;&#039;distinguished names&#039;&#039;. Then only the second solution will have a deterministic result (returning allways the same user).&lt;br /&gt;
&lt;br /&gt;
===Using LDAPS (LDAP + SSL)===&lt;br /&gt;
====MS Active Directory + SSL ====&lt;br /&gt;
&lt;br /&gt;
If the Certificate Authority is not installed you&#039;ll have to install it first as follows:&lt;br /&gt;
# Click &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Control Panel&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Add or Remove programs.&#039;&#039;&#039;&lt;br /&gt;
# Click &#039;&#039;&#039;Add/Remove Windows Components&#039;&#039;&#039; and select &#039;&#039;&#039;Certificate Services.&#039;&#039;&#039;&lt;br /&gt;
# Follow the procedure provided to install the &#039;&#039;&#039;Certificate Authority&#039;&#039;&#039;. Enterprise level is a good choice.&lt;br /&gt;
&lt;br /&gt;
Verify that SSL has been enabled on the server by installing suptools.msi from Windows installation cd&#039;s \Support\tools directory. After support tools installation:&lt;br /&gt;
# Select &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Run&#039;&#039;&#039;, write &#039;&#039;&#039;ldp&#039;&#039;&#039; in the Open field.&lt;br /&gt;
# From the ldp window select &#039;&#039;&#039;Connection&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Connect&#039;&#039;&#039; and supply valid hostname and port number &#039;&#039;&#039;636&#039;&#039;&#039;. Also select the SSL check box.&lt;br /&gt;
&lt;br /&gt;
If successful, you should get information about the connection.&lt;br /&gt;
&lt;br /&gt;
Next step is to tell PHP&#039;s OpenLDAP extension to disable SSL certificate checking. On Windows servers you&#039;re most likely using pre-compiled PHP version, where you must create a path &#039;&#039;C:\OpenLDAP\sysconf&#039;&#039;. In this path create a file called &amp;quot;ldap.conf&amp;quot; with content:&lt;br /&gt;
&lt;br /&gt;
 TLS_REQCERT never.&lt;br /&gt;
&lt;br /&gt;
Now you should be able to use &#039;&#039;&#039;ldaps://&#039;&#039;&#039; when connecting to MS-AD.&lt;br /&gt;
&lt;br /&gt;
==Appendices==&lt;br /&gt;
&lt;br /&gt;
===Child Domains and the Global Catalog in MS Active Directory===&lt;br /&gt;
&lt;br /&gt;
Moodle currently only has limited support for multiple domain controllers; specifically it expects each of the LDAP servers listed to contain identical sets of information. If you have users in multiple domains this presents an issue. One solution when working with MS-AD is to use the Global Catalog. The Global Catalog is designed to be a read-only, partial representation of an entire MS-AD forest, designed for searching the entire directory when the domain of the required object is not known.&lt;br /&gt;
&lt;br /&gt;
For example your organisation has a main domain example.org, staff and students are contained in two child domains staff.example.org and students.example.org. The 3 domains (example.org, staff.example.org and students.example.org) each have a domain controller (dc01, dc02 and dc03 respectively.) Each domain controller contains a full, writable, representation of only the objects that belong to its domain. However, assuming that the Global Catalog has been enabled (see below) on one of the domain controllers (for example dc01) a query to the Global Catalog would reveal matching objects from all three domains. The Global Catalog is automatically maintained through replication across the active directory forest, it can also be enabled on multiple servers (if, for example, you need redundancy / load balancing.)&lt;br /&gt;
&lt;br /&gt;
To make use of this in Moodle to allow logins from multiple domains is simple. The Global Catalog runs on port 3268 as opposed to 389 for standard LDAP queries. As a result, still assuming the Global Catalog is running on dc01, the &#039;&#039;&#039;&#039;ldap_host_url&#039;&#039;&#039;&#039; would be &#039;&#039;ldap://dc01.example.org:3268&#039;&#039;. The rest of the settings are the same as for other MS-AS Auth setups.&lt;br /&gt;
&lt;br /&gt;
You should use the &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting to indicate the locations of individuals you wish to grant access. To extend the example above a little: In the example.org domain users are all in the&#039;&#039; &#039;Users&#039; &#039;&#039;OU, in the staff.example.org domain users are in two OUs at the root of the domain,&#039;&#039; &#039;Support Staff&#039; &#039;&#039;and&#039;&#039; &#039;Teaching Staff&#039; &#039;&#039;, and in the students.example.org domain students are in an OU indicating the year that they enrolled, all of which are under the&#039;&#039; &#039;Students&#039; &#039;&#039;OU. As a result our &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting may look a little like this:&#039;&#039; &#039;OU=Users,DC=example,DC=org; OU=Support Staff,DC=staff,DC=example,DC=org; OU=Teaching Staff,DC=staff,DC=example,DC=org; OU=Students,DC=students,DC=example,DC=org&#039;&#039;.&#039; The &#039;&#039;&#039;&#039;ldap_search_sub&#039;&#039;&#039;&#039; option should be set to&#039;&#039; &#039;Yes&#039; &#039;&#039;to allow moodle to search within the child OUs.&lt;br /&gt;
&lt;br /&gt;
Its worth noting that the Global Catalog only contains a partial representation of the attributes of each object, as defined in the Partial Attribute Set supplied by Microsoft. However common information likely to be of use to a general Moodle installation (Forename, Surname, Email Address, sAMAccountName etc) is included in the set. For specific needs the schema can be altered to remove or add various attributes.&lt;br /&gt;
&lt;br /&gt;
In most cases the Global Catalog is read-only, update queries must be made over the standard LDAP ports to the domain controller that holds the object in question (in our example, updating a student&#039;s details would require an LDAP query to the students.example.org domain controller - dc03, it would not be possible to update details by querying the Global Catalog.) The exception to this would be in an environment where there is only a single domain in the active directory forest; in this case the Global Catalog holds a writable full set of attributes for each object in the domain. However, for the purposes of Moodle authorisation, there would be no need to use the Global Catalog in this case.&lt;br /&gt;
&lt;br /&gt;
====Enabling the Global Catalog====&lt;br /&gt;
&lt;br /&gt;
The Global Catalog is available on Windows 2000 and Windows 2003 Active Directory servers. To enable, open the ‘Active Directory Sites and Services’ MMC (Microsoft Management Console) snap-in. Extend ‘Sites’ and then the name of the Site containing the active directory forest you wish to use. Expand the server you wish to enable the Global Catalog on, right click ‘NTDS settings’ and select the ‘Properties’ tab. To enable, simply click the ‘Global Catalog’ checkbox. Under a Windows 2000 server it is necessary to restart the server (although it won’t prompt you to); under Windows 2003 server it is not necessary to restart the server. In either case you will generally have to wait for the AD forest to replicate before the Global Catalog offers a representation of the entire AD forest. Changes made in Active Directory will also be subject to a short delay due to the latency involved with replication. If your AD servers are firewalled port 3268 will need to be opened for Global Catalog servers.&lt;br /&gt;
If your organisation uses Microsoft Exchange then it its highly likely that at least one Domain Controller will already have Global Catalog enabled – Exchange 2000 and 2003 rely on the Global Catalog for address information, users also access the Global Catalog when using the GAL (Global Address List)&lt;br /&gt;
&lt;br /&gt;
====ldap auth_user_create() only suports Novell====&lt;br /&gt;
&lt;br /&gt;
After configuring user authentication with ldap I realized ldap only support edir (Novell) when combining ldap an email user confirmation. For example in my case (I use openldap) I have the following error after filling the user form:&lt;br /&gt;
&lt;br /&gt;
auth: ldap auth_user_create() does not support selected usertype:&amp;quot;rfc2307&amp;quot; (..yet)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion&lt;br /&gt;
* [[LDAP enrolment]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[zh:LDAP认证]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=16999</id>
		<title>LDAP authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=LDAP_authentication&amp;diff=16999"/>
		<updated>2006-10-13T15:30:22Z</updated>

		<summary type="html">&lt;p&gt;RedMorris: Active Directory Troubleshooting Help added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document describes how to set up LDAP authentication in Moodle. You can find a [[#Basic Scenario|Basic Scenario]], where everything is simple and straightforward, and that should be enough for most installations. If your installation is a little bigger and you are using multiple LDAP servers, or multiple locations (contexts) for your users in your LDAP tree, then have a look at the [[#Advanced Scenarios|Advanced Scenarios]].&lt;br /&gt;
&lt;br /&gt;
==Basic Scenario==&lt;br /&gt;
&lt;br /&gt;
===Assumptions===&lt;br /&gt;
&lt;br /&gt;
# Your Moodle site is located at &#039;&#039;&#039;http://your.moodle.site/&#039;&#039;&#039;&lt;br /&gt;
# You have configured your PHP installation with the LDAP extension. It is loaded and activated, and it shows when you go to &#039;&#039;&#039;http://your.moodle.site/admin/phpinfo.php&#039;&#039;&#039; (logged in as user &#039;admin&#039;).&lt;br /&gt;
# Your LDAP server has &#039;&#039;&#039;192.168.1.100&#039;&#039;&#039; as its IP address.&lt;br /&gt;
# You are not using LDAP with SSL (also known as LDAPS) in your settings. This might prevent certain operations from working (e.g., you cannot update data if you are using MS Active Directory -- MS-AD from here on --), but should be OK if you just want to authenticate your users.&lt;br /&gt;
# You don&#039;t want your users to change their passwords the first time they log in into Moodle.&lt;br /&gt;
# You are using a single domain as the source of your authentication data in case you are using MS-AD (more on this in the Appendices).&lt;br /&gt;
# You are using a top level distinguished name (DN) of &#039;&#039;&#039;dc=my,dc=organization,dc=domain&#039;&#039;&#039; as the root of your LDAP tree. &lt;br /&gt;
# You have a non-privileged LDAP user account you will use to bind to the LDAP server. This is not necessary with certain LDAP servers, but MS-AD requires this and it won&#039;t hurt if you use it even if your LDAP server doesn&#039;t need it. Make sure &#039;&#039;&#039;this account and its password don&#039;t expire&#039;&#039;&#039;, and make this password as strong as possible. Remember you only need to type this password once, when configuring Moodle, so don&#039;t be afraid of making it as hard to guess as possible. Let&#039;s say this user account has a DN of &#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;, and password &#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;.&lt;br /&gt;
# All of your Moodle users are in an organizational unit (OU) called &#039;&#039;&#039;moodleusers&#039;&#039;&#039;, which is right under your LDAP root. That OU has a DN of &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039;.&lt;br /&gt;
# You &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want your LDAP users&#039; passwords to be stored in Moodle at all.&lt;br /&gt;
&lt;br /&gt;
===Configuring Moodle authentication===&lt;br /&gt;
&lt;br /&gt;
Log in as an admin user and go to Administration &amp;gt;&amp;gt; Users &amp;gt;&amp;gt; Authentication. In the drop down listbox titled  &amp;quot;Choose an authentication method&amp;quot; select &amp;quot;Use an LDAP Server&amp;quot;. You will get a page similar to this one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
::: [[Image:auth_ldap_config_screenshot.jpg]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, you just have to fill in the values. Let&#039;s go step by step.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
! Field name&lt;br /&gt;
! Value to fill in&lt;br /&gt;
|-&lt;br /&gt;
| ldap_host_url&lt;br /&gt;
| As the IP of your LDAP server is 192.168.1.100, type &amp;quot;&#039;&#039;&#039;ldap://192.168.1.100&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_version&lt;br /&gt;
| Unless you are using a really old LDAP server, &#039;&#039;&#039;version 3&#039;&#039;&#039; is the one you should choose.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_preventpassindb&lt;br /&gt;
| As you &#039;&#039;&#039;don&#039;t&#039;&#039;&#039; want to store the users&#039;s password in Moodle&#039;s database, choose &#039;&#039;&#039;Yes&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_dn&lt;br /&gt;
| This is the distinguished name of the bind user defined above. Just type &amp;quot;&#039;&#039;&#039;cn=ldap-user,dc=my,dc=organization,dc=domain&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_bind_pw&lt;br /&gt;
| This is the bind user password defined above. Type &amp;quot;&#039;&#039;&#039;hardtoguesspassword&#039;&#039;&#039;&amp;quot; (without the quotes).&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_type&lt;br /&gt;
| Choose: &lt;br /&gt;
* &#039;&#039;&#039;Novel Edirectory&#039;&#039;&#039; if your LDAP server is running Novell&#039;s eDdirectory.&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307)&#039;&#039;&#039; if your LDAP server is running a RFC-2307 compatible LDAP server (choose this is your server is running OpenLDAP).&lt;br /&gt;
* &#039;&#039;&#039;posixAccount (rfc2307bis)&#039;&#039;&#039; if your LDAP server is running a RFC-2307bis compatible LDAP server.&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount (v.3.0.7)&#039;&#039;&#039; if your LDAP server is running with SAMBA&#039;s 3.x LDAP schema extension and you want to use it.&lt;br /&gt;
* &#039;&#039;&#039;MS ActiveDirectory&#039;&#039;&#039; if your LDAP server is running Microsoft&#039;s Active Directory (MS-AD)&lt;br /&gt;
|-&lt;br /&gt;
| ldap_contexts&lt;br /&gt;
| The DN of the context (container) where all of your Moodle users are found. Type &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_search_sub&lt;br /&gt;
| If you have any sub organizational units (subcontexts) hanging from &#039;&#039;&#039;ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; and you want Moodle to search there too, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. Otherwise, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_opt_deref&lt;br /&gt;
| Sometimes your LDAP server will tell you that the real value you are searching for is in fact in another part of the LDAP tree (this is called an alias). If you want Moodle to &#039;dereference&#039; the alias and fetch the real value from the original location, set this to &#039;&#039;&#039;yes&#039;&#039;&#039;. If you don&#039;t want Moodle to dereference it, set this to &#039;&#039;&#039;no&#039;&#039;&#039;. If you are using MS-AD, set this to &#039;&#039;&#039;no&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_user_attribute&lt;br /&gt;
| The attribute used to name/search users in your LDAP tree. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in&amp;lt;/u&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
By the way, it&#039;s usually &#039;&#039;&#039;cn&#039;&#039;&#039; (Novell eDirectory and MS-AD) or &#039;&#039;&#039;uid&#039;&#039;&#039; (RFC-2037, RFC-2037bis and SAMBA 3.x LDAP extension), but if you are using MS-AD you could use &#039;&#039;&#039;sAMAccountName&#039;&#039;&#039; (the pre-Windows 2000 logon account name) if you need too.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_memberattribute&lt;br /&gt;
| The attribute used to list the members of a given group. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By the way, the usual values are &#039;&#039;&#039;member&#039;&#039;&#039; and &#039;&#039;&#039;memberUid&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_objectclass&lt;br /&gt;
| The type of LDAP object used to search for users. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the default values for each of the &#039;&#039;ldap_user_type&#039;&#039; values:&lt;br /&gt;
* &#039;&#039;&#039;User&#039;&#039;&#039; for Novel eDirectory&lt;br /&gt;
* &#039;&#039;&#039;posixAccount&#039;&#039;&#039; for RFC-2037 and RFC-2037bis&lt;br /&gt;
* &#039;&#039;&#039;sambaSamAccount&#039;&#039;&#039; for SAMBA 3.0.x LDAP extension&lt;br /&gt;
* &#039;&#039;&#039;user&#039;&#039;&#039; for MS-AD&lt;br /&gt;
|-&lt;br /&gt;
| Force change password&lt;br /&gt;
| Set this to &#039;&#039;Yes&#039;&#039; if you want to force your users to change their password on the first login into Moodle. Otherwise, set this to &#039;&#039;no&#039;&#039;. Bear in mind the password they are forced to change is the one stored in your LDAP server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;As you don&#039;t want your users to change their passwords in their first login, leave this set to &#039;&#039;No&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Use standard Change Password Page&lt;br /&gt;
|&lt;br /&gt;
* Setting this to &#039;&#039;Yes&#039;&#039; makes Moodle use it&#039;s own standard password change page, everytime users want to change their passwords.&lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; makes Moodle use the the page specified in the field called &amp;quot;Change password URL&amp;quot; (at the bottom of the configuration page).&lt;br /&gt;
&lt;br /&gt;
Bear in mind that changing your LDAP passwords from Moodle might require a LDAPS connection (this is true at least for MS-AD).&lt;br /&gt;
&lt;br /&gt;
Also, code for changing passwords from Moodle for anything but Novell eDirectory is almost not tested, so this may or may not work for other LDAP servers.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration&lt;br /&gt;
| &lt;br /&gt;
* Setting this to &#039;&#039;No&#039;&#039; will make Moodle not to check if the password of the user has expired or not.&lt;br /&gt;
* Setting this to &#039;&#039;LDAP&#039;&#039; will make Moodle check if the LDAP password of the user has expired or not, and warn her a number of days before the password expires.&lt;br /&gt;
&lt;br /&gt;
Current code only deals with Novell eDirectory LDAP server, but there is a patch floating around to make it work with MS-AD too (search in the authentication forum).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server (or use the patch), choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_expiration_warning&lt;br /&gt;
| This value sets how many days in advance of password expiration the user is warned that her password is about to expire.&lt;br /&gt;
|-&lt;br /&gt;
| ldap_exprireattr&lt;br /&gt;
| The LDAP user attribute used to check password expiration. This option takes a default value based on the &#039;&#039;ldap_user_type&#039;&#039; value you choosed above. &amp;lt;u&amp;gt;So unless you need something special, you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_gracelogins&lt;br /&gt;
| This setting is specific to Novell eDirectory. If set to &#039;&#039;Yes&#039;&#039;, enable LDAP gracelogin support. After password has expired the user can login until gracelogin count is 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So unless you have Novell eDirectory server and want to allow gracelogin support, choose &#039;&#039;No&#039;&#039; here.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_graceattr&lt;br /&gt;
| This setting is currently not used in the code (and is specific to Novell eDirectory). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;So you don&#039;t need to fill this in.&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ldap_create_context&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| ldap_creators&lt;br /&gt;
| The DN of the group that contains all of your Moodle creators. This is typically a posixGroup with a &amp;quot;memberUid&amp;quot; attribute for each user you want to be a creator.  If your group is called &#039;&#039;creators&#039;&#039;, type &#039;&#039;&#039;cn=creators,ou=moodleusers,dc=my,dc=organization,dc=domain&#039;&#039;&#039; here.  Each memberUid attribute contains the CN of a user who is authorized to be a creator.  Do not use the user&#039;s full DN (e.g.,  not &#039;&#039;&#039;memberUid: cn=JoeTeacher,ou=moodleusers,dc-my,dc=organizations,dc=domain&#039;&#039;&#039;, but rather &#039;&#039;&#039;memberUid: JoeTeacher&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
In eDirectory, the objectClass for a group is (by default) not &#039;&#039;&#039;posixGroup&#039;&#039;&#039; but &#039;&#039;&#039;groupOfNames,&#039;&#039;&#039; whose member attribute is &#039;&#039;&#039;member,&#039;&#039;&#039; not &#039;&#039;&#039;memberUid,&#039;&#039;&#039; and whose value is the full DN of the user in question.  Although you can probably modify Moodle&#039;s code to use this field, a better solution is just to add a new &#039;&#039;&#039;objectClass&#039;&#039;&#039; attribute of &#039;&#039;&#039;posixGroup&#039;&#039;&#039; to your creators group and put the CNs for each creator in a &#039;&#039;&#039;memberUid&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
In MS Active Directory, you will need to create a security group for your creators to be part of and then add them all. If your ldap context above is &#039;ou=staff,dc=my,dc=org&#039; then your group should then be &#039;cn=creators,ou=staff,dc=my,dc=org&#039;. If some of the users are from other contexts and have been added to the same security group, you&#039;ll have to add these as separate contexts after the first one using the same format.&lt;br /&gt;
|-&lt;br /&gt;
| First name&lt;br /&gt;
| The name of the attribute that holds the first name of your users in your LDAP server. This is usually &#039;&#039;&#039;givenName&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Surname&lt;br /&gt;
| The name of the attribute that holds the surname of your users in your LDAP server. This is usually &#039;&#039;&#039;sn&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Email address&lt;br /&gt;
| The name of the attribute that holds the email address of your users in your LDAP server. This is usually &#039;&#039;&#039;mail&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 1&lt;br /&gt;
| The name of the attribute that holds the telephone number of your users in your LDAP server. This is usually &#039;&#039;&#039;telephoneNumber&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Phone 2&lt;br /&gt;
|  The name of the attribute that holds an additional telephone number of your users in your LDAP server. This can be &#039;&#039;&#039;homePhone&#039;&#039;&#039;, &#039;&#039;&#039;mobile&#039;&#039;&#039;, &#039;&#039;&#039;pager&#039;&#039;&#039;, &#039;&#039;&#039;facsimileTelephoneNumber&#039;&#039;&#039; or even others.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Department&lt;br /&gt;
| The name of the attribute that holds the department name of your users in your LDAP server. This is usully &#039;&#039;&#039;departmentNumber&#039;&#039;&#039; (for posixAccount and maybe eDirectory) or &#039;&#039;&#039;department&#039;&#039;&#039; (for MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Address&lt;br /&gt;
| The name of the attribute that holds the street address of your users in your LDAP server. This is usully &#039;&#039;&#039;streetAddress&#039;&#039;&#039; or &#039;&#039;&#039;street&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| City/town&lt;br /&gt;
| The name of the attribute that holds the city/town of your users in your LDAP server. This is usully &#039;&#039;&#039;l&#039;&#039;&#039; (lowercase L) or &#039;&#039;&#039;localityName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| Country&lt;br /&gt;
| The name of the attribute that holds the couuntry of your users in your LDAP server. This is usully &#039;&#039;&#039;c&#039;&#039;&#039; or &#039;&#039;&#039;countryName&#039;&#039;&#039; (not valid in MS-AD).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Description&lt;br /&gt;
| &#039;&#039;&#039;description&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| ID Number&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Language&lt;br /&gt;
| &#039;&#039;&#039;preferredLanguage&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;This setting is optional&amp;lt;/u&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Instructions&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the fields are common to all authentication methods and will not be discussed here.&lt;br /&gt;
&lt;br /&gt;
==Active Directory Troubleshooting Help==&lt;br /&gt;
&lt;br /&gt;
===Warning: The PHP LDAP module does not seem to be present. Please ensure it is installed and enabled.===&lt;br /&gt;
This usually means that the main ldap dll or one of the supporting dlls are missing.&lt;br /&gt;
Let&#039;s start with the main one itself. &lt;br /&gt;
Use the &amp;quot;Configuration File (php.ini) Path&amp;quot; field on http://s-moodle1/admin/phpinfo.php to determine which php.ini is being used and open it. Find the line &#039;extension=php_ldap.dll&#039; and take out the semi-colon if it is there. That semi-colon will stop it loading the module all together! &lt;br /&gt;
While you have that file open, search for &#039;extension_dir&#039; and note which folder it is set to. Open that folder and ensure the php_ldap.dll file is in there. If it isn&#039;t then put it in there.&lt;br /&gt;
If that still hasn&#039;t fixed it you are missing a supporting dll, but you don&#039;t get told that. To see what dlls are missing open the Command Propmt and navigate to the php directory and execute the following line &#039;php -m&#039;. You should get some error messages now. Ugly, but at least they give you information! Find the dlls listed and copy them to the php directory. Run &#039;php -m&#039; again and you should be error free and the message in Moodle should be gone now.&lt;br /&gt;
&lt;br /&gt;
===LDAP-module cannot connect any LDAP servers : Server: &#039;ldap://my.ldap.server/&#039; Connection: &#039;Resource id #26&#039; Bind result: &#039;&#039;===&lt;br /&gt;
Getting this message when you are trying to log in is a result of incorrect details for the Bind user, or the user account having insufficient permissions in Active Directory. The best way to test and resolve this is use ldp.exe to test binding until it suceeds. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open the program and Connect to AD, giving the server name, then from the Connection menu choose Bind. Enter the details you think are correct and you will probably find that an error is returned. Try adjusting the accounts priveleges or another account until you are returned an &amp;quot;Authenticated as&amp;quot; message.&lt;br /&gt;
Once you are sure your account can be used to bind to AD, check that the DN of that users name is correct. Expand the tree on the left until you find the user you used to bind. Right click on that item and choose Copy DN. Go to the User Authentication page in Moodle and paste the value into the ldap_bind_dn field. Add the password and you can now feel safe your user is binding sucessfully.&lt;br /&gt;
&lt;br /&gt;
===Getting correct CNs for Contexts and Creators===&lt;br /&gt;
For those not familiar with AD this could be very confusing, and not that easy for some who are familiar with it. Again, ldp.exe is your friend. There are instructions on installing ldp.exe below.&lt;br /&gt;
Open it up and expand the tree on the left until you find the group or user you want to use and right click on it and select Copy DN. Go back to the Moodle User Authentication page and paste that value into either ldap_contexts or ldap_creators.&lt;br /&gt;
&lt;br /&gt;
===Getting the right user_attribute===&lt;br /&gt;
By default, Moodle uses an accounts cn (full name) to verify against, but most networks don&#039;t use a full given name for logon as it&#039;s too easy to guess and you can easily have two people with the same name. If this is the case for you too you need to tell Moodle to look at another field for the logon id.&lt;br /&gt;
In ldp.exe navigate the tree on the left to find a user account, preferably your own. Double-click the item in the tree and full-details will be loaded into the screen on the right. Look down the details until you find your logon id and note the item listed against it. For me, and a lot of people, it is sAMAccountName. Copy this name and paste it into the ldap_user_attribute on the Moodle User Authentication page.&lt;br /&gt;
There are instructions on installing ldp.exe below.&lt;br /&gt;
&lt;br /&gt;
===Installing ldap.exe Server Tool===&lt;br /&gt;
ldp.exe comes as part of the Server Tools on most versions of Windows Server. Find your Windows Server installation disc and find a folder on it called Support\Tools. In there will be a SupTools.msi which will install the server tools if run. You should now have a folder under Program Files called Support Tools, in which will be ldp.exe&lt;br /&gt;
&lt;br /&gt;
==Advanced Scenarios==&lt;br /&gt;
&lt;br /&gt;
===Using multiple LDAP Servers===&lt;br /&gt;
Entering more than one name in the ldap_host_url field can provide some sort of resilience to your system. Simply use the syntax :&lt;br /&gt;
ldap://my.first.server ; ldap://my.second.server ; ...&lt;br /&gt;
&lt;br /&gt;
Of course, this will only work if all the servers share the same directory information, using a replication or synchronization mecanism once introduced in eDirectory and now generalized to the main LDAP-compatible directories.&lt;br /&gt;
&lt;br /&gt;
There is one drawback in Moodle 1.5 - 1.6 implementation of LDAP authentication : the auth_ldap_connect() function processes the servers sequentially, not in a round robin mode. Thus, if the primary server fails, you will have to wait for the connection to time out before switching to the following one.&lt;br /&gt;
&lt;br /&gt;
===Using multiple user locations (contexts) in your LDAP tree===&lt;br /&gt;
There is no need to use multiple user locations if your directory tree is flat, i.e. if all user accounts reside in a &#039;&#039;&#039;ou=people,dc=my,dc=organization,dc=domain&#039;&#039;&#039; or &#039;&#039;&#039;ou=people,o=myorg&#039;&#039;&#039; container. &lt;br /&gt;
&lt;br /&gt;
At the opposite, if you use the ACL mecanism to delegate user management, there are chances that your users will be stored in containers like &#039;&#039;&#039;ou=students,ou=dept1,o=myorg&#039;&#039;&#039; and &#039;&#039;&#039;ou=students,ou=dept2,o=myorg&#039;&#039;&#039; ...&lt;br /&gt;
&lt;br /&gt;
Then there is an alternative :&lt;br /&gt;
* Look at the &#039;&#039;&#039;o=myorg&#039;&#039;&#039; level with the ldap_search_sub attribute set to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
* Set the ldap_context to &#039;&#039;&#039;ou=students,ou=dept1,o=myorg ; ou=students,ou=dept2,o=myorg&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Choosing between these two solutions supposes some sort of benchmarking, as the result depends heavily on the structure of your directory tree &#039;&#039;&#039;and&#039;&#039;&#039; on your LDAP software indexing capabilities. Simply note that there is a probability in such deep trees that two users share the same &#039;&#039;common name&#039;&#039; (cn), while having different &#039;&#039;distinguished names&#039;&#039;. Then only the second solution will have a deterministic result (returning allways the same user).&lt;br /&gt;
&lt;br /&gt;
===Using LDAPS (LDAP + SSL)===&lt;br /&gt;
====MS Active Directory + SSL ====&lt;br /&gt;
&lt;br /&gt;
If the Certificate Authority is not installed you&#039;ll have to install it first as follows:&lt;br /&gt;
# Click &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Control Panel&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Add or Remove programs.&#039;&#039;&#039;&lt;br /&gt;
# Click &#039;&#039;&#039;Add/Remove Windows Components&#039;&#039;&#039; and select &#039;&#039;&#039;Certificate Services.&#039;&#039;&#039;&lt;br /&gt;
# Follow the procedure provided to install the &#039;&#039;&#039;Certificate Authority&#039;&#039;&#039;. Enterprise level is a good choice.&lt;br /&gt;
&lt;br /&gt;
Verify that SSL has been enabled on the server by installing suptools.msi from Windows installation cd&#039;s \Support\tools directory. After support tools installation:&lt;br /&gt;
# Select &#039;&#039;&#039;Start&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Run&#039;&#039;&#039;, write &#039;&#039;&#039;ldp&#039;&#039;&#039; in the Open field.&lt;br /&gt;
# From the ldp window select &#039;&#039;&#039;Connection&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Connect&#039;&#039;&#039; and supply valid hostname and port number &#039;&#039;&#039;636&#039;&#039;&#039;. Also select the SSL check box.&lt;br /&gt;
&lt;br /&gt;
If successful, you should get information about the connection.&lt;br /&gt;
&lt;br /&gt;
Next step is to tell PHP&#039;s OpenLDAP extension to disable SSL certificate checking. On Windows servers you&#039;re most likely using pre-compiled PHP version, where you must create a path &#039;&#039;C:\OpenLDAP\sysconf&#039;&#039;. In this path create a file called &amp;quot;ldap.conf&amp;quot; with content:&lt;br /&gt;
&lt;br /&gt;
 TLS_REQCERT never.&lt;br /&gt;
&lt;br /&gt;
Now you should be able to use &#039;&#039;&#039;ldaps://&#039;&#039;&#039; when connecting to MS-AD.&lt;br /&gt;
&lt;br /&gt;
==Appendices==&lt;br /&gt;
&lt;br /&gt;
===Child Domains and the Global Catalog in MS Active Directory===&lt;br /&gt;
&lt;br /&gt;
Moodle currently only has limited support for multiple domain controllers; specifically it expects each of the LDAP servers listed to contain identical sets of information. If you have users in multiple domains this presents an issue. One solution when working with MS-AD is to use the Global Catalog. The Global Catalog is designed to be a read-only, partial representation of an entire MS-AD forest, designed for searching the entire directory when the domain of the required object is not known.&lt;br /&gt;
&lt;br /&gt;
For example your organisation has a main domain example.org, staff and students are contained in two child domains staff.example.org and students.example.org. The 3 domains (example.org, staff.example.org and students.example.org) each have a domain controller (dc01, dc02 and dc03 respectively.) Each domain controller contains a full, writable, representation of only the objects that belong to its domain. However, assuming that the Global Catalog has been enabled (see below) on one of the domain controllers (for example dc01) a query to the Global Catalog would reveal matching objects from all three domains. The Global Catalog is automatically maintained through replication across the active directory forest, it can also be enabled on multiple servers (if, for example, you need redundancy / load balancing.)&lt;br /&gt;
&lt;br /&gt;
To make use of this in Moodle to allow logins from multiple domains is simple. The Global Catalog runs on port 3268 as opposed to 389 for standard LDAP queries. As a result, still assuming the Global Catalog is running on dc01, the &#039;&#039;&#039;&#039;ldap_host_url&#039;&#039;&#039;&#039; would be &#039;&#039;ldap://dc01.example.org:3268&#039;&#039;. The rest of the settings are the same as for other MS-AS Auth setups.&lt;br /&gt;
&lt;br /&gt;
You should use the &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting to indicate the locations of individuals you wish to grant access. To extend the example above a little: In the example.org domain users are all in the&#039;&#039; &#039;Users&#039; &#039;&#039;OU, in the staff.example.org domain users are in two OUs at the root of the domain,&#039;&#039; &#039;Support Staff&#039; &#039;&#039;and&#039;&#039; &#039;Teaching Staff&#039; &#039;&#039;, and in the students.example.org domain students are in an OU indicating the year that they enrolled, all of which are under the&#039;&#039; &#039;Students&#039; &#039;&#039;OU. As a result our &#039;&#039;&#039;&#039;ldap_contexts&#039;&#039;&#039;&#039; setting may look a little like this:&#039;&#039; &#039;OU=Users,DC=example,DC=org; OU=Support Staff,DC=staff,DC=example,DC=org; OU=Teaching Staff,DC=staff,DC=example,DC=org; OU=Students,DC=students,DC=example,DC=org&#039;&#039;.&#039; The &#039;&#039;&#039;&#039;ldap_search_sub&#039;&#039;&#039;&#039; option should be set to&#039;&#039; &#039;Yes&#039; &#039;&#039;to allow moodle to search within the child OUs.&lt;br /&gt;
&lt;br /&gt;
Its worth noting that the Global Catalog only contains a partial representation of the attributes of each object, as defined in the Partial Attribute Set supplied by Microsoft. However common information likely to be of use to a general Moodle installation (Forename, Surname, Email Address, sAMAccountName etc) is included in the set. For specific needs the schema can be altered to remove or add various attributes.&lt;br /&gt;
&lt;br /&gt;
In most cases the Global Catalog is read-only, update queries must be made over the standard LDAP ports to the domain controller that holds the object in question (in our example, updating a student&#039;s details would require an LDAP query to the students.example.org domain controller - dc03, it would not be possible to update details by querying the Global Catalog.) The exception to this would be in an environment where there is only a single domain in the active directory forest; in this case the Global Catalog holds a writable full set of attributes for each object in the domain. However, for the purposes of Moodle authorisation, there would be no need to use the Global Catalog in this case.&lt;br /&gt;
&lt;br /&gt;
====Enabling the Global Catalog====&lt;br /&gt;
&lt;br /&gt;
The Global Catalog is available on Windows 2000 and Windows 2003 Active Directory servers. To enable, open the ‘Active Directory Sites and Services’ MMC (Microsoft Management Console) snap-in. Extend ‘Sites’ and then the name of the Site containing the active directory forest you wish to use. Expand the server you wish to enable the Global Catalog on, right click ‘NTDS settings’ and select the ‘Properties’ tab. To enable, simply click the ‘Global Catalog’ checkbox. Under a Windows 2000 server it is necessary to restart the server (although it won’t prompt you to); under Windows 2003 server it is not necessary to restart the server. In either case you will generally have to wait for the AD forest to replicate before the Global Catalog offers a representation of the entire AD forest. Changes made in Active Directory will also be subject to a short delay due to the latency involved with replication. If your AD servers are firewalled port 3268 will need to be opened for Global Catalog servers.&lt;br /&gt;
If your organisation uses Microsoft Exchange then it its highly likely that at least one Domain Controller will already have Global Catalog enabled – Exchange 2000 and 2003 rely on the Global Catalog for address information, users also access the Global Catalog when using the GAL (Global Address List)&lt;br /&gt;
&lt;br /&gt;
====ldap auth_user_create() only suports Novell====&lt;br /&gt;
&lt;br /&gt;
After configuring user authentication with ldap I realized ldap only support edir (Novell) when combining ldap an email user confirmation. For example in my case (I use openldap) I have the following error after filling the user form:&lt;br /&gt;
&lt;br /&gt;
auth: ldap auth_user_create() does not support selected usertype:&amp;quot;rfc2307&amp;quot; (..yet)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=32168 PHP LDAP module does not seem to be present] forum discussion&lt;br /&gt;
* [[LDAP enrolment]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[zh:LDAP认证]]&lt;/div&gt;</summary>
		<author><name>RedMorris</name></author>
	</entry>
</feed>