Commit 3e55def7 authored by Lisa Seeto's avatar Lisa Seeto Committed by Gerrit Code Review
Browse files

Merge "Bug 1903592: Only try to check the email if supplied"

parents 6deb237e 8bcb937f
...@@ -16,6 +16,7 @@ $string['ldapconfig'] = 'LDAP configuration'; ...@@ -16,6 +16,7 @@ $string['ldapconfig'] = 'LDAP configuration';
$string['description'] = 'Authenticate against an LDAP server'; $string['description'] = 'Authenticate against an LDAP server';
$string['notusable'] = 'Please install the PHP LDAP extension'; $string['notusable'] = 'Please install the PHP LDAP extension';
$string['emailmissing'] = 'The email address is missing.';
$string['attributename'] = 'Name of the LDAP attribute used to sync groups based on its values (required and must respect case)'; $string['attributename'] = 'Name of the LDAP attribute used to sync groups based on its values (required and must respect case)';
$string['cannotdeleteandsuspend']= 'Cannot specify -d and -s at the same time.'; $string['cannotdeleteandsuspend']= 'Cannot specify -d and -s at the same time.';
$string['cli_info_sync_groups']='This command line PHP script will attempt to synchronize an institution list of groups with an LDAP directory. $string['cli_info_sync_groups']='This command line PHP script will attempt to synchronize an institution list of groups with an LDAP directory.
......
...@@ -1353,10 +1353,11 @@ class AuthLdap extends Auth { ...@@ -1353,10 +1353,11 @@ class AuthLdap extends Auth {
var_dump($todb); var_dump($todb);
} }
//check for used email //check for used email
if ( if (!empty($todb->email) && (
($d1 = get_record('usr', 'email', $todb->email)) ($d1 = get_record('usr', 'email', $todb->email))
|| ||
($d2 = get_record('artefact_internal_profile_email', 'email', $todb->email)) ($d2 = get_record('artefact_internal_profile_email', 'email', $todb->email))
)
) { ) {
if (empty($d1)) { if (empty($d1)) {
$d1 = get_record('usr', 'id', $d2->owner); $d1 = get_record('usr', 'id', $d2->owner);
...@@ -1368,6 +1369,10 @@ class AuthLdap extends Auth { ...@@ -1368,6 +1369,10 @@ class AuthLdap extends Auth {
log_warn(get_string('emailalreadytaken', 'auth.internal') .' '. $d1->username . ' '.$todb->email); log_warn(get_string('emailalreadytaken', 'auth.internal') .' '. $d1->username . ' '.$todb->email);
$nberrors ++; $nberrors ++;
} }
else if (empty($todb->email)) {
log_warn(get_string('emailmissing', 'auth.ldap') . ' ' . $ldapusername);
$nberrors ++;
}
else { else {
if (!$dryrun) { if (!$dryrun) {
create_user($todb, array(), $this->institution); create_user($todb, array(), $this->institution);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment