diff --git a/apachesolr.module b/apachesolr.module
index 3b5dd7b..02720a6 100644
--- a/apachesolr.module
+++ b/apachesolr.module
@@ -760,9 +760,12 @@ function apachesolr_set_last_index_position($env_id, $entity_type, $last_changed
 /**
  * Clear a specific environment, or clear all.
  */
-function apachesolr_clear_last_index_position($env_id, $entity_type = NULL) {
+function apachesolr_clear_last_index_position($env_id = NULL, $entity_type = NULL) {
   $stored = variable_get('apachesolr_index_last', array());
-  if ($entity_type) {
+  if (empty($env_id)) {
+    $stored = array();
+  }
+  elseif ($entity_type) {
     unset($stored[$env_id][$entity_type]);
   }
   else {
diff --git a/apachesolr_access/apachesolr_access.module b/apachesolr_access/apachesolr_access.module
index 3574179..bac5a28 100644
--- a/apachesolr_access/apachesolr_access.module
+++ b/apachesolr_access/apachesolr_access.module
@@ -122,7 +122,7 @@ function apachesolr_access_form_alter(&$form, $form_state, $form_id) {
 function apachesolr_access_rebuild_nodeaccess(&$form, $form_state) {
   drupal_set_message(t('Solr search index will be rebuilt.'));
   // Clear last updated
-  apachesolr_index_set_last_updated();
+  apachesolr_clear_last_index_position();
 }
 
 function apachesolr_access_enable() {
diff --git a/apachesolr_access/tests/apachesolr_access.test b/apachesolr_access/tests/apachesolr_access.test
index ef9986b..222a778 100644
--- a/apachesolr_access/tests/apachesolr_access.test
+++ b/apachesolr_access/tests/apachesolr_access.test
@@ -25,6 +25,15 @@ class DrupalApacheSolrNodeAccess extends DrupalWebTestCase {
       'edit own article content',
     );
     $this->basic_user = $this->drupalCreateUser($permissions);
+    // Create an admin user.
+    $permissions = array(
+      'access content',
+      'search content',
+      'administer nodes',
+      'administer search',
+      'access administration pages',
+    );
+    $this->admin_user = $this->drupalCreateUser($permissions);
   }
 
   function testIndexing() {
@@ -125,5 +134,15 @@ class DrupalApacheSolrNodeAccess extends DrupalWebTestCase {
     foreach ($expected_criterion as $k => $v) {
       $this->assertTrue(in_array("$k:$v", $parts), "Filter $k:$v found in the parts");
     }
+    // Test reset of index position.
+    $this->drupalLogin($this->admin_user);
+    $env_id = apachesolr_default_environment();
+    apachesolr_set_last_index_position($env_id, 'node', 1, 1);
+    $empty = serialize(array());
+    $value = db_query('SELECT value FROM {variable} WHERE name = :name', array(':name' => 'apachesolr_index_last'))->fetchField();
+    $this->assertNotEqual($value, $empty, 'value is not empty array');
+    $this->drupalPost('admin/reports/status/rebuild', array(), t('Rebuild permissions'));
+    $value = db_query('SELECT value FROM {variable} WHERE name = :name', array(':name' => 'apachesolr_index_last'))->fetchField();
+    $this->assertEqual($value, $empty, 'value is empty array');
   }
 }
