Importing AD Users via LDAP

Importing AD Users via LDAP

by Simon Hall -
Number of replies: 7

Hello Guys,


I have an ldap connection working with my Moodle 2.6 except that it doesnt seem to import all the users from my Active Directory automatically into Moodle.

I was assuming that once the connection was made that all users would be automatically imported into Moodle from Active Directory but it seems that users need to first log into Moodle to be recognised and are then added.

Is this the norm or is there some thing else I need to do to have the users imported into Moodle automatically?

Any help is much appreciated.

Regards,

Simon

Average of ratings: -
In reply to Simon Hall

Re: Importing AD Users via LDAP

by Simon Hall -

I have decided to go ahead and do a csv upload of users but I would like to be able to specify an authentication method for the users in the csv file - is this possible?


Regards,


Simon

In reply to Simon Hall

Re: Importing AD Users via LDAP

by John Gifford -

I think this is normal behavior, our setup certainly behaves that way. The ldap lookup is after all only an authentication method, so it's merely checking the details supplied by the user against the ldap/AD database.
Here a student logs into Moodle the first time and creates a Moodle profile, the ldap connection checks with AD about whether the student is allowed to login to Moodle then creates the account on Moodle, this means that Moodle doesn't have to store all the passwords etc and users have a common password for logging into the computer and using Moodle. If the password is changed in AD it changes automatically in Moodle. In practical terms if a user is in AD they can use Moodle but will still have to create a Moodle profile the first time they login.

There are companies I've seen that claim they can offer a tighter level of Moodle<->AD integration where users can be imported, but I think primarily these are just a scheduled task that runs every so often and creates Moodle profiles based on the ldap account details rather than anything more. So my feeling has always been is it worth the extra cost for such integration when an AD user can login to Moodle anyway, it just takes a couple of extra minutes the first time around.

John Gifford

In reply to Simon Hall

Re: Importing AD Users via LDAP

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

That is the way it is supposed to work.  When they log in, Moodle will query LDAP and create a profile according to the fields that you have specified in the settings.  If you map all the required profile settings, then it is a seamless process for the user and they do not even know what is happening in the background.

The only issue that I have found with this is that you cannot enroll a student in a course until after first login so that is where the csv upload comes in.  Yes, you can specify LDAP for the authentication method and so that works well.  Another step for the admin but I actually use the same file to add new users to LDAP and then Moodle.

I am not sure if anyone has come up with an LDAP sync plugin yet but you might search the plugins.

In reply to Simon Hall

Re: Importing AD Users via LDAP

by Kevin Rickard -

There is a php script in Moodle that will allow you to sync users from AD.  You must have LDAP authentication setup.

Before you run the script make sure your LDAP is pointing to the OU with user accounts only. If not, it will sync computer objects and become overwhelming.

I suggest you setup a cron job to have the script run automatically.


The script is located at /var/www/moodle/enrol/ldap/cli/sync.php

In reply to Kevin Rickard

Re: Importing AD Users via LDAP

by Simon Hall -

Thanks for everyone's responses !


So I ended up using the csv file to upload users and specified the authentication using 'auth' in one of the column headings and did the same for cohorts etc.

Works fine so thanks again.


Regards,


Simon

In reply to Simon Hall

Re: Importing AD Users via LDAP

by Muhammad Asif -

Hi Simon. How did you export users from AD and import to Moodle. In what field you gave value as 'auth'. Please write some salient steps.

In reply to Muhammad Asif

Re: Importing AD Users via LDAP

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Muhammad

https://moodle.org/mod/forum/discuss.php?d=262819 is somebody else's discussion! And that person https://moodle.org/user/view.php?id=1459421&course=5 has left the forum.

What is exactly "export users from AD and import to Moodle"? Is it one time? What information (attributes) of the users should land in Moodle?

Did you read the documentation linked to the header of this forum!