Freigeben über


Anwendungsabhängigkeiten <applicationDependencies>

Übersicht

Das <applicationDependencies>-Element des <Sicherheitselements> funktioniert zusammen mit dem <isapiCgiRestriction-Element>, um zu definieren, welche Anwendungen Abhängigkeiten von einer oder mehreren CGI- oder ISAPI-Erweiterungseinschränkungen haben. Wenn eine Anwendung in diesem Element enthalten ist, hat die Anwendung Abhängigkeiten von einem Element (oder mehreren Elementen) im <isapiCgiRestriction-Element>.

Kompatibilität

Version Hinweise
IIS 10.0 Das <applicationDependencies> Element wurde in IIS 10.0 nicht geändert.
IIS 8.5 Das <applicationDependencies> Element wurde in IIS 8.5 nicht geändert.
IIS 8.0 Das <applicationDependencies> Element wurde in IIS 8.0 nicht geändert.
IIS 7.5 Das <applicationDependencies>-Element wurde in IIS 7.5 nicht geändert.
IIS 7.0 Das <applicationDependencies>-Element des <security>-Elements wurde in IIS 7.0 eingeführt.
IIS 6.0 Das <applicationDependencies>-Element ersetzt das IIS 6.0-Attribut ApplicationDependencies des Metabasisobjekts IIsWebService.

Setup

Das <applicationDependencies>-Element ist in der Standardinstallation von IIS 7 enthalten.

Gewusst wie

Es gibt keine Benutzeroberfläche zum Konfigurieren des <applicationDependencies>-Elements für IIS 7. Beispiele zum programmgesteuerten Konfigurieren des <applicationDependencies>-Elements finden Sie im Abschnitt Codebeispiele dieses Dokuments.

Konfiguration

Attribute

Keine

Untergeordnete Elemente

Element Beschreibung
application Optionales Element.

Gibt eine Anwendung an, die Abhängigkeiten von einer CGI- oder ISAPI-Erweiterungseinschränkung aufweist.
clear Optionales Element.

Entfernt alle Verweise auf Anwendungen aus der Auflistung ApplicationDependencies.

Konfigurationsbeispiel

Das folgende Konfigurationsbeispiel veranschaulicht die Anwendungsabhängigkeiten im <applicationDependencies> Element für die Standardwebsite und die zugehörigen Einträge in der <isapiCgiRestriction> Nachinstallation von Active Server Pages (ASP) und einer benutzerdefinierten Anwendung in IIS 7:

  • Die Anwendung „Active Server Pages“ hat eine Abhängigkeit von der Einschränkungsgruppe „ASP“ ISAPI/CGI.
  • Die benutzerdefinierte Anwendung verfügt über eine Abhängigkeit von der ISAPI/CGI-Einschränkungsgruppe „MyCustomGroup“ und einer zusätzlichen Abhängigkeit von der ASP ISAPI/CGI-Einschränkungsgruppe.
<system.webServer>
   <security>
      <isapiCgiRestriction notListedIsapisAllowed="false" notListedCgisAllowed="false">
         <clear />
         <add allowed="true" groupId="ASP"
            path="C:\Windows\system32\inetsrv\asp.dll" 
            description="Active Server Pages" />
         <add allowed="true" groupId="MyCustomGroup"
            path="C:\Windows\system32\inetsrv\mycustom.dll"
            description="My Custom Application" />
      </isapiCgiRestriction>
   </security>
</system.webServer>

<location path="Default Web Site">
   <system.webServer>
      <security>
         <applicationDependencies>
            <application name="My Custom Application" groupId="MyCustomGroup">
               <add groupId="ASP" />
            </application>
         </applicationDependencies>
      </security>
   </system.webServer>
</location>

Beispielcode

Das folgende Konfigurationsbeispiel veranschaulicht die Anwendungsabhängigkeiten im <applicationDependencies>-Element für die Standardwebsite. Die benutzerdefinierte Anwendung verfügt über eine Abhängigkeit von der ISAPI/CGI-Einschränkungsgruppe „MyCustomGroup“ und einer zusätzlichen Abhängigkeit von der ASP ISAPI/CGI-Einschränkungsgruppe.

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/security/applicationDependencies /+"[name='My Custom Application',groupId='MyCustomGroup']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/applicationDependencies /+"[name='My Custom Application',groupId='MyCustomGroup'].[groupId='ASP']" /commit:apphost

Hinweis

Sie müssen unbedingt den Commitparameterapphost festlegen, wenn Sie AppCmd.exe verwenden, um diese Einstellungen zu konfigurieren. Dadurch werden die Konfigurationseinstellungen auf den entsprechenden Speicherortabschnitt in der Datei ApplicationHost.config festgelegt.

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection applicationDependenciesSection = config.GetSection("system.webServer/security/applicationDependencies", "Default Web Site");

         ConfigurationElementCollection applicationDependenciesCollection = applicationDependenciesSection.GetCollection();
         ConfigurationElement applicationElement = applicationDependenciesCollection.CreateElement("application");
         applicationElement["name"] = @"My Custom Application";
         applicationElement["groupId"] = @"MyCustomGroup";

         ConfigurationElementCollection applicationCollection = applicationElement.GetCollection();
         ConfigurationElement addElement = applicationCollection.CreateElement("add");
         addElement["groupId"] = @"ASP";
         applicationCollection.Add(addElement);
         applicationDependenciesCollection.Add(applicationElement);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim applicationDependenciesSection As ConfigurationSection = config.GetSection("system.webServer/security/applicationDependencies", "Default Web Site")

      Dim applicationDependenciesCollection As ConfigurationElementCollection = applicationDependenciesSection.GetCollection
      Dim applicationElement As ConfigurationElement = applicationDependenciesCollection.CreateElement("application")
      applicationElement("name") = "My Custom Application"
      applicationElement("groupId") = "MyCustomGroup"

      Dim applicationCollection As ConfigurationElementCollection = applicationElement.GetCollection
      Dim addElement As ConfigurationElement = applicationCollection.CreateElement("add")
      addElement("groupId") = "ASP"
      applicationCollection.Add(addElement)
      applicationDependenciesCollection.Add(applicationElement)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var applicationDependenciesSection = adminManager.GetAdminSection("system.webServer/security/applicationDependencies", "MACHINE/WEBROOT/APPHOST/Default Web Site");

var applicationDependenciesCollection = applicationDependenciesSection.Collection;
var applicationElement = applicationDependenciesCollection.CreateNewElement("application");
applicationElement.Properties.Item("name").Value = "My Custom Application";
applicationElement.Properties.Item("groupId").Value = "MyCustomGroup";

var applicationCollection = applicationElement.Collection;
var addElement = applicationCollection.CreateNewElement("add");
addElement.Properties.Item("groupId").Value = "ASP";
applicationCollection.AddElement(addElement);
applicationDependenciesCollection.AddElement(applicationElement);

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set applicationDependenciesSection = adminManager.GetAdminSection("system.webServer/security/applicationDependencies", "MACHINE/WEBROOT/APPHOST/Default Web Site")

Set applicationDependenciesCollection = applicationDependenciesSection.Collection
Set applicationElement = applicationDependenciesCollection.CreateNewElement("application")
applicationElement.Properties.Item("name").Value = "My Custom Application"
applicationElement.Properties.Item("groupId").Value = "MyCustomGroup"

Set applicationCollection = applicationElement.Collection
Set addElement = applicationCollection.CreateNewElement("add")
addElement.Properties.Item("groupId").Value = "ASP"
applicationCollection.AddElement(addElement)
applicationDependenciesCollection.AddElement(applicationElement)

adminManager.CommitChanges()