Automatically get ldap users to sync in moodle?

Automatically get ldap users to sync in moodle?

by ztechguy Z -
Number of replies: 7
I am using ldap via microsoft AD to authenticate my users in moodle.  And I am manually creating courses and enrollment.  I have made all of my courses, and would like to manually enroll students in my the classes.  I don't have a ton of users 400...  The LDAP is working already, and I just want to have a little more flexibility with enrollment, that is why I don't want to be so granular with auto enrollment with AD

The problem is that the students do not show up to enroll in moodle until they have logged in once.  Is there a way to sync the ldap users so they all show up in my moodle.  I don't want to have to login 400 times just to get them in moodle.  And I don't want to use the enrollment key method either.

Thanks,

ztechguy
Average of ratings: -
In reply to ztechguy Z

Re: Automatically get ldap users to sync in moodle?

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
There is a script called auth_ldap_sync_users.php in .../moodle/auth/ldap.php that you can run from the command line to sync all your LDAP users with Moodle. This effectively creates all of them the first time.

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

Re: Automatically get ldap users to sync in moodle?

by ztechguy Z -
Thanks Inaki

I did try running /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php

from the command prompt and I get this

Status: 404
Content-type: text/html
X-Powered-By: PHP/4.3.9

No input file specified

I am running on linux doing ldap to server 2000 ldap  went into the auth_ldap_sync_users.php file and found that it can run the above script in a cron job.  But I thought I would just test it from the command line.  What am I missing.  I'm mostly a windows guy.... darn linux..... smile

ztechguy
In reply to ztechguy Z

Re: Automatically get ldap users to sync in moodle?

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 just missed a '-f' before the file to run smile

/usr/bin/php -c /etc/php4/cli/php.ini -f /var/www/moodle/auth/ldap/auth_ldap_sync_users.php

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Automatically get ldap users to sync in moodle?

by ztechguy Z -
Thanks Inaki,

I did run the script and I am getting further.  Now I get this.  Thanks again for your help.
[root@webserver ~]# /usr/bin/php -c /etc/php4/cli/php.ini -f /var/www/html/moodle/auth/ldap/auth_ldap_sync_users.php
<div class="notifyproblem" align="center">Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL</div><br />
Configuring temp table
connecting to ldap
+ 77 users
+ 480 users
<div class="notifyproblem" align="center">Table 'moodle2.mdl_extuser' doesn't exist<br /><br />SELECT COUNT(idnumber) AS count, 1 FROM mdl_extuser LIMIT 100</div><br />
Did not get any users from LDAP -- error? -- exiting



Any ideas thanks, I'm assuming I would set this to run in a cronjob to keep the database current?

jason
In reply to ztechguy Z

Re: Automatically get ldap users to sync in moodle?

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
Make sure the database user has CREATE (or CREATE TEMPORARY TABLES if you are using MySQL 4.0.2+) privilege in the Moodle database. Otherwise the script won't be able to create a temporary table it uses to track external users.

Saludos. Iñaki.
In reply to ztechguy Z

Re: Automatically get ldap users to sync in moodle?

by David Bezemer -

in your php.ini set:

variables_order = "EGPCS"

and reload/restart apache

this is a specific issue of moodle in combination with php 5.1.6 and Im not sure what causes it, only that this setting solves it

In reply to ztechguy Z

Re: Automatically get ldap users to sync in moodle?

by Laurie Flenner -

Hi Jason-  Were you successful in getting this to run as a cronjob? I am looking to accomplish the same thing in a corporate environment with LDAP.

Many thanks,

Laurie