diff --git a/node_access_example/node_access_example.module b/node_access_example/node_access_example.module
index ba1461b..bdde77f 100755
--- a/node_access_example/node_access_example.module
+++ b/node_access_example/node_access_example.module
@@ -266,7 +266,10 @@ define('NODE_ACCESS_EXAMPLE_GRANT_ALL', 23);
  */
 function node_access_example_node_grants($account, $op) {
   // First grant a grant to the author for own content.
-  $grants['node_access_example_author'] = array($account->uid);
+  // Do not grant to anonymous user else all anonymous users would be author.
+  if ($account->uid) {
+    $grants['node_access_example_author'] = array($account->uid);
+  }
 
   // Then, if "access any private content" is allowed to the account,
   // grant view, update, or delete as necessary.
@@ -342,14 +345,16 @@ function node_access_example_node_access_records($node) {
 
     // For the node_access_example_author realm, the grant ID (gid) is
     // equivalent to the node author's user ID (UID).
-    $grants[] = array(
-      'realm' => 'node_access_example_author',
-      'gid' => $node->uid,
-      'grant_view' => 1,
-      'grant_update' => 1,
-      'grant_delete' => 1,
-      'priority' => 0,
-    );
+    if ($node->uid) {
+      $grants[] = array(
+        'realm' => 'node_access_example_author',
+        'gid' => $node->uid,
+        'grant_view' => 1,
+        'grant_update' => 1,
+        'grant_delete' => 1,
+        'priority' => 0,
+      );
+    }
     return $grants;
   }
   // Return nothing if the node has not been marked private.
