asp.net.ph

AuthorizationStoreRoleProvider Class

System.Web.Security Namespace


.NET Framework version 2.0

Manages storage of role-membership information for an ASP.NET application in an authorization-manager policy store, either in an XML file, in an Active Directory, or on an Active Directory Application Mode server.

AuthorizationStoreRoleProvider Class Members

Collapse   Constructors

Visibility Constructor Parameters
public AuthorizationStoreRoleProvider ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public ApplicationName String [ Get , Set ]
public CacheRefreshInterval Int32 [ Get ]
public ScopeName String [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
public AddUsersToRoles ( String usernames , String roleNames ) Void
public CreateRole ( String roleName ) Void
public DeleteRole ( String roleName , Boolean throwOnPopulatedRole ) Boolean
public FindUsersInRole ( String roleName , String usernameToMatch ) String
public GetAllRoles ( ) String
public GetRolesForUser ( String username ) String
public GetUsersInRole ( String roleName ) String
public Initialize ( String name , NameValueCollection config ) Void
public IsUserInRole ( String username , String roleName ) Boolean
public RemoveUsersFromRoles ( String userNames , String roleNames ) Void
public RoleExists ( String roleName ) Boolean

Remarks

This class is used by the Roles and RolePrincipal classes to provide role-management services for an ASP.NET application using an authorization-manager store. You can use role management to specify different levels of authorization for your application. The authorization manager can be accessed using the Microsoft Management Console.

The AuthorizationStoreRoleProvider object works with both Windows authentication and forms authentication modes.

You can configure the AuthorizationStoreRoleProvider object to use either a local XML file or an Active Directory or Active Directory Application Mode ( ADAM ) server. When using a local file, the connection string should look like the following example.

msxml://<path to xml file>

If the local file is stored in the directory tree of an ASP.NET Web application, you can use the tilde ( "~" ) character to indicate the root directory. For example, to indicate that the local file is stored in the Web application's data directory, you would use a connection string similar to the following example.

msxml://~\App_Data\datafilename.xml

NOTE: Storing an XML data file in the Web application directory is a potential security threat. By default, IIS will serve XML data files to the Web. To improve security when using a local data file in an ASP.NET application, you should store the data file in the App_Data directory. Files stored in the App_Data directory will not be served to the Web.

If you are using an Active Directory or ADAM server for the policy store, your connection string should be similar to the following example.

msldap://myserver/CN=MyAzManStore,OU=MyOU,DC=MyDomain,DC=MyDC,DC=Com

The exceptions listed in the documentation for AuthorizationStoreRoleProvider object methods are the exceptions that are raised by the AuthorizationStoreRoleProvider object. Since the provider relies on the underlying Authentication Manager runtime, a COMException exception may be thrown whenever the AuthorizationStoreRoleProvider object forwards a method call to the Authentication Manager runtime.

NOTE: The AuthorizationStoreRoleProvider object has the following requirements for running in partial-trust environments:

When using a file-based policy store in an ASP.NET application, the file I/O permissions granted by the current trust level determine whether read and write actions are allowed by the provider. The ASP.NET application must have read permission on the file to read data from the policy store, and must have write permission to save new information or update existing information in the policy store. The default Medium-trust policy file gives an ASP.NET application read/write permissions in its application directory. The default Low-trust policy file only gives an ASP.NET application read permission in its application directory. In addition, the process identity under which the ASP.NET application runs must have file-system permissions to read and/or write the policy file.

When using an Active Directory or ADAM server, the ASP.NET application needs unmanaged-code permission because the internal AuthorizationStoreRoleProvider object code uses COM interop.

When using the AuthorizationStoreRoleProvider object outside of ASP.NET, the calling code needs unmanaged-code permission.

Example

The following code example shows a Web.config file set to use the AuthorizationStoreRoleProvider for role management.

<configuration>
   <connectionStrings>
      <add name = "AuthorizationServices" 
         connectionString = "msxml://~\App_Data\SampleStore.xml" />
   </connectionStrings>

   <system.web>

      <authentication mode = "Windows" />
      <identity impersonate = "true" />

      <roleManager defaultProvider = "AuthorizationStoreRoleProvider"
         enabled = "true"
         cacheRolesInCookie = "true"
         cookieName = ".ASPROLES"
         cookieTimeout = "30"
         cookiePath = "/"
         cookieRequireSSL = "false"
         cookieSlidingExpiration = "true"
         cookieProtection = "All" >
         <providers>
            <clear />
            <add name = "AuthorizationStoreRoleProvider"
               type = "System.Web.Security.AuthorizationStoreRoleProvider"
               connectionStringName = "AuthorizationServices"
               applicationName = "SampleApplication"
               cacheRefreshInterval = "60"
               scopeName = "" />
         </providers>
      </roleManager>

   </system.web>
</configuration>
See Also

ASP.NET Authorization   <roleManager> Section   RoleProvider Class Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph