## Authentication

### Problem writing to LDAP AD after upload users

Problem writing to LDAP AD after upload users

We are a new Moodle school so please forgive any naivity!

We have Moodle talking nicely to our Active Directory using LDAP and it mostly works.  However our AD does not have email addresses populated and for long and boring technical reasons cannot update the 2000 odd users in AD.

Therefore we performed Upload Users and populated the email addresses in Moodle.  So far so good.

Although we have Update External set correctly (and this works when we do a manual change to the email address field (assuming the field is unlocked)) the Active Directory is not updated with this new information.

Is this a bug, or known functionality?  Regardless, is there a work around (perhaps a PHP script to force a LDAP update).

This would be a one-off solution as all new users from now on would be entered correctly in the AD.

I would be very grateful for assistance!

Average of ratings: -
Re: Problem writing to LDAP AD after upload users
Whether this is a bug or a feature is always debatable , but right now external updates are only performed on manual changes (it's always been like that, btw).

Regarding the workaround, look for these lines in admin/tool/index.php (around line 596 in Moodle 2.4):
 if ($doupdate or$existinguser->password !== $oldpw) { // we want only users that were really updated$DB->update_record('user', $existinguser); and change them to look like these:  if ($doupdate or $existinguser->password !==$oldpw) { // we want only users that were really updated $olduser =$DB->get_record('user', array('id' => $existinguser->id)); try {$auth->user_update($olduser,$existinguser); } catch (Exception $e) { // Ignore the exception }$DB->update_record('user', \$existinguser);

When you upload users and update any details of them, the new lines will force a LDAP update for each modified user. Note that I talk about modified user(s). If you don't modify any user details, the LDAP update will not be triggered.

Saludos.
Iñaki.

Average of ratings: -