In one of our Drupal projects, when the CRON URL was accessed it was showing the Access Denied page. After doing some R&D we found that the issue was due to the Apache Solr module. The Apache Solr module's CRON function was failing to index nodes. Finally we found the reason why this was failing and redirecting to Access Denied page. The reason was we had implemented the hook_node_view() to check permission when content of a particular type was accessed. So, when Apache Solr tried to index content of this type, it was failing to do so due to permission required to view the content. It then redirected the call to access denied page. After bypassing the code in hook_node_view() with the following condition it started working.
'search_index' != $view_mode
FYI, $view_mode is the second parameter of hook_node_view().
The following link gave us an idea about the issue.
http://www.blinkreaction.com/blog/be-aware-nodes-with-php-code-and-drupa... aware: nodes with PHP code and Drupal search index
Be aware: nodes with PHP code and Drupal search index
We finally decided to go to Apache Solr as our search solution. Basic installation and configuration went well out of the box (both solr engine and the Drupal module). The only thing left was waiting on the index to fill. Indexing is done on a cron run. Solr relies on Drupal's code Search engine, fo...