Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.339
diff -u -r1.339 search.module
--- modules/search/search.module	3 Mar 2010 19:46:25 -0000	1.339
+++ modules/search/search.module	9 Mar 2010 23:03:16 -0000
@@ -891,6 +891,11 @@
   // Add CSS
   drupal_add_css(drupal_get_path('module', 'search') . '/search.css', array('preprocess' => FALSE));
 
+  $type = _search_get_active_type($type);
+  if (!$type) {
+    form_set_error(NULL, t('All searching modules are disabled.'), 'error');
+    return $form;
+  }
   if (!$action) {
     $action = url('search/' . $type);
   }
@@ -918,6 +923,45 @@
 }
 
 /**
+ * Returns an active search type, using the supplied type if possible.
+ *
+ * @param $type
+ *   Type of search to try to use.
+ *
+ * @return
+ *   $type if that search module is currently active. If it is not currently
+ *   active, 'node' if that is an active search type. If neither $type nor
+ *   'node' works, the first active search module is chosen. FALSE is returned
+ *   if there are no active search modules.
+ */
+function _search_get_active_type($type) {
+  $search_hooks = search_get_info();
+  $types = array();
+  foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
+    if (isset($search_hooks[$module])) {
+      $types[] = $module;
+    }
+  }
+
+  if (!count($types)) {
+    return FALSE;
+  }
+
+  // Try to use supplied type.
+  if (isset($type) && in_array($type, $types)) {
+    return $type;
+  }
+
+  // Try to use 'node'.
+  if (in_array('node', $types)) {
+    return 'node';
+  }
+
+  // Just use the first active search type.
+  return $types[0];
+}
+
+/**
  * Form builder; Output a search form for the search block's search box.
  *
  * @ingroup forms
@@ -985,6 +1029,7 @@
  * Perform a standard search on the given keys, and return the formatted results.
  */
 function search_data($keys = NULL, $type = 'node') {
+  $type = _search_get_active_type($type);
 
   if (isset($keys)) {
     if (module_hook($type, 'search_execute')) {
Index: modules/search/search.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.pages.inc,v
retrieving revision 1.16
diff -u -r1.16 search.pages.inc
--- modules/search/search.pages.inc	3 Mar 2010 19:46:25 -0000	1.16
+++ modules/search/search.pages.inc	9 Mar 2010 23:03:16 -0000
@@ -14,11 +14,17 @@
   // the search query URL clean as a whistle:
   // search/type/keyword+keyword
   if (!isset($_POST['form_id'])) {
-    if ($type == '') {
+    $activetype = _search_get_active_type($type);
+    if (!$activetype) {
+      drupal_set_message(t('No search modules are currently enabled.'), 'error');
+      return '';
+    }
+
+    if ($type == '' || $type != $activetype) {
       // Note: search/node can not be a default tab because it would take on the
       // path of its parent (search). It would prevent remembering keywords when
       // switching tabs. This is why we drupal_goto to it from the parent instead.
-      drupal_goto('search/node');
+      drupal_goto('search/' . $activetype);
     }
 
     $keys = search_get_keys();
@@ -135,7 +141,7 @@
     // Fall through to the drupal_goto() call.
   }
 
-  $type = $form_state['values']['module'] ? $form_state['values']['module'] : 'node';
+  $type = _search_get_active_type($form_state['values']['module']);
   $form_state['redirect'] = 'search/' . $type . '/' . $keys;
   return;
 }
