How to use multiple LDAP servers with Moodle 1.8

Re: How to use multiple LDAP servers with Moodle 1.8

by Iñaki Arenaza -
Number of replies: 43
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)