WebPartsPersonalization.Authorization 属性

定义

获取一个 AuthorizationSection 对象,该对象包含当前 Web 应用程序的 Web 部件个性化设置授权。

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

属性值

WebPartsPersonalizationAuthorization

一个 AuthorizationSection 对象,包含当前 Web 应用程序的 Web 部件个性化设置授权。

属性

示例

下面的代码示例说明如何使用 Authorization 属性。 此代码示例是为类提供的大型示例的 WebPartsSection 一部分。

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

注解

必须至少有一个与集合中的每个对象关联的 AuthorizationRule 有效谓词。

适用于