diff --git a/ldapsync.admin.inc b/ldapsync.admin.inc
index 6bcda9a..25dee96 100644
--- a/ldapsync.admin.inc
+++ b/ldapsync.admin.inc
@@ -56,6 +56,13 @@ function ldapsync_admin_settings() {
     '#default_value' => variable_get('ldapsync_missing_users_action', 'warn'),
     '#options' => array('warn'=>t('warn'), 'block'=>t('block')),
   );
+  $form['options']['ldapsync_load_user_by'] = array(
+    '#type' => 'select',
+    '#title' => t('What to use for testing for existing users.'),
+    '#description' => t("If you want to check for users by email, change this."),
+    '#default_value' => variable_get('ldapsync_load_user_by', 'name'),
+    '#options' => array('name'=>t('User name'), 'email'=>t('E-mail')),
+  );
 
   $form['manual'] = array(
     '#type' => 'fieldset',
@@ -91,6 +98,7 @@ function ldapsync_admin_settings_submit($form, &$form_state) {
   variable_set('ldapsync_time_interval', $values['ldapsync_time_interval']);
   variable_set('ldapsync_filter', $values['ldapsync_filter']);
   variable_set('ldapsync_missing_users_action', $values['ldapsync_missing_users_action']);
+  variable_set('ldapsync_load_user_by', $values['ldapsync_load_user_by']);
   drupal_set_message(t('Settings saved'));
 }
 
diff --git a/ldapsync.module b/ldapsync.module
index b27adc3..c3078e0 100644
--- a/ldapsync.module
+++ b/ldapsync.module
@@ -87,8 +87,14 @@ function _ldapsync_sync() {
     // check whether user is in an OU mapped in module settings (need to create admin/settings/ldapsync page)
     $dn = $data['dn'];
 
-    // Does user exist in Drupal (find by username)? If not, create it (using process in ldapauth).
-    $account = user_load(array('name' => $name));
+    // Does user exist in Drupal? If not, create it (using process in ldapauth).
+    $user_test_method = variable_get('ldapsync_load_user_by', 'name');
+    if ($user_test_method == 'email') {
+      $account = user_load(array('mail' => $data['mail']));
+    }
+    else {
+      $account = user_load(array('name' => $name));
+    }
     if (!$account->uid) {
 
       // User does not exist in Drupal. Let's create it.
@@ -121,7 +127,7 @@ function _ldapsync_sync() {
       $data = unserialize($account->data);
       if (!$data['ldap_authentified']) {
         // User exists as a local Drupal account -- name conflict! -- log and stop processing this user.
-        watchdog('ldapsync', 'Could not create ldap-authentified account for user %name because a local user by that name already exists.', array('%name' => $name));
+        watchdog('ldapsync', 'Could not create ldap-authentified account for user %name because a local user by that %test_value already exists.', array('%name' => $name, '%test_value' => $user_test_method));
         continue;
       }
     }
