Modifica

Condividi tramite


WebPartsPersonalization.Authorization Property

Definition

Gets an AuthorizationSection object containing the Web Parts personalization authorizations for the current Web application.

public:
 property System::Web::Configuration::WebPartsPersonalizationAuthorization ^ Authorization { System::Web::Configuration::WebPartsPersonalizationAuthorization ^ get(); };
[System.Configuration.ConfigurationProperty("authorization")]
public System.Web.Configuration.WebPartsPersonalizationAuthorization Authorization { get; }
[<System.Configuration.ConfigurationProperty("authorization")>]
member this.Authorization : System.Web.Configuration.WebPartsPersonalizationAuthorization
Public ReadOnly Property Authorization As WebPartsPersonalizationAuthorization

Property Value

An AuthorizationSection object containing the Web Parts personalization authorizations for the current Web application.

Attributes

Examples

The following code example shows how to use the Authorization property. This code example is part of a larger example provided for the WebPartsSection class.

// Add an authorization.
AuthorizationRule ar = 
    new AuthorizationRule(AuthorizationRuleAction.Allow);
ar.Verbs.Add("ModifyState");
ar.Users.Add("Admin");
webPartsSection.Personalization.Authorization.Rules.Add(ar);

// List current authorizations.
for (int ai = 0;
    ai < webPartsSection.Personalization.Authorization.Rules.Count; 
    ai++)
{
    Console.WriteLine("  #{0}:", ai);
    AuthorizationRule aRule = 
        webPartsSection.Personalization.Authorization.Rules[ai];
    Console.WriteLine("  Verbs=");
    foreach (string verb in aRule.Verbs)
        Console.WriteLine("    * {0}", verb);
    Console.WriteLine("  Roles=");
    foreach (string role in aRule.Roles)
        Console.WriteLine("    * {0}", role);
    Console.WriteLine("  Users=");
    foreach (string user in aRule.Users)
        Console.WriteLine("    * {0}", user);
}
' Add an authorization.
Dim ar As AuthorizationRule = _
  New AuthorizationRule(AuthorizationRuleAction.Allow)
ar.Verbs.Add("ModifyState")
ar.Users.Add("Admin")
webPartsSection.Personalization.Authorization.Rules.Add(ar)

' List current authorizations.
Dim ai As Integer
For ai = 0 To _
  webPartsSection.Personalization.Authorization.Rules.Count
    Console.WriteLine("  #{0}:", ai)
    Dim aRule As AuthorizationRule = _
      webPartsSection.Personalization.Authorization.Rules(ai)
    Console.WriteLine("  Verbs=")
    Dim verb As String
    For Each verb In aRule.Verbs
      Console.WriteLine("    * {0}", verb)
      Console.WriteLine("  Roles=")
    Next
    Dim role As String
    For Each role In aRule.Roles
      Console.WriteLine("    * {0}", role)
      Console.WriteLine("  Users=")
    Next
    Dim user As String
    For Each user In aRule.Users
      Console.WriteLine("    * {0}", user)
    Next
Next

Remarks

There must be at least one valid verb associated with each AuthorizationRule object in the collection.

Applies to