Share via


AuthorizationRule.Roles Vlastnost

Definice

Získá role přidružené k prostředku.

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

Hodnota vlastnosti

Kolekce StringCollection obsahující role, jejichž autorizace musí být ověřena.

Atributy

Příklady

Následující příklad kódu ukazuje, jak tuto vlastnost použít.

 // 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)

Poznámky

Vlastnost Roles je seznam rolí, kterým je udělen nebo odepřen přístup k prostředku. V kolekci Users vlastností nebo v kolekci Roles vlastností musí být alespoň jedna hodnota, případně obě.

Platí pro