diff --git a/src/SimpleSAML/IdP.php b/src/SimpleSAML/IdP.php
index 92943bf1adbd63c88d6e4a2fef385ce51328f078..3e0950adf2c680fa62d9ff0348fbfddd75964819 100644
--- a/src/SimpleSAML/IdP.php
+++ b/src/SimpleSAML/IdP.php
@@ -91,12 +91,14 @@ class IdP
             }
             $this->config = $metadata->getMetaDataConfig(substr($id, 5), 'adfs-idp-hosted');
 
-            try {
-                // this makes the ADFS IdP use the same SP associations as the SAML 2.0 IdP
-                $saml2EntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
-                $this->associationGroup = 'saml2:' . $saml2EntityId;
-            } catch (\Exception $e) {
-                // probably no SAML 2 IdP configured for this host. Ignore the error
+            if ($globalConfig->getBoolean('enable.saml20-idp', false)) {
+                try {
+                    // this makes the ADFS IdP use the same SP associations as the SAML 2.0 IdP
+                    $saml2EntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted');
+                    $this->associationGroup = 'saml2:' . $saml2EntityId;
+                } catch (\Exception $e) {
+                    // probably no SAML 2 IdP configured for this host. Ignore the error
+                }
             }
         } else {
             throw new \Exception("Protocol not implemented.");