Share via


AuthorizationRule.Roles Propriété

Définition

Obtient les rôles associés à la ressource.

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

Valeur de propriété

Collection StringCollection contenant les rôles dont l'autorisation doit être vérifiée.

Attributs

Exemples

L’exemple de code suivant montre comment utiliser cette proprié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)

Remarques

La Roles propriété est une liste de rôles auxquels l’accès à la ressource est accordé ou refusé. Il doit y avoir au moins une valeur dans la Users collection de propriétés ou la collection de Roles propriétés, ou les deux.

S’applique à