## Authentication

### LDAP Mass sync users

LDAP Mass sync users

Hi,
We're running moodle 1.9.3 and php 5.2.5.

our moodle has been using ldap for awhile now, we have 1700+ users in moodle.

We're tring to use auth_ldap_sync_users.php but when used in the browser we get a blank screen and when done though command line the cmd window just closes.

i figure we're doing something wrong, just dont know what.

Could anyone explain where I'm going wrong please?

Average of ratings: -
Re: LDAP Mass sync users

I have seen this, too. One thing is to check your LDAP setting of MaxPageSize. I think the ADAM or AD LSD default for Windows based LDAP server is only 1000, which will be not enough for your situation.

But there are PHP limits too, although I don't remember offhand what they are. Probably someone else who replies will know better than I.

Average of ratings:Useful (1)
Re: LDAP Mass sync users

I done some research before hand and increased it to 2000, we have 1700 users in moodle (too many), 1300 users in AD. cron doesn't remove the excess users, We have it set to suspend.
when we run the php script, we get a blank web page, (no sorce code) and when we run it with php.exe we get a box with some text in it then dissapears with no change.

also within the php script it says it is optimised for 25k users, and i assume if it was reaching some sort of limit i would get some input back before the script reaches it's limit.

Average of ratings: -
Re: LDAP Mass sync users

*update*
when running though the commandline with

C:\wamp\bin\php\php5.2.5\php.exe -c C:\wamp\bin\php\php5.2.5\php.ini D:\moodle\auth\ldap\auth_ldap_sync_users.php
(and a million other variations)

the command box says connecting to ldap, pauses for a second, then the box dissapears

logging in to moodle using ldap works fine still.

Average of ratings: -
Re: LDAP Mass sync users

We have a similar setup - around 1700 users in LDAP - some missing forename / surname that we don't want to sync to moodle.

We have a Linux server (Ubuntu 10.2) but you may be able to follow some of the same ideas to get around it in Windows.

Here's what we did to get round it:

1. First, increase the maximum page size for LDAP on activedirectory: http://technet.microsoft.com/en-us/library/cc770976(WS.10).aspx
2. set up a script that will run daily that will perform the ldap sync:

php [path_to_moodle]/auth/ldap/auth_ldap_sync_users.php -d memory_limit=256M

php delete_empty_users.php
3. Note that the last line is optional - it requires that you create a new file called delete_empty_users.php with the following text:

<?php
require_once('[path_to_moodle]/config.php');
require_once($CFG->dirroot . '/lib/dmllib.php');$sql = "DELETE FROM " . $CFG->prefix . "user WHERE lastname='' AND auth ='ldap';"; execute_sql($sql);
?>
4. This will delete all users with a blank surname (we have hundreds floating around in active directory - ex students, test users). Make sure that you replace [path_to_moodle] in both files with your moodle root folder (e.g. D:\moodle)
5. If you're in windows, you may have to swap the / for \ in one or both of the above files.

Hope that's some use to you.

Average of ratings: -
Re: LDAP Mass sync users

Hey thanks for replying!

In responce to:
1. This was the first thing we done, it's set to 2000

2. We cant get the LDAP sync users to work in the first place! lol

3,4 That looks useful thanks

5. done

Average of ratings: -
Re: LDAP Mass sync users
That is really strange. The command box shouldn't close at all, even if the script fails.

Anyway, you can make the command send all its output to a file, so even if it closes the command box, you can get the error messages at least.

Something like this should do the trick (all in a single line):

 C:\\wamp\\bin\\php\\php5.2.5\\php.exe -c C:\\wamp\\bin\\php\\php5.2.5\\php.ini -d error_log=C:\\some-temp-directory\\php-error.log -f D:\\moodle\\auth\\ldap\\auth_ldap_sync_users.php

Saludos.
Iñaki.

Average of ratings: -
Re: LDAP Mass sync users

I tried your command changing only "some-Temp-Directory", and i didn't get any log, I've taken some screen shots

tripple checked everything i was typing in was right, no syntax mistakes.
when i press "ok".

after this the box closes and there is no change to the moodle users.

Average of ratings: -
Re: LDAP Mass sync users

Aha! Now I get it!

In the "Run" dialog box, simply type:

 cmd.exe


and click on "OK". You will get a command window that won't close when the execution of the php command finishes . Then type the full php command you were trying to use.

Saludos. Iñaki.

Average of ratings: -
Re: LDAP Mass sync users

Window stays open but doesn't do anything else

Average of ratings: -
Re: LDAP Mass sync users
If the c:\phperror directory exists prior to executing the command, you should find a file called php-error.log there, hopefully with some details of what's going on.

Saludos.
Iñaki.

Average of ratings:Useful (1)
Re: LDAP Mass sync users

There is no log.
no log = no errors so maybe moodles ldap search is returning no results. does moodle have to be connected to the global catalog? I'm trying this now.
I've played around with ldp.exe checking our LDAP settings they all seem to be correct. Bind user isn't the problem i tried the administrator account and got the same results.

will post the results of catalog soon

Average of ratings: -
Re: LDAP Mass sync users

PROBLEM FIXED!
Our moodle is on Wamp in the php directory there is a php.ini file
i was pointing the script to that! I think the ldap extention was commented out or something.
under closer inspection of moodle/admin/phpinfo.php it showed "Loaded Configuration File" was pointing somewhere else.
once i put the right config file in the command line everything sprung to life! :D

Thanks for all the help

Average of ratings:Useful (1)