ManagementAuthorization Klasse
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Stellt Funktionen zum Verwalten der Autorisierungsliste für eine bestimmte Website oder Anwendung bereit.
public ref class ManagementAuthorization abstract sealed
public static class ManagementAuthorization
type ManagementAuthorization = class
Public Class ManagementAuthorization
- Vererbung
-
ManagementAuthorization
Beispiele
Im folgenden Beispiel werden mehrere Methoden und Eigenschaften der ManagementAuthorization Klassen und ManagementAuthorizationInfo implementiert. In diesem Beispiel wird einer angegebenen Website ein angegebener Benutzer hinzugefügt und eine Sammlung autorisierter Benutzer der angegebenen Website angezeigt.
// Returns a Property bag that contains the Site Owner Details.
public PropertyBag GetSiteOwnerDetails(string siteName)
{
PropertyBag SiteOwnerDetailsBag = new PropertyBag();
// Set the userName.
string userName = "User4";
string display = null;
string message = null;
AppDomain domain = Thread.GetDomain();
domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
// Gets the site from the siteName.
Site site = base.ManagementUnit.ServerManager.Sites[siteName];
// Set the path.
string path = site.Name;
SiteOwnerDetailsBag.Add(0, principal.Identity.Name);
SiteOwnerDetailsBag.Add(1,
ManagementAuthorization.IsAuthorized(principal, path).ToString());
SiteOwnerDetailsBag.Add(2, siteName as string);
message = "Provider: " + ManagementAuthorization.Provider;
display = display + message;
// Get a collection of authorized users.
ManagementAuthorizationInfoCollection authorizedCollection =
ManagementAuthorization.GetAuthorizedUsers(path, true, 0, -1);
message = "\nAuthorizedUsers count: " +
authorizedCollection.Count.ToString() + "\n ";
display = display + message;
bool isInCollection = false;
message = null;
// Search the returned collection.
foreach (ManagementAuthorizationInfo authorizedInfo in authorizedCollection)
{
message = message + "\nName: " + authorizedInfo.Name;
message = message + " ConfigurationPath: " +
authorizedInfo.ConfigurationPath;
message = message + " IsRole: " + authorizedInfo.IsRole;
// Check to see if the user is already in the allowed users collection.
if (userName.Equals(authorizedInfo.Name))
{
isInCollection = true;
}
}
// Grant the user permission to this site only if
// they are not already in the allowed users collection.
if (!isInCollection)
{
ManagementAuthorization.Grant(userName, path, false);
message = message + "\nadded: " + userName;
}
display = display + message;
string[] configPaths =
ManagementAuthorization.GetConfigurationPaths(principal, null);
message = "\n\nThe current user is a member of " +
configPaths.Length + " paths.";
foreach (string configpath in configPaths)
{
message = message + "\npath: " + configpath;
}
display = display + message;
SiteOwnerDetailsBag.Add(3, display as string);
// Uncomment the following line to rename a configuration path.
// ManagementAuthorization.RenameConfigurationPath(path , path + "-new");
// Uncomment the following line to revoke
// all authorizations for the specified user.
// ManagementAuthorization.Revoke(userName);
// Uncomment the following line to revoke the
// authorization for the specified user to the specified site.
// ManagementAuthorization.Revoke(userName, path);
// Uncomment the following line to revoke all
// authorization for the specified site.
// ManagementAuthorization.RevokeConfigurationPath(path);
return SiteOwnerDetailsBag;
}
Hinweise
Berechtigungen für den IIS-Manager werden für einen bestimmten Standort oder eine bestimmte Anwendung und nicht auf Serverebene erteilt. Das ManagementAuthorization -Objekt bestimmt, ob einem Benutzer oder einer Rolle Zugriff auf eine bestimmte Website oder Anwendung gewährt werden soll. Eine Liste der autorisierten Benutzer ist auf der Seite IIS-Manager-Berechtigungen des IIS-Managers verfügbar.
Diese Klasse kann nicht vererbt werden.
Eigenschaften
| Provider |
Ruft den Autorisierungsanbieter für DEN IIS-Manager ab. |
Methoden
| GetAuthorizedUsers(String, Boolean, Int32, Int32) |
Ruft eine Sammlung autorisierter Benutzer für den angegebenen Konfigurationspfad ab. |
| GetConfigurationPaths(IPrincipal, String) |
Gibt ein Array von Konfigurationspfaden zurück, für das der angegebene Prinzipal autorisiert ist. |
| Grant(String, String, Boolean) |
Gewährt eine Autorisierung für einen Benutzernamen oder eine Rolle für den angegebenen Konfigurationspfad. |
| IsAuthorized(IPrincipal, String) |
Ruft einen Wert ab, der angibt, ob der angegebene Prinzipal für den angegebenen Konfigurationspfad autorisiert ist. |
| RenameConfigurationPath(String, String) |
Benennt einen Konfigurationspfad um. |
| Revoke(String) |
Widerruft die Autorisierung für den angegebenen Benutzer für alle Konfigurationspfade. |
| Revoke(String, String) |
Widerruft die Autorisierung für den angegebenen Benutzer für den angegebenen Konfigurationspfad. |
| RevokeConfigurationPath(String) |
Entfernt alle autorisierten Benutzer aus dem angegebenen Konfigurationspfad. |