WebPartsPersonalization.Authorization Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

[ConfigurationPropertyAttribute("authorization")]
public WebPartsPersonalizationAuthorization Authorization { get; }

Property Value

Type: System.Web.Configuration.WebPartsPersonalizationAuthorization

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

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

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);
}

.NET Framework
Available since 2.0
Return to top
Show: