How to use multiple LDAP servers with Moodle 1.8

How to use multiple LDAP servers with Moodle 1.8

by Paul F -
Number of replies: 226
Moodle's LDAP authentication is great, however it would be better if we could use multiple LDAP systems for authentication.

I have seen several posts from people using Active Directory in an educational environment with for example, separate Active Directory domains for staff and students. There are ways to talk to multiple LDAP servers if you have an Active Directory forest and are talking to an appropriate Global Catalogue server, however what if you have domains that are not in a forest and what if you have some other LDAP system that you would also like to authenticate against - for example, say you have a student Active Directory domain that is not in a forest with a staff Active Directory domain, and what if you also have another LDAP server such as Apple's OSX OpenDirectory or Linux OpenLDAP or Novell eDirectory?

The good news is you can use as many as you like - my solution to this problem is quite simple - duplicate the LDAP plugin and make some small changes - here's how to do it (using Moodle 1.8):

*DISCLAIMER* I accept no responsibility for anything that may go wrong with your system as a result of this procedure. I suggest taking a backup of your system and database first just in case.
  • Backup ANY files before making changes. Better safe than sorry, however we are not going to be changing anything old, just adding something new.
  • Find the 'ldap' folder in html/auth/
  • Make a copy of the folder, and call it something different - e.g. ldap2
  • Note that by doing this step the admin will not be able to get into the authentication page of Moodle until the changes below are applied (they will get a blank page). If you panic, simply delete the new folder (i.e. ldap2) and all will return to normal.
  • Look in the newly created ldap2 folder and edit the file auth.php
  • Change the following lines:
Line 24: class auth_plugin_ldap extends auth_plugin_base {

to

class auth_plugin_ldap2 extends auth_plugin_base {
...note we are simply adding a '2' on the end of the class name.

Line 29: function auth_plugin_ldap() {
To: function auth_plugin_ldap2() {
...note again simply adding a '2'.

Line 31: $this->config = get_config('auth/ldap');
$this->config = get_config('auth/ldap2');
...again with the '2'.

Then jump to line 1654 and change all of the auth/ldap lines to have a '2' on the end - e.g.

// save settings
set_config('host_url', $config->host_url, 'auth/ldap2');
set_config('ldapencoding', $config->ldapencoding, 'auth/ldap2');
set_config('host_url', $config->host_url, 'auth/ldap2');
...
...(lots of lines)
...
set_config('removeuser', $config->removeuser, 'auth/ldap2');
  • Save the file
  • In Moodle 'Users/authentication' if you refresh the page, you will now see another LDAP module (mine is auth_ldap2title at the moment as I've not working out how to change the title yet but this appears to be purely cosmetic).
  • Configure the settings for your additional LDAP server.
  • Click the 'eye' to turn the module on.
  • Test a login from both LDAP servers.
In theory you should be able to repeat this procedure for as many LDAP servers as you need, and you should be able to mix and match systems and vendors - obviously use different names for any you add - e.g. we have simply put a '2' on the end in this example - in the next one use '3', the one after that '4' etc. (or anything you want - it shouldn't matter so long as it's unique).

Hope this is useful!

Average of ratings: -
In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by Chris Lamb -

An interesting fix, thanks!

To solve your auth_ldap2title problem you need a new file in your language pack - if you copy your existing auth language file, eg yourmoodle\lang\en\auth.php, and call it auth2.php, that should solve your problem.

A couple of questions about this - do I take it that this still only allows each Moodle installation to connect to one domain's LDAP, you just get the choice of which one, or will a Moodle now try validating against each domain for which there's an auth2, auth3 etc file?  In other words, if I put this fix into one of my Moodles will I just get the choice of which domain to authenticate against, eg staff or student, or will that Moodle then check both domains to try and authenticate?

Do you know if this will work on 1.7 and earlier?

In reply to Chris Lamb

Re: How to use multiple LDAP servers with Moodle 1.8

by Paul F -
Ahh thankyou for pointing me in the right direction - I have added the following lines to lang\en_utf8\auth.php which works:

// Secondary LDAP plugin (PF20070620)
$string['auth_ldap2title'] = 'LDAP server';
$string['auth_ldap2description'] = 'This method provides authentication against an external LDAP server.

If the given username and password are valid, Moodle creates a new user

entry in its database. This module can read user attributes from LDAP and prefill

wanted fields in Moodle. For following logins only the username and

password are checked.';
//
Everything else uses the same variable names as the main LDAP plugin, so no problems there.

In answer to your question - Moodle will try to authenticate supplied credentials on all 'enabled' modules (i.e. the 'eye' is open in the list), in the order that you have set. For example, ours here now will check an account against the first LDAP server in the list, and if that fails will try the next authentication system in the list, which in my case happens to also be an LDAP server module, pointing at a different LDAP server. Users with accounts on either server can log in (there may be a problem with users with the same username on all servers and different passwords but I've not tested that yet). I could keep adding servers in this way and it would simply try them all in order.

...not sure if it will work on 1.7 and earlier - I guess if it has a modular authentication system like 1.8, then it should be a similar procedure as all we are doing is basically providing Moodle with an extra authentication module for it to try to authenticate users with.

I think it might be an idea for Moodle to ship with maybe three LDAP modules by default as I think that would cover most users.
In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by Hans Hofman -

Thanx for the help.

Its not totally correct 2 things:

help file: edited the auth.php and not a copy of auth.php since the file name is auth.php so it looks at the auth.php in the help file.

When you want to change the settings in the

Cron synchronization script

Refers to the first ldap server settings and not to the second ldap server settings. Files are correctly saved but not correctly read.

Hans

In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by Charlie Owen -
I've been meaning to post this for ages, but here's what our developer hacked together to get Moodle authenticating against two AD servers in different forests. It's similar to what you've done and might help those who are developing the Moodle authentication code. Sorry if some of it isn't too clear - the guy who wrote this isn't around any more to ask!



So, ripped straight from our internal documentation wiki: (all the nulc references are to our organisation: Newcastle-under-Lyme College).

Moodle LDAP Authentication

In order to authenticate against multiple AD domains (such as different Student and Staff domains), several functions had to be rewritten.

This page details the changes that were made to the Moodle 1.7 line in order to allow it to authenticate against multiple AD domains. This code will not work unmodified on other versions of Moodle, as authentication functions seem to change with each point release.

Database modifications

It is not necessary to perform major database changes for this modification. In the mdl_config table, all records with ldap in the name must be duplicated and modified to read ldapad2. These config entries are follows:

  • ldapad2_expiration = 0
  • auth_ldapad2_stdchangepassword = 0
  • auth_ldapad2_forcechangepassword = 0
  • ldapad2_objectclass = objectClass=*
  • ldapad2_memberattribute =
  • ldapad2_user_attribute = sAMAccountName
  • ldapad2_opt_deref = 0
  • ldapad2_search_sub = 1
  • ldapad2_contexts = ourcontextsgohere
  • ldapad2_user_type = ad
  • ldapad2_bind_pw = ourbindpassword
  • ldapad2_bind_dn = ourbinduser
  • ldapad2_preventpassindb = 1
  • ldapad2_version = 3
  • ldapad2_host_url = ourhosturls
  • ldapad2_expiration_warning = 10
  • ldapad2_expireattr =
  • ldapad2_gracelogins = 0
  • ldapad2_graceattr =
  • ldapad2_create_context =
  • ldapad2_creators =
  • auth_ldapad2_changepasswordurl =
  • auth_ldapad2_changepasswordhelp =

LDAP Authentication library

  • Copy auth/ldap directory to auth/ldapad2
  • Edit auth/ldapad2/lib.php and replace all instances of $CFG->ldap with $CFG->ldapad2
  • Edit auth/ldapad2/config.html and replace instances of ldap with ldapad2 except in print_string or get_string functions except line 356: $help .= get_string("auth_updateremote_ldapad2","auth");

Modified Moodle Functions

  • See attached file. It goes in: lib/moodlelib-nulc.php
  • In file lib/setup.php line 192 (add):
 require_once($CFG->libdir .'/moodlelib-nulc.php'); // NULC Specific modifications 
  • In file login/index.php change line 120 to:
 $user = authenticate_user_login_nulc($frm->username, $frm->password, $frm->authtype); 

Custom Login Page

Any custom login page must include either a select box or radio buttons which must pass the chosen authentication method (ldap, ldapad2, internal) in the variable authtype.

In reply to Charlie Owen

Re: How to use multiple LDAP servers with Moodle 1.8

by William Rice -

We're working on authenticating against multiple LDAP sources at our institution, using version 1.9.8. When we try to authenticate as a user who is in one of the sources, we get this debug code:

Warning: ldap_search(): Search: Partial results and referral received in /srv/www/htdocs/auth/ldapalt2/auth.php on line 1683 Warning: ldap_first_entry(): supplied argument is not a valid ldap result resource in /srv/www/htdocs/auth/ldapalt2/auth.php on line 1691

Does anyone have any insight into what would cause this?

In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by Steven XXX -
Hi Paul Fitzgibbon,

I done for your instruction, but ldap2 not work.
I using moodle 1.9.3. Please help me to resolve it.

Thanks a lot.
In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Christoph Ackermann -

Hello,

has anyone tried this modification with moodle 2.0?
I had it running with moodle 1.9.9 for multiple domains (from multiple forests). It also worked nicely with SSO.

It seems that in moodle 2.0 the auth.php has changed quite a bit.
I am still able to manually login from different domains.
But there are two other problems:
1.) the single-sign-on works only for the original ldap, not for ldap2.
2.) the pluginname (and the other variables) can not be defined separatly for each ldap-module

The variables for names and other strings are not in the moodle/lang-folder anymore, but directly in moodle/auth/ldap/lang/en/auth_ldap.php.
It seems to be referenced by the $this->authtype variable. Unfortunately this also seems to have influence on other parts of the code.
I was able to use the variables of that file, but then there were other problems regarding the login. So I think it's not safe to change $this->authtype from "ldap" to "ldap2" for example.


Any help would be greatly appreciated.
Thanks in advance!

Christoph

In reply to Christoph Ackermann

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

I recently created a patch for 2.0 to be able to do this. The attached zip file contains three files:

  • 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch
  • ldapname.php
  • ldapname.diff

You need to unzip them in the root directory of your Moodle install. Then you have to apply the patch from the first file (0001-Add....) (see http://docs.moodle.org/en/Development:How_to_apply_a_patch if you don't know how to apply a patch). The patch should apply cleanly to Moodle 2.0.x current as of today.

Then you need to execute the second file using the command line php executable:

php -f ldapname.php ldap2

(execute it with the last param to see the script syntax).

That should create a new LDAP auth plugin called ldap2 (or whatever name you used). You need to go to "Administration >> Notifications" to make Moodle install the new plugin, and then visit "Administration >> Plugins >> Authentication >> Manage authentication plugins" to enable and configure it.

I haven't tested the NTLM SSO feature too much (I don't depend on it) so if you find it doesn't work as expected, please let me know wink

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi,

I'm using Moodle 2.0.2.

I got the error (find the attachment)

Could you please elaborate with an example.

Thanks and Regards,

Pandiarajan K

In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think you are trying to use the .diff file with patch directly, which you shouldn't.

I'll go step by step. I'll assume you already have patch and command line php installed and available in your PATH (you really need them in your PATH!!!)

1. Download the .zip file with the 3 files. Unzip it and copy the 3 files to the top directory of your Moodle installation. Let's say it's under C:\Moodle\server\moodle.

2. Open a command prompt window and cd into c:\Moodle\server\moodle.

3. Apply the patch from the first file:

    patch -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch

4. Run the ldapname.php file with the name you want to give to your second LDAP auth plugin. Let's say I'll call mine 'ldap2' (without the quotes);

    php -f ldapname.php ldap2

5. That should do it!

Now you only need to go to the Notifications page to install, enable and configure the new 'ldap2' plugin.

If you get a conflict in step 3 or 4 (with a message of 'HUNK failed' or something like that), that means my patch is not up to date with newer versions. If that's the case, just drop me a message here on privately via Moodle messaging-

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Inaki,

I got the following error when I executed in Command prompt.

D:\Moodle\server\moodle>patch -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch
patching file auth/ldap/auth.phpAssertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way.Please contact the application's support team for more information.

Thanks,

Pandiarajan

In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It looks like the version of patch you are using doesn't work well with patch files with Unix line endings.

You can follow the instructions given here http://docs.moodle.org/en/Development:How_to_apply_a_patch#Apply_a_Patch_in_Windows_using_gnuwin32 to deal with the problem.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Inaki,

Now, I got this

D:\Moodle\server\moodle>patch --binary -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch
patching file auth/ldap/auth.php
Hunk #1 FAILED at 107.
Hunk #2 FAILED at 125.
Hunk #3 FAILED at 413.
Hunk #4 FAILED at 428.
Hunk #5 FAILED at 438.
Hunk #6 FAILED at 480.
Hunk #7 FAILED at 507.
Hunk #8 FAILED at 593.
Hunk #9 FAILED at 612.
Hunk #10 FAILED at 626.
Hunk #11 FAILED at 678.
Hunk #12 FAILED at 698.
Hunk #13 FAILED at 716.
Hunk #14 FAILED at 730.
Hunk #15 FAILED at 740.
Hunk #16 FAILED at 766.
Hunk #17 FAILED at 774.
Hunk #18 FAILED at 809.
Hunk #19 FAILED at 823.
Hunk #20 FAILED at 864.
Hunk #21 FAILED at 979.
Hunk #22 FAILED at 1034.
Hunk #23 FAILED at 1082.
Hunk #24 FAILED at 1125.
Hunk #25 FAILED at 1143.
Hunk #26 FAILED at 1160.
Hunk #27 FAILED at 1173.
Hunk #28 FAILED at 1181.
Hunk #29 FAILED at 1230.
Hunk #30 FAILED at 1239.
Hunk #31 FAILED at 1266.
Hunk #32 FAILED at 1284.
Hunk #33 FAILED at 1300.
Hunk #34 FAILED at 1342.
Hunk #35 FAILED at 1363.
Hunk #36 FAILED at 1507.
Hunk #37 FAILED at 1526.
Hunk #38 FAILED at 1544.
Hunk #39 FAILED at 1587.
Hunk #40 FAILED at 1683.
Hunk #41 FAILED at 1820.
Hunk #42 FAILED at 1838.
Hunk #43 FAILED at 1847.
Hunk #44 FAILED at 1894.
Hunk #45 FAILED at 1987.
45 out of 45 hunks FAILED -- saving rejects to file auth/ldap/auth.php.rejpatching file auth/ldap/cli/sync_users.phppatching file auth/ldap/config.htmlpatching file auth/ldap/db/install.phppatching file auth/ldap/ntlmsso_attempt.phppatching file auth/ldap/ntlmsso_finish.phppatching file auth/ldap/ntlmsso_magic.php
D:\Moodle\server\moodle>

Kindly help me out.

Thanks and Regards,
Pandiarajan

In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Christoph Ackermann -

Hi Pandiarajan,

is there a special reason why you used the parameter "--binary" with the patch-command?

Try first ("--dry-run" = only simulates, no actual changes):

D:\Moodle\server\moodle>patch --dry-run -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch

And if that works, you can run the command without the dry-run-parameter.

In reply to Christoph Ackermann

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Chris,

As I got the error "Assertion failed error".

Spending minutes of googling helped me.
I got this "On MS-Windows, the patchfile must be a text file, i.e. CR-LF must be used as line endings. A file with LF may give the error: "Assertion failed, hunk, file patch.c, line 343," unless the option '--binary' is given."

Thanks for your reply..

Kind Regards,
Pandiarajan K

In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Inaki,

I applied the same as above and got succeeded in the First step.

D:\Moodle\server\moodle>patch -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch
patching file auth/ldap/auth.phpHunk #40 succeeded at 1707 (offset 24 lines).
Hunk #41 succeeded at 1844 (offset 24 lines).
Hunk #42 succeeded at 1862 (offset 24 lines).
Hunk #43 succeeded at 1871 (offset 24 lines).
Hunk #44 succeeded at 1918 (offset 24 lines).
Hunk #45 succeeded at 2011 (offset 24 lines).
patching file auth/ldap/cli/sync_users.php
patching file auth/ldap/config.html
patching file auth/ldap/db/install.php
patching file auth/ldap/ntlmsso_attempt.php
patching file auth/ldap/ntlmsso_finish.php
patching file auth/ldap/ntlmsso_magic.php

But in the Second, no luck.

 

D:\Moodle\server\moodle>php -f ldapname.php ldap2
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/auth.php auth/ldap2/auth.php
|--- auth/ldap2/auth.php        2011-01-12 14:58:31.297536058 +0100
|+++ auth/ldap2/auth.php        2011-01-12 14:58:08.745533575 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
2 out of 2 hunks ignored
can't find file to patch at input line 25
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/cli/sync_users.php auth/ldap2/cli/sync_users.php
|--- auth/ldap2/cli/sync_users.php      2011-01-12 12:51:43.641534527 +0100
|+++ auth/ldap2/cli/sync_users.php      2011-01-12 14:55:47.625535078 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 37
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/db/install.php auth/ldap2/db/install.php
|--- auth/ldap2/db/install.php  2011-01-12 15:03:30.337533042 +0100
|+++ auth/ldap2/db/install.php  2011-01-12 15:11:40.706022325 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
The next patch would delete the file auth/ldap2/lang/en/auth_ldap.php,
which does not exist!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
The next patch would create the file auth/ldap2/lang/en/auth_ldap2.php,
which already exists!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file auth/ldap2/lang/en/auth_ldap2.
php.rej
can't find file to patch at input line 346
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/ntlmsso_attempt.php auth/ldap2/ntlmsso_attempt.php
|--- auth/ldap2/ntlmsso_attempt.php     2011-01-12 13:09:55.905536932 +0100
|+++ auth/ldap2/ntlmsso_attempt.php     2011-01-12 14:56:28.849399275 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 358
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/ntlmsso_finish.php auth/ldap2/ntlmsso_finish.php
|--- auth/ldap2/ntlmsso_finish.php      2011-01-12 13:10:12.113533756 +0100
|+++ auth/ldap2/ntlmsso_finish.php      2011-01-12 14:56:35.505532049 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 370
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/ntlmsso_magic.php auth/ldap2/ntlmsso_magic.php
|--- auth/ldap2/ntlmsso_magic.php       2011-01-12 13:11:07.273533913 +0100
|+++ auth/ldap2/ntlmsso_magic.php       2011-01-12 14:56:41.061374137 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
D:\Moodle\server\moodle>
Please help me out guys..
Kind Regards,
Pandiarajan K
In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Pandiarajan Karuppasamy

I'm really sorry, this is completely my fault sad I didn't test it in Windows, and I assumed it would work like it does in Linux/Unix. I have tested it today, and it clearly didn't work at all.

I've updated the files to make it work in Windows too (I've tested them myself under W2003), and I'm attaching a new .zip file to this message.

Again, sorry for the inconveniences sad sad

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Inaki,

Thanks for your reply.
Patch is working fine. But the LDAP2 config page is not working properly.
Once the patch got completed, I've opened the Homepage it redirects to the /admin/index.php - It asked me to upgrade(Module/plugin).
I've clicked upgrade then, the page display the auth ldap2(where the page shows only first half page other half is not displayed as like the attachment)
Is it possible to manually config the LDAP2 plugin.
And I'm not able to view the "Manage Authentication" page as well.

Please find the attachment.

Thanks,
Pandiarajan K

In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Pandiarajan Karuppasamy,

can you try this new version? I missed a couple of things in the previous version and I've added a note stating that you need to adjust some permissions by hand if you are using Internet Information Services (due to a bug in the patch.exe tool for Windows).

I hope this is the good one smile

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Inaki,

Thanks for your reply, patch worked well.
D:\Moodle\server\moodle>patch -p1 < 0001-Add-support-for-multiple-clones-of-the-
LDAP-auth-plu.patch
patching file auth/ldap/auth.php
Hunk #40 succeeded at 1707 (offset 24 lines).
Hunk #41 succeeded at 1844 (offset 24 lines).
Hunk #42 succeeded at 1862 (offset 24 lines).
Hunk #43 succeeded at 1871 (offset 24 lines).
Hunk #44 succeeded at 1918 (offset 24 lines).
Hunk #45 succeeded at 2011 (offset 24 lines).
patching file auth/ldap/cli/sync_users.php
patching file auth/ldap/config.html
patching file auth/ldap/db/install.php
patching file auth/ldap/ntlmsso_attempt.php
patching file auth/ldap/ntlmsso_finish.php
patching file auth/ldap/ntlmsso_magic.php
D:\Moodle\server\moodle>php -f ldapname.php ldap2
D:\Moodle\server\moodle\auth\ldap\auth.php
D:\Moodle\server\moodle\auth\ldap\auth.php.orig
D:\Moodle\server\moodle\auth\ldap\auth.php.rej
D:\Moodle\server\moodle\auth\ldap\config.html
D:\Moodle\server\moodle\auth\ldap\ntlmsso_attempt.php
D:\Moodle\server\moodle\auth\ldap\ntlmsso_finish.php
D:\Moodle\server\moodle\auth\ldap\ntlmsso_magic.php
D:\Moodle\server\moodle\auth\ldap\README-LDAP
D:\Moodle\server\moodle\auth\ldap\version.php
D:\Moodle\server\moodle\auth\ldap\cli\sync_users.php
D:\Moodle\server\moodle\auth\ldap\db\install.php
D:\Moodle\server\moodle\auth\ldap\lang\en\auth_ldap.php
12 File(s) copied
patching file auth/ldap2/auth.php
patching file auth/ldap2/cli/sync_users.php
patching file auth/ldap2/db/install.php
patching file auth/ldap2/lang/en/auth_ldap2.php
patching file auth/ldap2/ntlmsso_attempt.php
patching file auth/ldap2/ntlmsso_finish.php
patching file auth/ldap2/ntlmsso_magic.php
=====================================================================
If you are using Internet Information Server (IIS) to run your Moodle
installation, please adjust the permissions of the
D:\Moodle\server\moodle\auth\ldap2 directory.
patch.exe for Windows removes some essential permissions from the
patched files, that make some of then unreadable by IIS.
The simplest way to fix them is to use Windows Explorer to show the
properties of the D:\Moodle\server\moodle\auth\ldap2 directory, go to the
Security tab, click on the 'Advanced' button on the bottom right,
select the checkbox called 'Replace permission entries on all child
objects with entries shown here that apply to child objects', click
on the 'OK' button and confirm the dialog box.
=====================================================================
D:\Moodle\server\moodle>
----------------------------------------------------------
Note: I'm using Apache web server.
Thanks and Regards,
Pandiarajan K
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Christoph Ackermann -

Hello Iñaki,

thank you very much for the ldap-patch. It works great, also with a windows server. I now have seven different domains with NTLM-SSO running. wide eyes

For all those who want to try it with a windows server: After you've extracted the files to your moodle directory it's basically two additional steps before you can a new ldap-plugin as described.

1.) Download gnu32win patch, extract it and add the location to the windows path

2.) Open all three files of the patch with Wordpad and save them again in the MS-DOS Textformat.

After that you can call the commands as described.

 

Christoph

In reply to Christoph Ackermann

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Pandiarajan Karuppasamy -

Hi Chris/Inaki,

I applied the same as above and got succeeded in the First step.

D:\Moodle\server\moodle>patch -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch
patching file auth/ldap/auth.phpHunk #40 succeeded at 1707 (offset 24 lines).
Hunk #41 succeeded at 1844 (offset 24 lines).
Hunk #42 succeeded at 1862 (offset 24 lines).
Hunk #43 succeeded at 1871 (offset 24 lines).
Hunk #44 succeeded at 1918 (offset 24 lines).
Hunk #45 succeeded at 2011 (offset 24 lines).
patching file auth/ldap/cli/sync_users.php
patching file auth/ldap/config.html
patching file auth/ldap/db/install.php
patching file auth/ldap/ntlmsso_attempt.php
patching file auth/ldap/ntlmsso_finish.php
patching file auth/ldap/ntlmsso_magic.php

But in the Second, no luck.

D:\Moodle\server\moodle>php -f ldapname.php ldap2
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/auth.php auth/ldap2/auth.php
|--- auth/ldap2/auth.php        2011-01-12 14:58:31.297536058 +0100
|+++ auth/ldap2/auth.php        2011-01-12 14:58:08.745533575 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
2 out of 2 hunks ignored
can't find file to patch at input line 25
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/cli/sync_users.php auth/ldap2/cli/sync_users.php
|--- auth/ldap2/cli/sync_users.php      2011-01-12 12:51:43.641534527 +0100
|+++ auth/ldap2/cli/sync_users.php      2011-01-12 14:55:47.625535078 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 37
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/db/install.php auth/ldap2/db/install.php
|--- auth/ldap2/db/install.php  2011-01-12 15:03:30.337533042 +0100
|+++ auth/ldap2/db/install.php  2011-01-12 15:11:40.706022325 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
The next patch would delete the file auth/ldap2/lang/en/auth_ldap.php,
which does not exist!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
The next patch would create the file auth/ldap2/lang/en/auth_ldap2.php,
which already exists!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file auth/ldap2/lang/en/auth_ldap2.
php.rej
can't find file to patch at input line 346
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/ntlmsso_attempt.php auth/ldap2/ntlmsso_attempt.php
|--- auth/ldap2/ntlmsso_attempt.php     2011-01-12 13:09:55.905536932 +0100
|+++ auth/ldap2/ntlmsso_attempt.php     2011-01-12 14:56:28.849399275 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 358
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/ntlmsso_finish.php auth/ldap2/ntlmsso_finish.php
|--- auth/ldap2/ntlmsso_finish.php      2011-01-12 13:10:12.113533756 +0100
|+++ auth/ldap2/ntlmsso_finish.php      2011-01-12 14:56:35.505532049 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 370
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -urN auth/ldap2/ntlmsso_magic.php auth/ldap2/ntlmsso_magic.php
|--- auth/ldap2/ntlmsso_magic.php       2011-01-12 13:11:07.273533913 +0100
|+++ auth/ldap2/ntlmsso_magic.php       2011-01-12 14:56:41.061374137 +0100
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
D:\Moodle\server\moodle>
Please help me out guys..
Kind Regards,
Pandiarajan K
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Денис Васильев -

I used the patch for version 2.9 but when you try to update the configuration there is such an error

Attachment 2016-01-27 00-15-24 Ошибка – Yandex.png
In reply to Pandiarajan Karuppasamy

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by karl Hehr -

This doesn't appear to work with Moodle 2.2

I have followed the steps and I found two errors.

Here is the text from the terminal commands:

patching file auth/ldap/auth.php
Hunk #8 succeeded at 594 (offset 1 line).
Hunk #9 succeeded at 613 (offset 1 line).
Hunk #10 succeeded at 627 (offset 1 line).
Hunk #11 succeeded at 679 (offset 1 line).
Hunk #12 succeeded at 699 (offset 1 line).
Hunk #13 succeeded at 717 (offset 1 line).
Hunk #14 succeeded at 731 (offset 1 line).
Hunk #15 succeeded at 741 (offset 1 line).
Hunk #16 succeeded at 767 (offset 1 line).
Hunk #17 succeeded at 775 (offset 1 line).
Hunk #18 succeeded at 810 (offset 1 line).
Hunk #19 succeeded at 824 (offset 1 line).
Hunk #20 succeeded at 865 (offset 1 line).
Hunk #21 succeeded at 980 (offset 1 line).
Hunk #22 succeeded at 1035 (offset 1 line).
Hunk #23 succeeded at 1083 (offset 1 line).
Hunk #24 succeeded at 1126 (offset 1 line).
Hunk #25 succeeded at 1144 (offset 1 line).
Hunk #26 succeeded at 1161 (offset 1 line).
Hunk #27 succeeded at 1174 (offset 1 line).
Hunk #28 succeeded at 1182 (offset 1 line).
Hunk #29 succeeded at 1231 (offset 1 line).
Hunk #30 succeeded at 1240 (offset 1 line).
Hunk #31 succeeded at 1267 (offset 1 line).
Hunk #32 succeeded at 1285 (offset 1 line).
Hunk #33 succeeded at 1301 (offset 1 line).
Hunk #34 succeeded at 1343 (offset 1 line).
Hunk #35 succeeded at 1364 (offset 1 line).
Hunk #36 succeeded at 1508 (offset 1 line).
Hunk #37 succeeded at 1527 (offset 1 line).
Hunk #38 succeeded at 1545 (offset 1 line).
Hunk #39 succeeded at 1588 (offset 1 line).
Hunk #40 succeeded at 1684 (offset 1 line).
Hunk #41 succeeded at 1821 (offset 1 line).
Hunk #42 succeeded at 1839 (offset 1 line).
Hunk #43 succeeded at 1848 (offset 1 line).
Hunk #44 succeeded at 1895 (offset 1 line).
Hunk #45 succeeded at 1988 (offset 1 line).
patching file auth/ldap/cli/sync_users.php
patching file auth/ldap/config.html
patching file auth/ldap/db/install.php
patching file auth/ldap/ntlmsso_attempt.php
patching file auth/ldap/ntlmsso_finish.php
patching file auth/ldap/ntlmsso_magic.php
moodle:moodle techacsd$ sudo php -f ldapname.php ldap2
patching file auth/ldap2/auth.php
patching file auth/ldap2/cli/sync_users.php
patching file auth/ldap2/db/install.php
patching file auth/ldap2/lang/en/auth_ldap.php
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file auth/ldap2/lang/en/auth_ldap.php.rej
patching file auth/ldap2/lang/en/auth_ldap2.php
patching file auth/ldap2/ntlmsso_attempt.php
patching file auth/ldap2/ntlmsso_finish.php
patching file auth/ldap2/ntlmsso_magic.php

 

Then when I go into my site and try and activate the new plug-in I get the following error:

 

Debug info: Plugin installed in wrong folder.
Stack trace:
  • line 296 of /lib/upgradelib.php: plugin_defective_exception thrown
  • line 1440 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 269 of /admin/index.php: call to upgrade_noncore()

Any help would be appreciated. This instance of Moodle is installed on an OS X Server. (Unix)

In reply to karl Hehr

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

as there are multiple Moodle 2.2 versions (from 2.2.0 to 2.2.9+, with many sub-versions in between) it's a bit difficult to produce a single patch that works for all of them.

I have just created a new version of the patch for Moodle 2.2.9+ (current as of today). I'm attaching the patch to this post. I hope this updated version works with your particular version.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Bob Kresko -

We have version 2.2 runing on Windows Server 2008.  I can't seem to follow th instructions.  It looks like we have the patch as we have multiple LDAP servers in the auth directory.  I see the ldapname files unzipped to the root as well. Someone prior to me configured this, but I can't follow the instructions to get it to add another.

Step by step for this platform would really be appreciated.

 

In reply to Bob Kresko

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Bob,

if you go back in the conversation, you will see that there are step by step instructions to do it in Windows. Anyway, I'll rehash them here, including additional remarks to address some things that have happened to several people since I wrote those instructions smile

I'll go step by step. I'll assume you already have the patch executable (patch.exe) and command line php executable (php.exe) installed and available in your PATH (you really need them in your PATH!!!). It is a good idea to check the Moodle documentation page on how to apply a patch in Windows

  1. Download the .zip file with the 3 files. Make sure you download the right .zip for your Moodle version! Unzip it and copy the 3 files to the top directory of your Moodle installation. Let's say it's under C:\Moodle\server\moodle.

  2. Open a command prompt window and cd into c:\Moodle\server\moodle.

  3. Apply the patch from the first file, using the instructions you can find in the Moodle documetation page we mentionned above.

  4. Run the ldapname.php file with the name you want to give to your second LDAP auth plugin. Let's say I'll call mine 'ldap2' (without the quotes);

    php.exe -f ldapname.php ldap2

  5. Now you only need to go to the Notifications page to install, enable and configure the new 'ldap2' plugin.

If you need to add a third LDAP auth plugin (a fourth, a fifth etc.), you just need to repeat steps 4 and 5 (using the new LDAP auth plugin, of course!). You only need to repeat steps 1 to 3 if you upgrade your Moodle version.

If you get a conflict in step 3 or 4 (with a message of 'HUNK failed' or something like that), that means my patch is not up to date with newer versions. If that's the case, just drop me a message here on privately via Moodle messaging.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by suleman soudagar -

Hello Inaki,

Could you please share the patch for Moodle 3.6.x. I am having the same problem.


thanks


In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Alex Hosmer -

Hi Iñaki,

I'm having a similar patch error.  I'm trying to patch the most recent build of Moodle as of 03/21/2011.  Is there a way to specify which lines to replace in the Moodle code?  I know this would be applied cleanly to the same version you were running, but I wanted to make sure I'm including the most up to date fixes to Moodle itself.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Forrest Gaston -

Iñaki, 

I was wondering, do you have a patch file for Moodle 1.9, I thought I could implement this before my upgrade to Moodle 2.2.

By the way, thanks again for the Moodle 2.2 diff file, it worked great. 

Forrest 

In reply to Forrest Gaston

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Forrest,

I'm afraid I don't have such a patch, and I don't know when I'll have some spare time to create it sad

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by R. Gusmão -

Hi Everyone,

I´m testing a moodle 2.3 install in ubuntu desktop 12.04, and trying to connect to my active director ldap servers.  I have the root domain and one child domain for authenticate users in moodle.

I put the LDAP2 in /moodle/auth, and apparently everything work well, the plugin is enable.

The problem is that I configure the fields but I only authenticate users from root domain, with users of the child fomain gives me this error:

"LDAP-module cannot connect to any servers: Server: 'ldap://xxx.xxx.xxx.xxx', Connection: 'Resource id #48', Bind result: ''

I checked all the parameters and is everything correct (bind user; password; contexts...)

Some help need.

Thanks in advance

In reply to R. Gusmão

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by R. Gusmão -

Solved, add my bind user to group of administrators smile 

 

Thanks anyway

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

Hello,


I have moodle 3.2.1 and have different ldap servers in the same forest but all are the same, there is no parent/child relationship between them:


|-ldap1.domain1.com

|-ldap2.domain2.com

|-ldap3.domain3.com

|-ldap4.domain4.com


Users from multiple ldaps shall do single sign on this way

domain1\user1

domain1\user2

domain2\user1

domain3\user1


How can I set up all these ldaps to be querried all at the same and not through a failover mode.

Best regards,

In reply to Georges O.

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The easiest way would be if one is a global catalog and then you might be able to do this with one ldap connector.  Otherwise, you are going to have to clone your ldap module for each domain.  Search clone ldap to find the thread where Inaki has very handy patches for creating the cloned modules.

In reply to Emma Richardson

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

Hi Emma, the patch that was suggested by Inaki was for version 2.0 while I have version 3.2.1

In reply to Georges O.

Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñigo Zendegi Urzelai -
Picture of Core developers Picture of Plugin developers

Hi Georges,

This thread is so long and can be difficult to find but some weeks ago Iñaki posted the updated version for Moodle 3.2.x here:

https://moodle.org/mod/forum/discuss.php?d=74279#p1390869
In reply to Iñigo Zendegi Urzelai

Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

Hi Inigo,

I was able to do authication to multiple ldap servers along with NTLM SSO referring to the post of Inaki however there is a problem that the username is stored in Moddle without the domain if I retrieve sAMAccountName from AD and stored as user@domain.com if I use userPrincipalName from AD.


However NTLM works only with sAMAccountName as in userPrincipalName I have to retype username as password to login.

My problem is that I have duplicate usernames between the domains, for example:

domainname1\userIntitial17

domainname2\userIntitial17


and without having this combination, the second user is not able to authenticate.


Best regards,

Georges

In reply to Georges O.

Er: Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñigo Zendegi Urzelai -
Picture of Core developers Picture of Plugin developers

Hi Georges,

I'm not 100% sure but I'd say that with this method you cannot validate identic usernames from different domains because, as Emma said, the domain is stored in the authentication method and the username must be unique.

For example, if you have two users (domain1\username33 and domain2\username33) and the first one logs in his/her username is stored in the user table with the authentication method pointing to that domain, so when the second user tries to log the system tries to authenticate it using the domain of the first user.

In reply to Iñigo Zendegi Urzelai

Re: Er: Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

Hi Inigo,

When I used: "userPrincipalName" instead of "sAMAccountName" for the User attribute, both usernames were stored in this format: username33@domain1.com and username22@domain2.com which solved my problem however NTLM did not work.

Best regards,

Georges

In reply to Georges O.

Re: Er: Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That could work if you used Kerberos-style SSO instead of NTLM-style SSO. But the setup for Kerberos SSO is way more complex than the one used for NTLM.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Er: Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

Hello Inaki,

Thank you for your reply. How can I switch to Kerberos-style SSO and does it require additional modules?

Best regards,

Georges

In reply to Georges O.

Re: Er: Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Georges,

you need to configure your web server (Apache, IIS, etc) to use Kerberos instead of NTLM. If you are using Apache on linux, the following two links give you the details to set it up:

Once you have done that, you need to use "userPrincipalName" as the user attribute, and choose "Kerberos" as the authentication type in the NTLM SSO Section, as shown below:

NOTE: I've neved used Kerberos myself for this kind of setup, but according to some people in the forums, it should work.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Er: Re: Er: Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

Hi Inaki,


Thank you for your reply. my Apache is running on Windows Server 2012. Is what you sent supported on my OS. If not, is there any alternative?


Best regards,

Georges

In reply to Christoph Ackermann

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Gordon McLeod -

Hello,

I've installed a copy of ldap 2 on our 1.9 site, and it loaded and allowed me to configure the settings - but the site doesn't appear to notice.

The original ldap plugin works and allows users to login - and if we swap the details to those of the second server those users can then login (so the settings are correct), but ldap2 just doesn't work. Can anyone suggest a where-next step - should I have modified something else that doesn't sit inside the auth/ldap2 directory?

Thanks.

In reply to Gordon McLeod

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Is it enabled?  And what error do you get when you try to log in with one of those accounts?

In reply to Emma Richardson

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Georges O. -

yes it enabled and I the first user is able to authenitcate correctly however the second one is redirected to enter a user/pass

I have also created the following to test how it is displayed

<?php

 if (isset($_SERVER['REMOTE_USER']) && !empty($_SERVER['REMOTE_USER'])) {
     echo "<p>NTLM authentication seems to be working. User: " . $_SERVER['REMOTE_USER'] . "</p>";
 } else {
     echo '<p>NTLM is not working</p>';
 }

?>

it is giving for each:

Domain1\MyUserName17

Domain2\MyUserName17


However, if you go inside Moodle into:

    Dashboard
    Users
    MyUserName17
    Preferences
    User account
    Edit profile


the username will be: MyUserName17 instead of Domain1\MyUserName17

In reply to Georges O.

Re: How to use multiple LDAP servers with Moodle 2.0(!)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Sorry, got confused because you are in an old post with so many messages.  I replied to some other message that is in the middle of yours.  It is so much better to start a fresh thread.

However, are you sure it is wrong?  Just because the username does not include the domain, the users will be distinguished by authentication method...

In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by Vangel Ajanovski -

We use separate AD servers for staff and students and I solved this with a small OpenLDAP server configured to function as a proxy. The configuration is such that talks to both (or as many as you need) servers, rewrites the paths to make them look like they belong to a single LDAP within a single root.

This is the config - it connects to two ldap servers, teachers on 1 and students on 2 and presents them both as if under a single tree:

  • OU=Techers,DC=COMPANY
  • OU=Students, DC=COMPANY

I configure Moodle to use the root of the proxy server, and to connect using the MANAGER user.

We have just a small problem with this which I posted in another topic here - Moodle does not update user autocreation does not work if the user profile fields are setup to update on every login (this is with the CAS plugin)

------------------------------------

include         /etc/ldap/schema/core.schema
moduleload      back_ldap
moduleload      back_meta

database meta
suffix dc=COMPANY
rootdn "cn=Manager,dc=COMPANY"
rootpw {SSHA}***********************************

uri "ldap://server1/ou=Teachers,dc=COMPANY"
suffixmassage "ou=Teachers,dc=COMPANY" "real ldap path where teachers are in server1"
idassert-bind bindmethod=simple   binddn="user to connect in server1 full path"   credentials="********************"   mode=none   flags=non-prescriptive
idassert-authzFrom "dn.exact:cn=Manager,dc=COMPANY"

uri "ldap://server2/ou=Students,dc=COMPANY"
suffixmassage "ou=Students,dc=COMPANY" "real path where students are in server2"
idassert-bind bindmethod=simple   binddn="user to connect in server1 full path"   credentials="*********"   mode=none   flags=non-prescriptive
idassert-authzFrom "dn.exact:cn=Manager,dc=COMPANY"
In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by Senthil Kumar -
Hi I have followed your steps and configured two LDAP settings, first one - ldap and the second one ldap2, If i run the ldap2 user sync, it deletes the users from ldap and if i run the ldap user sync, it deletes the user from ldap2 and also i noticed that ldap2 synced users are stored under the ldap auth, not stored in ldap2 auth, Please suggest me how to solve this issue
In reply to Senthil Kumar

Re: How to use multiple LDAP servers with Moodle 1.8

by Rosario Carcò -

Sorry, I migth be very late for this but I used multiple LDAP-Servers like this:

  • in the LDAP Server Field (Host URL) you may type in more than one server separated by semicolons like this:
  • ldap://yourAd.domain.edu:3268;ldap://10.51.3.17:3268 (The port 3268 being Microsoft's Global Catalog Port which is compatible with the default LDAP Port)
  • or you may use DNS-Round-Robin to achieve the same redundancy on yourAd.domain.edu
  • instead of using SamAccountName you may use mail if you have the same SamAccountNames on two or more domains like we do. Simply set the USER ATTRIBUTE Field of your LDAP-Settings to mail so as to use the eMail-Addresses of the users as Moodle usernames. You have to enable extended characters in your Moodle-Server-Policy for user-account-names first because of the @-sign.

Rosario

In reply to Rosario Carcò

Re: How to use multiple LDAP servers with Moodle 1.8

by Kathrin Schwarz -

Great stuff !!!

We have install the patch for moodle 2.2.1.

Thanks a lot!!

Kathrin

In reply to Kathrin Schwarz

Re: How to use multiple LDAP servers with Moodle 1.8

by Forrest Gaston -

I'm getting the following error message when I try to load the duplicated LDAP module"

Plugin "auth_ldapf9" is defective or outdated, can not continue, sorry.

More information about this error

Debug info: Plugin installed in wrong folder.
Stack trace:
  • line 296 of /lib/upgradelib.php: plugin_defective_exception thrown
  • line 1440 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 269 of /admin/index.php: call to upgrade_noncore()
 
I didn't notice any issues etc while patching.
 
I'm user Moodle version: 2.2+ (Build: 20111209)
 
The duplicated module is in the /auth/ folder, I'm not sure where the plugin installed in wrong folder is coming from. 
 
Thanks
Forrest
 
In reply to Forrest Gaston

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Forrest,

it seems the patch is not compatible with Moodle 2.2.x (in fact I'm surprised it even works with 2.1.x smile).

I'll see if I can spend some time on upgrading it for 2.2.x, but I can't promise anything.

Saludos.
Iñaki.
Average of ratings: Useful (1)
In reply to Forrest Gaston

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Forrest,

I finally had a couple of free hours today and updated the patch for 2.2 (current as of today). The instructions to apply the patch are the same as the old version.

Saludos.
Iñaki.
Average of ratings: Useful (1)
In reply to Kathrin Schwarz

Re: How to use multiple LDAP servers with Moodle 1.8

by Forrest Gaston -

Kathrin, 

 

Can you tell me how you got it to work with Moodle 2.2.1, I can't get it to work. 

 

Thanks

Forrest

In reply to Forrest Gaston

Re: How to use multiple LDAP servers with Moodle 1.8

by Flávio Camargo -

Hi,

I have good news.

To use multiple ldap, copy and paste the attachment directory in the directory auth.

Now you only need to go to the Notifications page to install, configure and enablethe new 'LDAP2 plugin.

I tested this in version 2.1.1 and 2.2.1! =)

Thanks Iñaki Arenaza!

 

Average of ratings: Useful (1)
In reply to Flávio Camargo

Re: How to use multiple LDAP servers with Moodle 1.8

by Christopher O'Kelly -

Hey, just applied. I got this message at the end -

 

"If you are using Internet Information Server (IIS) to run your Moodle installation, please adjust the permissions of the /var/www/mtp/auth/ldap2 directory. patch.exe for Windows removes some essential permissions from the patched files, that make some of then unreadable by IIS. The simplest way to fix them is to use Windows Explorer to show the properties of the /var/www/mtp/auth/ldap2 directory, go to the Security tab, click on the 'Advanced' button on the bottom right, select the checkbox called 'Replace permission entries on all child objects with entries shown here that apply to child objects', click on the 'OK' button and confirm the dialog box."

 

I actually use ubuntu and apache, does this not apply to me in that case?

In reply to Christopher O'Kelly

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Christopher,

this only applies to those using Microsoft Internet Information Server on Windows smile

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Oleg Mikheev -

Hello! We use Moodle 2.2.2 and have a problem then installing your last patch for 2.2.1.

What we make wrong?

Thanks, regards. KFU.

 

In reply to Oleg Mikheev

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Oleg,

I see in your screenshot that you run patch.exe command with the '--dry-run' option to test whether the patch applies cleanly, but you don't run it a second time without it, to actually apply the patch.

I also see that before running 'php -f ldapname.php ....' you get out of the moodle installation directory. You don't have to do that. You have to execute the command from inside the moodle installation directory (just like the first one).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by anh pham -

Hi Iñaki,

I would like to use features of Moodle 2.3+ stable, could you please create the patch for LDAP in this version?

Thank you!

In reply to anh pham

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi,

here a version for 2.3+. There are two zip files because depending on the exact 2.3+ version you have, the patch is slightly different (due to the MDL-23254 bugfix). So if your version is from *before* Thu Jun 28 2012, it doesn't have the MDL-23254 fix and you should use ldap-clones-patch-scriptv5_2.3.zip. If your version is from *after* that date, then you should use ldap-clones-patch-scriptv5_2.3+.zip

Saludos.
Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by anh pham -

Thanks Iñaki,

When applying patch, I get the error below:

[root@moodle moodle]# patch -p1 < 0001-Add-support-for-multiple-clones-of-the -LDAP-auth-plu.patch
patching file auth/ldap/auth.php
patching file auth/ldap/cli/sync_users.php
patching file auth/ldap/config.html
patching file auth/ldap/ntlmsso_attempt.php
Hunk #2 FAILED at 36.
1 out of 2 hunks FAILED -- saving rejects to file auth/ldap/ntlmsso_attempt.php. rej
patching file auth/ldap/ntlmsso_finish.php
patching file auth/ldap/ntlmsso_magic.php
Hunk #3 FAILED at 32.
Hunk #4 succeeded at 46 (offset -1 lines).
1 out of 4 hunks FAILED -- saving rejects to file auth/ldap/ntlmsso_magic.php.re j
patching file auth/ldap/version.php

Then I ran 'php -f ldapname.php  ldap2'

It created an notification, I installed the new plugin and it didn't give me 'successful install'. 

But the new plugin 'ldap2' is somehow added to Plugin-->Authentication .

I have not tested new ldap2 yet.

My question is 'Does the error above is ok?' Could you please check the patch again?

I use moodle 2.3+ and ldap-clones-patch-scriptv5_2.3+.zip (fresh installation)

Thank you so much!

In reply to anh pham

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It looks like you are using a 2.3+ version from before the date I talked about (jugding from the errors). So you should use ldap-clones-patch-scriptv5_2.3.zip (without the +) instead.

But before trying with that, you should restore the original files of the auth/ldap directory (otherwise the patching will fail again).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by anh pham -

Thank you so much Iñaki!

It works well.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by anh pham -

Hi Iñaki,

I have another error with this, I cannot create over 3 LDAP plugin. When I create the 4th is okie, go to the admin page to upgrade, It gace me an error "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request." and nothing in apache log file.

Did you try to create more than 3 LDAP?

In reply to anh pham

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi anh pham,

with the fixed version of the patch I have just posted, I've created 7 LDAP authentication plugins a couple of minutes ago (in a test install). All of them have installed successfully, with no internal o server errors at all.

You might need the fixed version of the patch.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Stephen Carter -

Thanks for this patch Iñaki. I've installed in on our Moodle 2.3 and it appears to have worked.


The only issue I had on install occured at the last step at Site Admin / Notifications / Upgrade. Moodle recognised that an upgrade was required OK, but when I ran the upgrade it returned the following error:

Fatal Error: Call to undefined function xmldb_auth_ldap2_install() in /home/XXXXXXXXXXXXXXX/public_html/lib/upgradelib.php on line 445

Even though it produced this error the new instance of LDAP (defined as ldap2) appeared as an authentication method and I was able to configure and use it with success. Should I be worried about the error ?


Also, do you know of a way to set up LDAP authentication so that two LDAP servers are defined, but the same authentication method 'ldap' is used for both servers and entered in user profiles. When a user with the authentication method of 'ldap' attempts to login, Moodle checks the first LDAP server and if that fails, checks the second LDAP server.

In reply to Stephen Carter

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Sorry, that was totally my fault! There was a missing hunk in the patching file ldapname.diff, to rename db upgrade function to the right name. That's why you get the fatal error.

But as that function is completely empty in Moodle 2.3, the new ldap plugin is fully functional.

Anyway, here are the fixed versions for 2.3 and 2.3+ (the same criteria from my previous posts apply).

Regarding your second question about two LDAP servers, I'm not sure I fully understand the details. Are you talking about having to different LDAP authentication plugins, or two LDAP servers in the same authentication plugin?

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Forrest Gaston -

Hi Inaki, 

I'm getting the following error message when I try to apply the patch for Moodle 2.3.2, I was wondering if you could help me out. 

Hunk #1 FAILED at 101.

1 out of 13 hunks FAILED -- saving rejects to file auth/ldap/config.html.rejn

With the following detail in the config.html.rejn file:

 

*************** *** 101,124 ****

-

-

 error_text($err['host_url']); } ?>

-

-

   

+

authtype) ?>

 

+ authtype) ?>

 error_text($err['host_url']); } ?>

+ authtype) ?>

+ authtype) ?>

   

Thanks again, 

Forrest Gaston

In reply to Forrest Gaston

Re: How to use multiple LDAP servers with Moodle 1.8

by curly curly -

We get the same error here I am afraid.

 

LDAP2 directory is there and there is a successful install of ldap2 from notifications, and a subsequent config page for the second LDAP. However, it does not show up as a link in the admin navigation afterwards.

 

In reply to curly curly

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Did you enable the additional LDAP plugin in "Site administration >> Plugins >> Authentication >> Manage authentication"? As soon as I do it, it appears in the admin navigation like any other authentication enabled plugin.

Saludos.
Iñaki.
In reply to Forrest Gaston

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Can you try the attached version?

There were a couple of changes between 2.3 and 2.3.2 that broke the patch. I've tried the attached version with 2.3.2+ current as of today and it applies cleanly (I also created a new LDAP instance to test that it works as expected too).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by curly curly -

I got a chance to install this over the weekend and it works perfectly. Thank you sincerely. This is a really strong feature for a practical Moodle setup as so many real world environments that require multiple directory authentication.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Jaswant Tak -

Hi Iñaki,

I applied the patch and then tried to execute the command

php -f ldapname.php ldap2

But I am getting this message

Default exception handler: <p>Error: Database connection failed</p>
<p>It is possible that the database is overloaded or otherwise not running properly.</p>
<p>The site administrator should also check that the database details have been correctly specified in config.php</p> Debug:
Warning: mysqli::mysqli(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Applications/MAMP/htdocs/moodle232/lib/dml/mysqli_native_moodle_database.php on line 377

Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in /Applications/MAMP/htdocs/moodle232/lib/dml/mysqli_native_moodle_database.php on line 377

Error code: dbconnectionfailed
* line 384 of /lib/dml/mysqli_native_moodle_database.php: dml_connection_exception thrown
* line 344 of /lib/dmllib.php: call to mysqli_native_moodle_database->connect()
* line 476 of /lib/setup.php: call to setup_DB()
* line 30 of /config.php: call to require_once()
* line 28 of /ldapname.php: call to require()

!!! <p>Error: Database connection failed</p>
<p>It is possible that the database is overloaded or otherwise not running properly.</p>
<p>The site administrator should also check that the database details have been correctly specified in config.php</p> !!!

I have macbook and MAMP to run my Moodle. MySQL is connected, I can even access the Moodle in browser. But dont know why I am getting database connection failed message with ldapname.php script.

Please advise.

Thanks,

Jaswant

In reply to Jaswant Tak

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Jaswant,

I don't know why the script can't connect to the database, as it simply includes config.php which does all the work as usual.

Anyway, we don't need the database at all for this script to work. We just include config.php to get the some paths from the configuration settings. So you can modify ldapname.php to catch this exception and ignore it.

Look for the line that reads:


require(dirname(__FILE__).'/config.php');


and change it to this:


try {
require(dirname(__FILE__).'/config.php');
} catch (dml_connection_exception $e) {
// Just continue, we con't need the database for this to work.
}


Depeding on your Moodle debugging settings you might get some warning messages about the failed connection, but the script should continue and do its work.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ouahib gebraltar -

Hi Iñaki,

    I'm facing the same issue and I don't know how to work it around. 

I have moodle 3.2 version before June 29th 2012, so I dowloaded the above patch ldap-clones-patch-scriptv5_2.3.zip, my database is oracle

when I try the command php -f ldapname.php ldap2 I get the following nasty error : 

<p>The site administrator should verify server configuration</p><p>PHP has not been properly configured with the OCI8 extension so that it can communicate with Oracle. Please check your php.ini file or recompile PHP.</p> !!!

I checked in the php.ini, the OCI8.so extension is there !

 look forward to see your advise.

 

Thanks in advance for your precious help. 

 

Ouahib 

 

 

In reply to ouahib gebraltar

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Oubhib,

PHP can use different php.ini files, depending on whether it's running in web context (as part of the web page request) or in the command line. So make sure you check the php.ini file your command line php is using. You can see which one it's using by executing:


php -i


and looking for the line that reads something similar to this one (this one is for my Debian Linux box, yours can be different).


Loaded Configuration File => /etc/php5/cli/php.ini


Saludos.
Iñaki.
Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by SWBH IT -

Hi Iñaki,

Do you have a version of your patch file for Moodle 2.4.1?

Many thanks in advance,

Barny.

In reply to SWBH IT

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Barny,

just had it in my disk but didn't remember to post it before. Here it is (it should work on 2.4.0, 2.4.1 and 2.4.2 current as of today).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by SWBH IT -

Iñaki,

Applyed perfectly and works brilliantly.

Many thanks for your help and putting the effort in to developing this and keeping it up to date.

Thanks again.

Regards,

Barny.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ouahib gebraltar -

Hi Iñaki,

   Thanks a lot for your help. indeed as I'm using Redhat the php.ini should have been put in the right system directory. 

So now I'm able to see the entry Ldap 2 in the authentication list, however when I enter the right AD details in LDAP server 2,which work correctly with default LDAP server, the authentication doesn't work while it woks with normally ldap server .

 

any idea what I should do ?

 

Knowing that I didn't cleanup the DB after the 1st attempt which didn't work, I have just removed the directory auth/ldap2. 

 

Thanks in advance for your help.

Ouahib 

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ouahib gebraltar -

Hi Iñaki,

   I did a roolback of my DB and itried again the patch command worked correctly , however for the command 

php -f ldapname.php ldap2

I got the folowing error : 

[root@MEC-SVMOODT01 moodle]# php -f ldapname.php ldap2
patching file auth/ldap2/auth.php
Hunk #2 FAILED at 108.
1 out of 2 hunks FAILED -- saving rejects to file auth/ldap2/auth.php.rej
patching file auth/ldap2/cli/sync_users.php
Hunk #1 FAILED at 50.
1 out of 1 hunk FAILED -- saving rejects to file auth/ldap2/cli/sync_users.php.rej
patching file auth/ldap2/lang/en/auth_ldap2.php
patching file auth/ldap2/ntlmsso_attempt.php
Hunk #1 FAILED at 2.
1 out of 1 hunk FAILED -- saving rejects to file auth/ldap2/ntlmsso_attempt.php.rej
patching file auth/ldap2/ntlmsso_finish.php
patching file auth/ldap2/ntlmsso_magic.php
patching file auth/ldap2/version.php

 

any idea ?

 

Thanks for your help

Ouahib 

In reply to ouahib gebraltar

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Maybe you are using a slightly more recent 2.3 version than the one I used to produce the patches. And those 3 files are slightly different so the patch doesn't apply cleanly. If you tell me your exact Moodle version (the $vesion number from version.php file) I could have a look at it.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ouahib gebraltar -

Hi Inaki,

  Thanks for your feedback,  the version number I found in the file version.php is 2012061700

 

Thanks

Ouahib

In reply to ouahib gebraltar

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I have just tried with that version (which by the way is an alpha version before 2.3 stable came out; you should really upgrade it to latest stable 2.3 version) and it has worked as expected.

I reset my installation back to the default original files and executed the "php -f ldapname.php ldap2" command without previously applying the 0001-... patch file and I got exactly the same errors as you. So I highly suspect you simply didn't apply the patch (maybe you executed patch in 'simulate' mode, using --dry-run option).

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ouahib gebraltar -

Hi Iñaki,

  Thanks for your feedback, I will try your proposal by upgrading to the stable version of 2.3. 

I have actually applied the patch first before excuting the comand  "php -f ldapname.php ldap2" and I didn't use the "simulate" mode. 

 

Anyways. I will let you know. 

Thanks

Ouahib 

 

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Imran Hussain -

Hi,

I am having difficulty in applying the patch to the folders using GnuWin32 & cmd.

Is it possible you could send me the patched folder for ldap2 so that I can stick it into the folder path auth/

I would really appreciate it, many thanks.

In reply to Imran Hussain

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi,

which exact Moodle version are you using (please, cite the version numbers from version.php, as each version can have slight changes from one each other smile)

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Imran Hussain -

Hi,

This is taken from version.php

Moodle Version:

version  = 2012120303.04
release  = '2.4.3+ (Build: 20130405)'

PHP Version: 5.3.10

I did try to patch the files yesturday, first two patches were fine (.patch & .diff) but the php patch did not work. sad 

In reply to Imran Hussain

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Imran,

your version of Moodle is a bit newer that the one I used to create the patch for 2.4, and has a couple of bug fixes that weren't present before. That's why the patches might not apply cleanly. I've created a new version of the patch that should apply cleanly if you follow the instructions given at https://moodle.org/mod/forum/discuss.php?d=74279#p752238

Hope that helps.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Imran Hussain -

Hi Iñaki,

The patch worked a treat. I can now have both staff & student login using the LDAP auth.

Thank you for your time and effort in helping me and others achieve what was required.

Kind Regards.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Cristian Zanni -

Hey Iñaki,

it is possible to download some patch to the Moodle 2.1 Version?

Thanks  / Gracias!

Cristian

 

In reply to Cristian Zanni

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't have a patch for 2.1 yet.I'll see if I can make one in a reasonable amount of time.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Cristian Zanni -

Nevermind Iñaki, we achieved this by using the folder provided by Flavio Camargo; patch was not needed!

https://moodle.org/pluginfile.php/183/mod_forum/attachment/874648/ldap2.rar

Anyway, i want to appreciate your help here and also make a little contribution: In our scenario, we faced a domain migration. So, some users were migrated from domainA to domainB.

After we applied this workaround (duplicate ldap plugin) we had to UPDATE the "auth" field at mdl_user table of every migrated user by replacing "ldap" to "ldap2" (or the name you used in the second ldap plugin).

This is because the moodle users table were previously populated with the ldap "original" plugin. New users at domainB were able to login smoothly

Cheers!

Saludos!

Cristian

 

 

 

 

 

 

In reply to Cristian Zanni

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Glad that you didn't need it smile

I had a little spare time today and produced the patch anyway (it was very easy starting from the patch for 2.0.x).

So here it goes in case someone else needs it wink

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Anthony Connor -

Hi Iñaki,

I am using version 2.4.4+ (Build: 20130621), maturity = MATURITY_STABLE;

PHP version 5.3.10.

Could I use the patch for 2.4.3 ( ldap-clones-patch-scriptv8b_2.4.3.zip) or will it not work. If so any chance you would be able to updating the patch for this version?

It would be brilliant if you could help me out of this jam, many thanks,

Anthony

In reply to Anthony Connor

Re: How to use multiple LDAP servers with Moodle 1.8

by Anthony Connor -

Hi again,

So I decided to try the 2.4.3 ( ldap-clones-patch-scriptv8b_2.4.3.zip) patch on the moodle version 2.4.4+ (Build: 20130621) that I am running and it worked.

I first tried the patch in a test environment - a 32bit ubuntu server (php 5.4.3) and it patched correctly and I was able to successfully edit the LDAP connection settings, enable the new LDAP connection type and login to moodle using valid AD accounts over LDAP.

Thanks for the patch Iñaki. smile

Anthony

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi there,

in case anyone is interested on it, here's the patch for Moodle 2.5.x (current as of today).

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Kester David -

Thanks a Mil! Iñaki

 

Works perfect!

In reply to Kester David

Re: How to use multiple LDAP servers with Moodle 1.8

by Lee Procter -

Hi Iñaki,

The patch you have created is an excellent solution and works a treat.

Will there be a update file to support version 2.5.2+ (Build: 20131101) any time soon. We are looking to upgrade very shortly.

 

Lee

 

 

In reply to Lee Procter

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Lee,

this version should apply cleanly to 2.5.2+ current as of today, and 2.5.3+ current as of today.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Lee Procter -

Hi Inaki,

I have tested the patch on ver 2.5.2 but get the following output on the first patch:

patching file auth/ldap/auth.php
patching file auth/ldap/cli/sync_users.php
patching file auth/ldap/config.html
Hunk #3 FAILED at 187.
1 out of 14 hunks FAILED -- saving rejects to file auth/ldap/config.html.rej
patching file auth/ldap/ntlmsso_attempt.php
patching file auth/ldap/ntlmsso_finish.php
patching file auth/ldap/ntlmsso_magic.php
patching file auth/ldap/version.php

 

Any ideas? Thanks in advance

 

In reply to Lee Procter

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Lee,

the patch if for 2.5.2+ (Build 21031101) or later, not for 2.5.2 (Build: 20130909). There's no point in running 2.5.2 when 2.5.2+ is out fixing a few bugs (and not introducing new features). That's why I cooked the patch for 2.5.2+.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Karl Brooker -

Hi Inaki,

Do you plan an update for version 2.6? I've just built a fresh 2.6 box and wondered if I should wait or just try the 2.5.2+ patch.

Regards,
Karl

In reply to Karl Brooker

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Karl,

here's a version for 2.6+ (Build: 20131129), current as of today.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Ernesto Perez -

hi Iñaki Arenaza

I hope you can help me, I'm working with Moodle 2.6 + on windows with wamp. I installed patch.exe but I get the following error when running the. patch

with the instruction of. php no problem, if the directory is generated LDAP2 moodle me but when I open the problem appears.

The "auth_ldap2" plugin is installed in the wrong location "$ CFG-> dirroot/auth/ldap2", the expected location is "$ CFG-> dirroot / auth / ldap"

How I can install the. Patch on windows?

 

In reply to Ernesto Perez

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Ernesto,

make sure you follow the right instructions to apply the patch on Windows, as I said earlier in this thread: https://moodle.org/mod/forum/discuss.php?d=74279#p752740

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Ernesto Perez -

Thanks Iñaki

I set up moodle on Ubuntu and I had no problems to clone ldap, I have two domains with organizational units are around 200 each domain. the detail that I have now is that it takes a long time to authenticate a user. as I can do to make it faster reading's site. as I can change the page size to change the value default is 250. the type of encoding that uses my server is utf-8, version 3.

I hope you can help me thanks in advance!

In reply to Ernesto Perez

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Ernesto,

I'm afraid I don't understand what your problem is and why you want to change the page size (which doesn't affect the login time at all).

Could you elaborate it a bit?

Saludos.
Iñaki.

P.S. I speak Spanish, in case you feel you can describe your problem more easily in Spanish smile
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Alan Hare -

Iñaki,

I tried using your patch ldap-clones-patch-scriptv10_2.5.2 on moodle_2.5.3+_build_20131115 from 11th Nov 2013, but does not work.

  • patch.exe --dry-run -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch
  • Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

Thank you for your assistance! smile

In reply to Alan Hare

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Alan,

If you are trying to use these patches on Windows (and it looks like you are using Windows, judging from your patch.exe command smile), make sure you follow the instructions given in this page: http://docs.moodle.org/en/Development:How_to_apply_a_patch#Apply_a_Patch_in_Windows_using_gnuwin32

Saludos.
Iñaki.


In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Alan Hare -

You are correct, I was using the wrong command/file.  :/

When I run the correct file ldapname.diff accoring to the Windows directions I get this

Am I missing something?

In reply to Alan Hare

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Alan,

you were using the right file, but the wrong procedure (for Windows). The problem is the patch file (0001-bla-bla-bla.patch) has Unix line endings. And patch.exe for Windows doesn't like them (that's why you got an assert failure). You need to convert the Unix line endings to Windows line endings before trying to apply the patch.

That's why the instructions on how to apply a patch on Windows tells you to "Open the patch file with Wordpad, and click 'File' >> 'Save as...', choose a different name for the file eg ('mynewpatch.diff') and "Save as type" >> 'Text Document - MS-DOS Format' " (in the link I provieded before).

Saludos. Iñaki

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Alan Hare -

Hi Iñaki, Thanks for the reply! smile

I changed the file format as directed in the document, but I still receive an error. 

In reply to Alan Hare

Re: How to use multiple LDAP servers with Moodle 1.8

by Alan Hare -

UPDATE: I went line by line for the config.html section of the patch file and changed it.. they all matched.  Then I was able to run the command "php -f ldapname.php ldap2" to make the duplicate copy of the plugin.

Does the line # error for the patching, does it match up directly to the orignal file being patched?  If so.. for this instance it's a blank like.  I am quite curious what the issue was though.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Jamie Kramer -

Hi Iñaki. Thanks for providing this to the community.

I have a suggestion for making this work better on a Mac.

At about line 47 of ldapname.php you have:

} elseif (stristr(PHP_OS, 'win')) {

This causes the script to detect the running os on a Mac as windows and as such, attempts to use the xcopy command. The reason is that PHP_OS on a mac gets set to Darwin.

I added simple logic so now it looks like this:

if (stristr(PHP_OS, 'Darwin')) {

        system('cp -a "'.$ldap_orig.'" "'.$ldap_new.'"');

} elseif (stristr(PHP_OS, 'win')) {

        $ldap_orig = str_replace('/', '\\', $ldap_orig);

        $ldap_new = str_replace('/', '\\', $ldap_new);

        $ldap_orig_langfile = str_replace('/', '\\', $ldap_orig_langfile);

        $ldap_new_langfile = str_replace('/', '\\', $ldap_new_langfile);

        $patch_file_orig = str_replace('/', '\\', $patch_file_orig);

        system('xcopy "'.$ldap_orig.'" "'.$ldap_new.'" /S /E /I');

} else {

        system('cp -a "'.$ldap_orig.'" "'.$ldap_new.'"');

}

 

Regards,

 

Jamie

 

In reply to Jamie Kramer

Re: How to use multiple LDAP servers with Moodle 1.8

by Jamie Kramer -

Also, there is a problem when upgrading a site from say, 2.4 to 2.5. The ldapname script does not seem to set the new ldap name in db/upgrade.php. It is easy enough to fix in the cloned plugin, just by updating db/upgrade.php and replacing ldap with the name of your cloned ldap plugin.

In reply to Jamie Kramer

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Jamie,

thanks a lot for your feeback! I have updated the patches for 2.5, 2.6 and master (current as of today). I didn't notice that from 2.5 onwards db/upgrade.php was used, so my patch missed it. I've also added code to detect Darwin as a Unix platform using the same test code that Moodle uses elsewhere.

I'm going to upload the zip files with the patches in separate posts, as there's a limit of two attachments per post (and to make it clearer which zip file corresponds to which Moodle version).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is the updated version of the patch for master 2.7dev (Build: 20140307) or later.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is the updated version of the patch for master 2.8dev (Build: 20140529) or later.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Wolfgang Hollauf -

Dear Inaki

Build: 20140529 works quite fine in moodle 2.7+ stable version!!! smile

Very nice job!!!!

thank you very much!

wolfgang

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ashley savage -

good morning, having troubles with this updated patch as-well, tried both and both failed... just crashes patch.exe "This application has requested the Runtime to terminate"... I'm running windows 2008 R2 server MSSQL and IIS 7.5


thanks for all you work on this... been running great with moodle 2.5 and your older patches...


ash 

In reply to ashley savage

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Ashley,

make sure you follow the instructions from http://docs.moodle.org/dev/How_to_apply_a_patch#Apply_a_Patch_in_Windows_using_gnuwin32

I create the patches on Linux, and the Windows version of patch has a tendency of blowing up when dealing with files using Linux/Unix line endings.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ashley savage -

gday and thanks for your reply, yeah must be doing something wrong... now getting

C:\moodle>patch.exe --dry-run -p1 < ldapname.diff

can't find file to patch at input line 4

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|diff -urN auth/%%LDAPNAME%%/auth.php auth/%%LDAPNAME%%/auth.php

|--- auth/%%LDAPNAME%%/auth.php 2012-12-10 17:02:03.375012706 +0100

|+++ auth/%%LDAPNAME%%/auth.php 2012-12-10 17:02:31.139150376 +0100

--------------------------

File to patch:


can you shed any light ????


thanks again for all your work...

ash

In reply to ashley savage

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Ashley,

see this post earlier in this same forum thread: https://moodle.org/mod/forum/discuss.php?d=74279#p752238 smile

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by ashley savage -

thanks again for all your help, but no love with windows... got the patch.exe working, but now just come up asking for "file to patch" 

thanks again

will keep trying


ash

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Wolfgang Hollauf -

Hi Inaki,

i have installed moodle 2.7+ stable and tried out your version 14 and 15 (2.7dev and 2.8dev) -> both are not working!? sad do you have a version for teh stable 2.7+


best

wolfgang

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is the updated version of the patch for 2.7+ (Build: 20140529).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Miika Lippojoki -

Hello Iñaki,


We were upgrading our Moodle to 2.7+ and found your ldap plugin(version 16_27+) very useful when working with multiple domains at our environment. Thank you for the excellent work!

However, we found out that when adding multiple domains to work with, you cannot use upper case letters when naming the ldap plugins with the command php -f ldapname.php.

For example, we tried to make plugin called ldapSCHOOL with command "php -f ldapname.php ldapSCHOOL" and the result was that the folders were created to filesystem but in Moodle the plugin never showed up to the Notifications -page under Site Administration.

After we changed the ldapname to ldapschool, everything worked as it should.

Do you have any idea what was causing this?


Yours,


Miika Lippojoki
ICT-coordinator
Kainuu Vocational College, Finland

In reply to Miika Lippojoki

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Miika,

I know this answer is a bit late, but the problem is has strict rules on how to name plugins. And they are stricted than I thought they were (it seems the developers made them stricter around Moodle 2.2 but I didn't notice, and didn't update my patch to take them into account).

Currently plugin names can only contain lowercase ASCII letters, numbers and underscores (but numbers and underscores are strongly discouraged by Moodle developers!). And the plugin name must start with a lowercase ASCII letter.

That's why your copy of the plugin didn't show up in the Notifications page: it wasn't considered a valid plugin name, and thus it was completely ignored.

I have update the patch scripts to comply with the rules and reject any plugin name that would be considered invalid by Moodle.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Here are the (updated) patches for Moodle 2.7.3+ and 2.8.1+ current as of today. They already have the stricter plugin name validation rules added.

Saludos.
Iñaki.
Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Domenic Silletti -

Hi,

I tried running the patch for 2.6.2 on a 2.6.5 system (OS is RedHat 6, 64bit) and got numerous "Hunk" errors; is there a specific patch for my system or is there another one I should be using?

Thanks,

Domenic

In reply to Domenic Silletti

Re: How to use multiple LDAP servers with Moodle 1.8

by Domenic Silletti -

Update, I ran the 2.6.2 patch again on my system and it ran with no issues.  I now have my Moodle talking to 2 different Active Directory Domains.

In reply to Iñaki Arenaza

Tárgy: Re: How to use multiple LDAP servers with Moodle 1.8

by Tamas Mako -

Hi Inaki

I'm using Moodle 2.8.3+ (Build: 20150205) system. I need a multiple LDAP because I have to authenticate from two different domain. I installed your script and the patch process worked fine and I created ldap2 (auth/ldap2). I added correctly to authentication method as well and then I encountered in a weird problem, when I try to login:

Ldap: I can see this address  /auth/ldap/ntlmsso_attempt.php

Attempting Single Sign On via NTLM...

/auth/ldap/ntlmsso_finish.php

Auto-login failed, try the normal login page...


Ldap2: I can see this address  /auth/ldap2/ntlmsso_attempt.php

Attempting Single Sign On via NTLM...

/auth/ldap/ntlmsso_finish.php

Auto-login failed, try the normal login page...

I can see just this running login proccess continuously and I cannot reach the normal login page,


Do you have any idea what caused this problem?

I attached a pic about my auth manager window I think the user don't appear in ldap2 auth.

Kind Reagards
Tom

Attachment moodleldap.png
In reply to Tamas Mako

Re: Tárgy: Re: How to use multiple LDAP servers with Moodle 1.8

by Michael Lynn -

When I tested this on Totara 2.7.6 (Moodle 2.7.9) if NTLM is enabled the problem is in ntlmsso_finish.php

It reaches an end state here:

// If ntlmsso_finish() succeeds, then the code never returns,
// so we only worry about failure.
if (!$authplugin->ntlmsso_finish()) {

// code to redirect with error code

}

I changed my code to then attempt a connection on ldap2.

if (!$authplugin->ntlmsso_finish()) {

     // My Change. try ldap2.
    redirect($CFG->httpswwwroot . '/auth/ldap2/ntlmsso_attempt.php');

}

In ldap2/ntlmsso_finish.php it tries ldap3/ntlmsso_attempt.php etc.

 

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Here are the (updated) patches for Moodle 2.7.7+ and 2.8.4 (that applies cleanly on 2.8.4+ and 2.8.5+ too) current as of today.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Waku Worldrings -

Hola Iñaki, tengo un problema en Moodle 2.8.5, el script funciona y me duplica el plugin, hasta ahí todo perfecto (bajo centOS).

Me sale esto:


sh: patch: no se encontró la orden


El problema viene que me sale un mensaje de actualizar la base de datos de moodle y al hacerlo me da un error:


La extensión "auth_ldap" está instalado en la ubicación incorrecta "$CFG->dirroot/auth/ldap2"; la ubicación prevista es "$CFG->dirroot/auth/ldap"

Más información sobre este error

Debug info: 
Error code: detectedmisplacedplugin
Stack trace:
  • line 450 of /lib/upgradelib.php: plugin_misplaced_exception thrown
  • line 1626 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 434 of /admin/index.php: call to upgrade_noncore()

In my bad English:

when i run your script, i get some errors, the first is "sh: patch: command not found"


And later when i enter to administration panel of moodle, a message appears whit the error that i have posted above.


Thank you for your free support to all us Iñaki.


Edito /edit:


He instalado patch y me da el siguiente error

i have instaled patch and now i have this error:


Hunk #1 FAILED at 25.

1 out of 1 hunk FAILED -- saving rejects to file auth/ldap2/version.php.rej

In reply to Waku Worldrings

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hola Waku,

¿qué versión exacta de Moodle tienes? (la puedes encontrar en el fichero version.php). Es para intentar reproducir el problema (ya que dependiendo de la versión, puede haber más o menos cambios en el área que toca el parche).

English version:

What exact Moodle version do you have? (you can find that our in version.php file). This will help me reproduce the problema (depending on the Moodle version, there can be more or less changes in the area affected by the patch)

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Waku Worldrings -

ante todo, Muchas gracias por responder y querer ayudarme.

El archivo php contiene lo siguiente:


defined('MOODLE_INTERNAL') || die();


$version  = 2014111005.00;              // 20141110      = branching date YYYYMMDD - do not modify!

                                        //         RR    = release increments - 00 in DEV branches.

                                        //           .XX = incremental changes.


$release  = '2.8.5 (Build: 20150310)'; // Human-friendly version name


$branch   = '28';                       // This version's branch.

$maturity = MATURITY_STABLE;             // This version's maturity level.


Muchas gracias.

In reply to Waku Worldrings

Re: How to use multiple LDAP servers with Moodle 1.8

by Waku Worldrings -

El problema que no me había modificado el archivo versions.php, lo he modificado a mano cambiando $plugin->component = 'auth_ldap'; 

a $plugin->component = 'auth_ldap2'; 


Ese era el problema en mi caso, un saludo.

In reply to Waku Worldrings

Re: How to use multiple LDAP servers with Moodle 1.8

by Anthony Cascianelli -

Does anyone know if this patch works for Moodle 2.9+?

In reply to Anthony Cascianelli

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you use the attached file, it should smile

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Nicolas REI -

Hello Inaki,


Thank's for your Patch.

I use this patch on mooble created by Bitnami and server 2012 R2.

My problem is the same of Pandiarajan : Error1.jpg


And no solution in this page.

If you have and idea...

Sorry for my English :/


Server 2012R2 Moodle 2.9.1 Patch 2.9+

Merci ;)

Nicolas

Attachment Error1.JPG
In reply to Nicolas REI

Re: How to use multiple LDAP servers with Moodle 1.8

by Nicolas REI -

Hello,

i have the solution, just not good format for the patch, now it's good, thank you.


Nico

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Wendy Gordon -

Hello Iñaki

Thank you for such a great patch. Has a version been done for 2.8.7.

Gracias

In reply to Wendy Gordon

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Wendy,

this version should work with 2.8.7+ (Build: 20150820).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It seems I forgot to include ldapname.diff in the previous .zip file (thanks Wendy for the heads up!).

This new .zip file includes all the necessary files.

Saludos
Iñaki.
Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Daniel Velazquez -
Hi iñaki my Moodle version it's 2.8.7+ I make all the instructions but when I tried to save de changes in the new server LDAP I can't, Here all the details about versión of my Moodle.

defined('MOODLE_INTERNAL') || die();


$version  = 2014111007.02;              // 20141110      = branching date YYYYMMDD - do not modify!

                                        //         RR    = release increments - 00 in DEV branches.

                                        //           .XX = incremental changes.


$release  = '2.8.7+ (Build: 20150716)'; // Human-friendly version name


$branch   = '28';                       // This version's branch.

$maturity = MATURITY_STABLE;             // This version's maturity level.

Saludos.


In reply to Daniel Velazquez

Re: How to use multiple LDAP servers with Moodle 1.8

by Noveck Gowandan -

Good day fellow Moodlers,

Are there any plans to port this mod over to Moodle 3?

Thanks for all that you guys do!

Regards,
Noveck

In reply to Noveck Gowandan

Re: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I just copied over the cloned folder and it is running just fine on 3.0.

In reply to Noveck Gowandan

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Noveck,

The attached patch applies cleanly to 3.0.1, 3.0.2 and 3.0.3 (current as of today). And with some offset warnings to 3.0 (but still working ok).

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It seems a small bug slipped in the previous version of the patch fro 3.0.x. It's harmless if you only create a single additional LDAP auth plugin clone, but it screws things up if you use more than one.

The attached .zip file fixes the bug.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Saravanan PP -

Dear Iñaki,


I have tried this version (ldap-clones-patch-script_3.0+_v2.zip) in my moodle server version 3.0. I am getting the following error when I try this patch.


[E6320@Qmoodles moodle_30]$ php -f ldapname.php ldaptmtl

!!! <p>Error: database driver problem detected</p>

<p>The site administrator should verify server configuration</p><p>PHP has not been properly configured with the MySQLi extension for it to communicate with MySQL. Please check your php.ini file or recompile PHP.</p> !!!


My moodle application is working fine without this MySQLi extension moodle will not function.


Kindly help


Regards,

Saravanan P

In reply to Saravanan PP

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Saravanan,

the error is probably due to the PHP command line interface configuration (php.ini) being different than your PHP web server module configuration (they sometimes use different configuration files for each of them).

Make sure you use the same configuration settings in both cases, and that you execute the command at the top of your Moodle installation directory.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Michael Lynn -

Hi Iñaki,

Just to let you know that ldap-clones-patch-scriptv16_27+.zip works perfectly with Totara 2.7.6 (Moodle 2.7.9). Thank you!

Regards,

Michael.

 

In reply to Michael Lynn

Re: How to use multiple LDAP servers with Moodle 1.8

by Tomas De Amos -

Hi Iñaki.

First of all I want to thank you for your contribution.

I am using Moodle 3.1 and was able to apply the patch.

The additional auth plugin was generated and I was able to install it, activate and configure it.

The issue I`m facing now is that I am not sure if I need to add a scheduled task for this in order to syncronize. When I execute the cron job I only see messages for the first original plugin, but not from the second one added. Is this task necesarry? If yes, How can I add it?

In Scheduled tasks I only see this:

LDAP users sync job \auth_ldap\task\sync_task

This is what I see on cron execution:

Execute scheduled task: Trabajo de sincronización de usuarios LDAP (auth_ldap\task\sync_task)
... started 19:59:10. Current memory use 20.5MB.
Conectando con el servidor LDAP ...Creando la tabla temporal tmp_extuser..Obtenidos 2 registros de LDAPNo hay actualizaciones disponiblesNo hay entradas de usuarios para agregar... used 8 dbqueries
... used 0.56359791755676 seconds
Scheduled task complete: Trabajo de sincronización de usuarios LDAP (auth_ldap\task\sync_task)

Am I missing any configuration?

Thanks in advance for your help.

Tomas.

In reply to Tomas De Amos

Re: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Yes, your duplicated ldap plugin will not be run through scheduled tasks.  You will need to set up a separate cron job on your server if you want it to sync automatically.

In reply to Emma Richardson

Re: How to use multiple LDAP servers with Moodle 1.8

by Tomas De Amos -

Thanks Emma for your prompt reply.

Excuse me for my ignorance: Can you point me to a document which specifies the steps to set up a separate cron job?

Regards.

Tomas.

In reply to Tomas De Amos

Re: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

That would depend on your server...at some point, you set up a cron job that pointed to admin/cli/cron.php or something similar.  Now you need add another line to that pointing to the sync.php or sync_users.php in your duplicated ldap plugin.

In reply to Emma Richardson

Re: How to use multiple LDAP servers with Moodle 1.8

by Tomas De Amos -

Thanks again Emma.

With your instructions I was able to execute the sincronization script directly from cli folder of the new LDAP plugin that I had generated.

Regards.

Tomas.

In reply to Tomas De Amos

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Tomas,

you are not missing any configuration, as Emma has pointed out.

On the other hand, it turns out that I didn't notice that the patch was failing to take into account the new scheduled tasks sub-system files. So the scheduled tasks were not being created for the cloned plugins.

I have updated the patch to take that into account. Bear in mind that the cloned plugin scheduled tasks are only created during plugin installation (that's the way Moodle behaves, not something patch-specific). So this won't benefit existing users much (unless you backup your cloned plugin settings, uninstall it, re-install it and restore your plugin settings).

I'm attaching updated patches for Moodle 3.1+ (current as of today), and Moodle master. I'll upload and update version for Moodle 3.0+ in a few hours.

Saludos.
Iñaki.
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Tomas De Amos -

Thanks for your help Iñaki !

Regards.

Tomas.

In reply to Tomas De Amos

Re: How to use multiple LDAP servers with Moodle 1.8

by Michael Lynn -

We are successfully using the clone script with Totara 2.7.6 (Moodle 2.7.9). It works really well.


A problem we have is that sometimes users have duplicate names in the different domains:

Example (names anonymised):

ldap - domain1\jsmith1 (Jonathan Smith)

ldap2 - domain2\jsmith1 (James Smith)

Jonathan Smith logs in and their account in Moodle is created.

When James Smith comes along their account isn't created in Moodle and they are logged in as Jonathan Smith.


This is because the username must be unique.

Question 1:

Am I right in saying that there is no way to map or modify the username created to include some other attribute e.g. country code in the Moodle username?

It might solve the problem if the username was generated with the country code as a prefix:

e.g. uk_jsmith1, us_jsmith1 etc.

We are using NTLM so the username is derived from SAMAccountName.


I can't see how we could even customise the authentication plugin because in auth.php in user_signup() $user->username is already populated with no access to other properties such as countrycode (mapped to c in the Active Directory attributes).


In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

I'm a bit behind the promised schedule wink, but here go updated patches for Moodle 3.2 and Moodle master, current as of today.

I'll send patches for Moodle 3.0+ and Moodle 3.1+ in a second message, as I can't attach more than two files per message in this forum.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi again,

here are the updated patches for Moodle 3.0+ and Moodle 3.1+.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Kimmo Kiiskinen -
Hi

the 3.1-script seems to be causing some errors with Moodle 3.1.6:

1 out of 14 hunks FAILED -- saving rejects to file auth/ldap/config.html.rej
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Darren Biggs -

Hi Inaki

Your excellent work with the LDAP clones plugin has helped me a lot of the last year or so. I was wondering if you'd had a chance to create a new plugin for Moodle 3.2.2? I've tried the ldap-clones-patch-script_3.2_v1.zip and get the errors in the attached file.

Thanks

Darren


In reply to Darren Biggs

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Darren,

here's an updated version for Moodle 3.2.2+ (Build: 20170316). It also applies cleanly to 3.2.2 (Build: 20170313).

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Darren Biggs -

Hi Inaki

That's is fantastic, thank you very much for your help. You are a life saver.

Thanks

Darren

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Anthony Rimmer -

Hi Iñaki,

I've sent you a PM about this as well, but is there a possibility of a 3.3 patch?

It looks like everything has changed with the LDAP plugin in this release. Has anyone else encountered issues?

Kind regards, 

Anthony

In reply to Anthony Rimmer

Re: How to use multiple LDAP servers with Moodle 1.8

by Mónica Puig-Pey -

Hi Anthony, 

I'm trying to apply this patch por Moodle 3.3 using he latest I found: ldap-clones-patch-script_3.2.2_v2, and I'm having the next message:

patching file auth/ldap/auth.php
Hunk #42 FAILED at 1827.
Hunk #43 FAILED at 1989.
Hunk #44 succeeded at 1828 (offset -180 lines).
Hunk #45 succeeded at 1837 (offset -180 lines).
Hunk #46 succeeded at 1884 (offset -180 lines).
Hunk #47 succeeded at 1993 (offset -180 lines).
Hunk #48 FAILED at 2223.
Hunk #49 succeeded at 2065 (offset -198 lines).
3 out of 49 hunks FAILED -- saving rejects to file auth/ldap/auth.php.rej
patching file auth/ldap/classes/task/sync_task.php
patching file auth/ldap/cli/sync_users.php
can't find file to patch at input line 608
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/auth/ldap/config.html b/auth/ldap/config.html
|index 883eb9d0b52..084dd592d9a 100644
|--- a/auth/ldap/config.html
|+++ b/auth/ldap/config.html
--------------------------
File to patch:

Could you solve it? thanks in advance, 

Regards, 

Monica


In reply to Mónica Puig-Pey

Re: How to use multiple LDAP servers with Moodle 1.8

by Anthony Rimmer -

Hi Monica,

I wanted to reply as you directed your message at me.

It's not something I would be able to help you with, but hopefully Iñaki or another can.

It looks like the settings.php file in 3.3 has superseded the config.html file in lesser versions, which is why the patching is failing. There is no config.html file anymore.

Anthony

In reply to Anthony Rimmer

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi,

I've been unable to get some spare time to work on this, but I finally managed to have some smile

Here are a couple of versions, one for 3.3, a second one for 3.3.1 (this one applies to 3.3 with just a warning about a single hunk, but i decided to create a separate one for 3.3).

Hope this helps.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Mónica Puig-Pey -

Hi Iñaki, 

Thank very much for your time and the new version patch, it's going to be very useful for our site.

I've seen a small mistake I think: in version 3.3.1, at ldapname.diff you are using ldap2 instead of '/auth/'.$this->authtype.'...', so you get an error if you use a different name of ldap2 for the new ldap.

Thanks again, un saludo

Mónica

Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Dom Northeast -

Hi Iñaki.,

Thank you for a most useful addition to Moodle, I have been using it successfully for the last couple of years. 


I hope you can assist. I recently upgraded our Moodle to 2.9+ (Build: 20150604) and have attempted to apply your 2.9+ patch but am coming up with a patch error as attached. The server is Centos 6.7. 

Kind Regards

Dominique Northeast




In reply to Dom Northeast

Re: How to use multiple LDAP servers with Moodle 1.8

by Dom Northeast -

Hi Iñaki,

Please ignore my previous request for assistance. I have figured out what I was doing wrong (my own fault as might be expected). I simply needed to cd to the moodle root directory before applying the patch. Once done the patch installed fine.

I had bit of a conflict with the installed version; I was getting a database upgrade error saying:

auth_ldap2

Cannot downgrade auth_ldap from 2015051100 to 2014111001.


However, once I modified the version dates in /auth/ldap2/db/upgrade.php from the older date to the newer, it installed fine and is working as perfectly as ever.


Regards

Dominique Northeast

Average of ratings: Useful (1)
In reply to Flávio Camargo

Re: How to use multiple LDAP servers with Moodle 1.8

by Paul Hulse -

Using this method, how do you add another ldap server. Where do I need to go in and change the name in the files. Thanks

In reply to Paul F

Ynt: How to use multiple LDAP servers with Moodle 1.8

by Arda Cetin -

Hello there,

I used this patch. Thanks firstly. I use Moodle 3.3.1 and I patched successful with no errors but i did not work.

I checked Authentication and Notification pages but there is no something new. What am I missing?


# patch -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch

patching file auth/ldap/auth.php

patching file auth/ldap/classes/admin_setting_special_ntlm_configtext.php

patching file auth/ldap/classes/task/sync_task.php

patching file auth/ldap/cli/sync_users.php

patching file auth/ldap/db/upgrade.php

patching file auth/ldap/ntlmsso_attempt.php

patching file auth/ldap/ntlmsso_finish.php

patching file auth/ldap/ntlmsso_magic.php

patching file auth/ldap/settings.php

patching file auth/ldap/version.php

root@moodle:

In reply to Arda Cetin

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

So you have a new folder in your auth folder?  Did you check permissions and ownership?

Average of ratings: Useful (1)
In reply to Emma Richardson

Ynt: Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Arda Cetin -

Thank you reply. I just check the permissions but I can see no problem about the permissions.


In reply to Arda Cetin

Re: Ynt: Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

That is the moodle folder - what about inside the auth folder?  Also, normally ownership should be www-data or apache user, not root...

In reply to Arda Cetin

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Arda,

the process has two steps, and you have apparently only performed the first one. Have a look at the instructions I gave here: https://moodle.org/mod/forum/discuss.php?d=74279#p737972

Two comments with respect to the original instructions:

  1. The new auth plugin name must follow the plugin names' rules, .i.e, it must start with a lowercase letter and only contain lowercase letters and numbers. The ldapname.php script checks for that before trying to create the new auth plugin.
  2. NTLM has been tested and known to work for some time now.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Wolfgang Hollauf -

Dear all,


would you be so kind and create the "ldap2" plugin for version 3.3.2 and provide it here (as zip download) - i have some troubles with the patch sad


Thanks you!

In reply to Wolfgang Hollauf

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Wolfgang Hollauf -

Finally i was able to run the script successfully and create ldap2 smile 


please find attached the plugin (works for 3.3.1 and 3.3.2)



Average of ratings: Useful (1)
In reply to Wolfgang Hollauf

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks for sharing!  Glad you were able to make it work.

In reply to Wolfgang Hollauf

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

And here's a version for Moodle 3.4.

I've changed the way I maintain the patches, which means the way to apply them has changed a bit. Now we just need to perform single step: executing ldapname.php

php ldapname.php ldap2

(substitute ldap2 with the new plugin name you want to use).

Saludos.

Iñaki.

Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Mónica Puig-Pey -

HI Iñaki, 

I had your patch working fine for Moodle 3.3 until today. It was really useful for our site.

Now I'm trying to update my second ldap for Moodle 3.4.

But your latest patch isn't working to me. It fails at .../auth/myldap/settings.php 

You can see the errors at the file joined. I've tried but it's impossible for me to understand anything of the file sad

After executin ldapname.php it returns:

patching file auth/ldap_paspdi/settings.php

Hunk #3 FAILED at 171.

Hunk #4 succeeded at 260 (offset 12 lines).

Hunk #5 succeeded at 299 (offset 12 lines).

1 out of 5 hunks FAILED -- saving rejects to file auth/ldap_paspdi/settings.php.rej


I would thank you very much if you could watch it.

Sorry and thanks again.


Mónica


In reply to Mónica Puig-Pey

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Mónica,

what exact Moodle version are you trying to patch? (please provide the values from version.php). Minor versions sometimes include fixes for the LDAP plugin and my patches break.

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Mónica Puig-Pey -

Sorry for the delay Iñaki,

I've seen version.php its says:

$version  = 2017111300.08;              // 20171113      = branching date YYYYMMDD - do not modify!

                                        //         RR    = release increments - 00 in DEV branches.

                                        //           .XX = incremental changes

$release  = '3.4+ (Build: 20171222)'; // Human-friendly version name


Thanks in advance, 

Un saludo, Mónica

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Alejandro Castillo Andrade -

does anyone know what do I need to change to point my ldap2 to the correct tables? if I change my Ip on ldap it changes the ip for ldap2

In reply to Alejandro Castillo Andrade

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Did you use the patch to create the second instance?  If you did it correctly, you will have a second settings page that you can set up.

In reply to Emma Richardson

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Alejandro Castillo Andrade -

I used the patch for moodle 3.4_v1  and it creates the folder but when I configure the plugin , it replaces the content of my first ldap server, also I checked the the database and in mdl_config_plugin the installation just creates version and installrunning tables, the patch 3.4_v3 doesn't work, I have the version $release  = '3.4.6+ (Build: 20181201)';

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Joan Luis Pérez -

Hi Iñaki,

We've tried to apply the patch for Moodle3.1.7 (version: 2016052307.00 - release: 3.1.7 (Build: 20170710))

We've applied the files that are in the folder ldap-clones-patch-script_3.1+_v3.zip and the fail that we obtains is:

root@server1:/var/www/html/moodle# patch -p1 < 0001-Add-support-for-multiple-clones-of-the-LDAP-auth-plu.patch

patching file auth/ldap/auth.php

patching file auth/ldap/classes/task/sync_task.php

patching file auth/ldap/cli/sync_users.php

patching file auth/ldap/config.html

Hunk #1 FAILED at 112.

Hunk #2 succeeded at 177 (offset 22 lines).

Hunk #3 succeeded at 219 (offset 22 lines).

Hunk #4 succeeded at 278 (offset 22 lines).

Hunk #5 succeeded at 318 (offset 22 lines).

Hunk #6 succeeded at 411 (offset 22 lines).

Hunk #7 succeeded at 423 (offset 22 lines).

Hunk #8 succeeded at 440 (offset 22 lines).

Hunk #9 succeeded at 457 (offset 22 lines).

Hunk #10 succeeded at 514 (offset 22 lines).

Hunk #11 succeeded at 525 (offset 22 lines).

Hunk #12 succeeded at 542 (offset 22 lines).

Hunk #13 succeeded at 587 (offset 22 lines).

Hunk #14 succeeded at 636 (offset 22 lines).

1 out of 14 hunks FAILED -- saving rejects to file auth/ldap/config.html.rej

patching file auth/ldap/db/upgrade.php

patching file auth/ldap/ntlmsso_attempt.php

patching file auth/ldap/ntlmsso_finish.php

patching file auth/ldap/ntlmsso_magic.php

patching file auth/ldap/version.php

How can we fix it? Is there any other file that we can use?

Regards

In reply to Joan Luis Pérez

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Joan Luis,

find attached a version of the patch that should apply cleanly on Moodle 3.1.7, 3.1.8 and 3.1.9.

Saludos.

Iñaki.

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Nicolas REI -

Hello,


I'm triying to instal  Moodle  version 3.4.2 on Windows server 2016 with Xampp 7.2.3.

I use the patch 3.4 but i'm facing a problem : Hunks Failed... on the pictures Capture1 and capture2.

If you have any idea to solve this it would be very helpfull.


Thank's you so much


Nicolas.

Attachment Capture1.JPG
Attachment Capture2.JPG
In reply to Nicolas REI

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Salut Nicola,

please find attached a version of the patch that should apply cleanly on any version between Moodle 3.4.2 (Build: 20180319) and Moodle 3.4.2+ (Build: 20180418).

As I said a few months ago, I've changed the way I maintain the patches, which means the way to apply them has changed a bit. Now we just need to perform single step: executing ldapname.php

php ldapname.php ldap2

(substitute ldap2 with the new plugin name you want to use).

Saludos.

Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Nicolas REI -

Hello Iñaki,


Thank you for this patch, it's ok to create and install on Moodle but, i've an error on : Exception: Call to Undefined function get_ldap_assignable_role_names()

Have you an idea for resolve this error?


TY

Nicolas

Attachment ldaperreur.JPG
Attachment ldapok1.JPG
In reply to Nicolas REI

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi Nicolas,

totally my fault! It seems I forgot to changethe reference from the "standard plugin name" to the customized plugin name in one place.

The attached file includes the fix. Sorry for the inconveniences sad

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Nicolas REI -

Hello Iñaki,


This version is perfect.


Thank you so much.

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Mónica Puig-Pey -

Hello Iñaki, 

Thank you very much for your contribution with this plugin. It's been really helpfull for our site. 

These days, we are trying to move to Moodle 3.5. I've tried this plugin version v3.1 for moodle 3.4. It seems everything is working well even though the plugin is for a previous version.

I just wanted to ask you, as the developer, if you think we could have any problem using it for Moodle 3.5.

Saludos Mónica


In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Darren Biggs -

Hi Iñaki

Could you confirm if this will work with Moodle 3.5 or if you have a new plugin for that version?

Thanks

Darren

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Alejandro Castillo Andrade -

Hello Iñaki

Do you have the version for moodle 3.4.6+ (Build: 20181201), I don't know if the version 3.4_v3.1 doesn't work for me because I have php 7 on my centos server , the patch doesn't create the folder clone and in version 3.4 v1 it creates the plugin and the folder but I have problems with xmldb class and I think thats why it doesn't create the tables for ldap2.

In reply to Iñaki Arenaza

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by IT Department -

Hi Iñaki Arenaza,


I have downloaded your script which we are currently on 3.4 but cannot run it because the version our server PHP OS is running at.


Even though our websites run via PLESK php 7.0 the OS version is only 5.4

when we run your script via command line we get the following error:


Moodle 3.2 or later requires at least PHP 5.6.5 (currently using version 5.4.16)                 .

Some servers may have multiple PHP versions installed, are you using the correct                  executable?


Do you have any manual instructions on how to duplicate this ldap plugin for 3.4?



In reply to IT Department

Re: Ynt: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can edit ldapname.php and remove some lines and modify a couple of others. But if you do this, make really sure you use a valid plugin name for your LDAP clone (the lines we are going to remove specifically check for this). Otherwise, it may have an erratic behaviour (i.e., some things working while other not).

So look for these lines in ldapname.php and comment/delete them:

try {
    require(dirname(__FILE__).'/config.php');
} catch (dml_connection_exception $e) {
    // Just continue, we don't need the database for this to work.
    echo "Continuing, even if database is not available\n";
}

try {
    $ldapname = validate_param($_SERVER['argv'][1], PARAM_PLUGIN);
} catch (invalid_parameter_exception $e) {
    usage();
    exit;
}

Then change these lines:

$ldapnew  = $CFG->dirroot.'/auth/'.$ldapname;
$patchfileorig = $CFG->dirroot.'/ldapname.diff';

to these:

$ldapname = $_SERVER['argv'][1];
$ldapnew  = './auth/'.$ldapname;
$patchfileorig = './ldapname.diff';

Then make absolutely sure you put both ldapname.php and ldapname.diff in the root directory of your moodle site.

That should do the trick.

Saludos. Iñaki.

In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by IT Department -

Those instructions are out of date as the code has changed since you done that so we cannot recreate.

In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by IT Department -

This is what im getting after doing what edits i could find and selecting install when it asks me to.


Plugin "auth_ldap" is installed in incorrect location "$CFG->dirroot/auth/ldap2", expected location is "$CFG->dirroot/auth/ldap"

More information about this error

Debug info: 
Error code: detectedmisplacedplugin
Stack trace:
  • line 544 of /lib/upgradelib.php: plugin_misplaced_exception thrown
  • line 1850 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 694 of /admin/index.php: call to upgrade_noncore()

In reply to IT Department

Re: How to use multiple LDAP servers with Moodle 1.8

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

This would appear to indicate that you have not replaced all the necessary instances of ldap with ldap2. More specifically, the name of the plugin.

In reply to Emma Richardson

Re: How to use multiple LDAP servers with Moodle 1.8

by IT Department -

I have followed all the instructions

Please see link to all the code.


https://pastebin.com/2WWpfTHx


In reply to IT Department

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

May I ask which instructions (those that you are responding to are from 2007, which are waaaay out of date if you are trying to use them with a recent Moodle version), and which Moodle version you are trying to apply them to? (it's not apparent from your pastebin).

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by IT Department -

Yes we were trying to use those old instructions, I was aware they were out of date and I also informed the person who reposted thoese old instructions they were out of date.


The moodle version we are using is 3.4.1

In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Manish Kumar -

Hi sir,

Please Provide us the patch file for Moodle 3.2.1 (Build: 20170109).

i have some issue with the  your provided version of patch (ldap-clones-patch-script_3.2_v1).

it is required on the urgent basis.

i am waiting for your response.



Attachment patcherror.png
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Darren Biggs -

Hi lnaki

Could you confirm if this works with Moodle 3.5 or if you have a new plugin for that version?

Thanks

Darren

In reply to Darren Biggs

Re: How to use multiple LDAP servers with Moodle 1.8

by Manish Kumar -
Hi,

we are using Moodle 3.2.1.

we need patch file for 3.2.1 for multiple Ldap integration.


In reply to Paul F

Re: How to use multiple LDAP servers with Moodle 1.8

by George Balasca -
Hi all,

Have anybody tried to clone the plugin for Moodle 3.7.2 running a windows server? Is there a patch or some clean instructions for doing that?

Thank you so much!
In reply to George Balasca

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

After a long time (probably too long, but sometimes life gets in your way smile) here's a version of the patch for Moodle 3.7.2+ (Build: 20191108).

I have lightly tested it and seems to work as expected. But I'm a bit rusty so I might have missed something. So if anything fails or breaks, just give me a shout!

From now on I will include a ldapname-README.txt file in the zip with instructions detailing how to apply the patch (thanks to Mark Thomson for the suggestion!)

Saludos.

Iñaki.

Average of ratings: Useful (3)
In reply to Iñaki Arenaza

Re: How to use multiple LDAP servers with Moodle 1.8

by Andrew Lorbach -
Hi Iñaki

Thank you so much for all your help with creating these patches. I think once I get it working it will be a massive help for our staff and students. Sorry I have to ask for help, I downloaded this patch for our moodle 3.7.3+ (I couldn't seem to get 3.7.2 anymore). I've got it almost all working I think, but when I try and test a user I get this error.

Administration: Plugins: Authentication: Test settings

Exception - Call to undefined function get_ldap_assignable_role_names()

I think it might be the same error this genteman was getting:
https://moodle.org/mod/forum/discuss.php?d=74279&parent=1489567

If it's not too much trouble would you be able to see if you could help me out.

Thank you so very much!

In reply to Andrew Lorbach

Re: How to use multiple LDAP servers with Moodle 1.8

by Chris J -
I was getting the same error message as Andrew on a new Moodle install (version 3.8) when using Iñaki's latest patch. I was able to resolve this by making a change to auth.php in the cloned ldap directory (Linux):

/var/www/html/moodle/auth/ldap2/auth.php

Perform a search (or go to line 2167) for "get_ldap_assignable_role_names()" and change it to "get_ldap2_assignable_role_names()".
Average of ratings: Useful (1)