AuthorizationRule.Roles Eigenschaft

Definition

Ruft die Rollen ab, die der Ressource zugeordnet sind.

public:
 property System::Collections::Specialized::StringCollection ^ Roles { System::Collections::Specialized::StringCollection ^ get(); };
[System.ComponentModel.TypeConverter(typeof(System.Configuration.CommaDelimitedStringCollectionConverter))]
[System.Configuration.ConfigurationProperty("roles")]
public System.Collections.Specialized.StringCollection Roles { get; }
[<System.ComponentModel.TypeConverter(typeof(System.Configuration.CommaDelimitedStringCollectionConverter))>]
[<System.Configuration.ConfigurationProperty("roles")>]
member this.Roles : System.Collections.Specialized.StringCollection
Public ReadOnly Property Roles As StringCollection

Eigenschaftswert

Eine StringCollection-Auflistung, die die Rollen enthält, deren Autorisierung überprüft werden muss.

Attribute

Beispiele

Im folgenden Codebeispiel wird die Verwendung dieser Eigenschaft veranschaulicht.

 // Using the AuthorizationRuleCollection Add method.

 // Set the action property.
 authorizationRule.Action = 
    AuthorizationRuleAction.Allow;
 // Define the new rule to add to the collection.
 authorizationRule.Users.Add("userName");
 authorizationRule.Roles.Add("admin");
 authorizationRule.Verbs.Add("POST");

 // Add the new rule to the collection.
 authorizationSection.Rules.Add(authorizationRule);
' Using the AuthorizationRuleCollection Add method.
' Set the action property.
  authorizationRule.Action = _
  AuthorizationRuleAction.Allow
' Define the new rule to add to the collection.
authorizationRule.Users.Add("userName")
authorizationRule.Roles.Add("admin")
authorizationRule.Verbs.Add("POST")

' Add the new rule to the collection.
authorizationSection.Rules.Add(authorizationRule)

Hinweise

Die Roles -Eigenschaft ist eine Liste von Rollen, denen der Zugriff auf die Ressource gewährt oder verweigert wird. Es muss mindestens ein Wert in der Eigenschaftsauflistung Users oder in der Roles Eigenschaftsauflistung oder in beiden vorhanden sein.

Gilt für: