Commit 8bcb937f authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1903592: Only try to check the email if supplied



Change-Id: I9ac19eac9384d13a84d12e2e9b89fc4b6ba1acda
Signed-off-by: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent ca192c62
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ $string['ldapconfig'] = 'LDAP configuration';
$string['description'] = 'Authenticate against an LDAP server';
$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['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.
+6 −1
Original line number Diff line number Diff line
@@ -1353,10 +1353,11 @@ class AuthLdap extends Auth {
                        var_dump($todb);
                    }
                    //check for used email
                    if (
                    if (!empty($todb->email) && (
                            ($d1 = get_record('usr', 'email', $todb->email))
                            ||
                            ($d2 = get_record('artefact_internal_profile_email', 'email', $todb->email))
                        )
                    ) {
                        if (empty($d1)) {
                            $d1 = get_record('usr', 'id', $d2->owner);
@@ -1368,6 +1369,10 @@ class AuthLdap extends Auth {
                        log_warn(get_string('emailalreadytaken', 'auth.internal') .' '. $d1->username . ' '.$todb->email);
                        $nberrors ++;
                    }
                    else if (empty($todb->email)) {
                        log_warn(get_string('emailmissing', 'auth.ldap') . ' ' . $ldapusername);
                        $nberrors ++;
                    }
                    else {
                        if (!$dryrun) {
                            create_user($todb, array(), $this->institution);