Index: singlesignon.module
===================================================================
--- singlesignon.module	(revision 130)
+++ singlesignon.module	(working copy)
@@ -69,7 +69,12 @@
     'target_url'       => '/\/cron.php$|\/feed$|\/rss.xml$/', // Allows remote cron, feed, and rss
   );
 
-  $master_url = variable_get('singlesignon_master_url', '');
+  if (variable_get('singlesignon_use_domain_module', 0) && function_exists('domain_default')) {
+    $master_url = _singlesignon_get_default_domain();
+  }
+  else {
+    $master_url = variable_get('singlesignon_master_url', '');
+  }
   $singlesignon_bot_matches = variable_get('singlesignon_bot_matches', $variable_defaults);
 
   if (
@@ -296,6 +301,14 @@
   );
 }
 
+/**
+ * 3rd party integration: get master url from Domain Access module
+ */
+function _singlesignon_get_default_domain() {
+  $domain = domain_default();
+  return $domain['scheme'] .'://'. $domain['subdomain'];
+}
+
 // }}}
 // {{{ other hook functions
 
@@ -337,13 +350,24 @@
   }
 
   $form = array();
+  $use_domain = variable_get('singlesignon_use_domain_module', 0);
+  if (module_exists('domain')) {
+    $form['singlesignon_use_domain_module'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Integrate with Domain module'),
+      '#default_value' => $use_domain,
+      '#description' => t('Synchronizes the master URL with the configured root domain of the <a href="!domain-settings">Domain</a> module.', array('!domain-settings' => url('admin/build/domain'))),
+    );
+  }
+  $master_url = $use_domain ? _singlesignon_get_default_domain() : variable_get('singlesignon_master_url', '');
   $form['singlesignon_master_url'] = array(
     '#type' => 'textfield',
     '#title' => t('Master URL'),
-    '#default_value' => variable_get('singlesignon_master_url', ''),
-    '#description' => t('Enter the URL of your master Single Sign-On server, in the form of <b>http://www.example.com</b>. Leave the trailing slash off. Do NOT include any path information.'),
+    '#default_value' => $master_url,
+    '#description' => t('Enter the URL of your master Shared Sign-On server, in the form of <b>http://www.example.com</b>. Leave the trailing slash off. Do NOT include any path information.'),
     '#maxlength' => '300',
     '#size' => '80',
+    '#disabled' => $use_domain,
   );
 
   $form['singlesignon_bot_matches'] = array(
