niedziela, 11 grudnia 2011

ASP.NET SQL Provider Part 1

Microsoft ASP.NET 2.0 Providers: Introduction 
ASP.NET 2.0 Provider Model: Introduction to the Provider Model
ASPNETDB Database 

The SQL providers include:
  • SqlMembershipProvider,  
  • SqlRoleProvider,  
  • SqlProfileProvider,  
  • SqlSessionStateStore,  
  • SqlWebEventProvider, and 
  • SqlPersonalizationProvider.
Each stores data using a predefined schema. The Aspnet_regsql.exe tool that comes with ASP.NET 2.0 creates a SQL Server database with a compatible schema.

The following table documents the features and services that are provider-based and the default providers that service them:
Feature or ServiceDefault Provider
MembershipSystem.Web.Security.SqlMembershipProvider
Role managementSystem.Web.Security.SqlRoleProvider
Site mapSystem.Web.XmlSiteMapProvider
ProfileSystem.Web.Profile.SqlProfileProvider
Session stateSystem.Web.SessionState.InProcSessionStateStore
Web eventsN/A (see below)
Web Parts personalizationSystem.Web.UI.WebControls.WebParts.SqlPersonalizationProvider
Protected configurationN/A (see below)


The structure of the SQL provider database:

Tables

Name  Description 
aspnet_Applications  Used by ASP.NET features to provide an application scope for data.
aspnet_Membership  Used by the SQL Membership Provider to store membership data.
aspnet_Paths  Used by the SQL Personalization Provider to store the path for which Web Parts personalization state has been saved.
aspnet_PersonalizationAllUsers  Used by the SQL Personalization Provider to store shared personalization data.
aspnet_PersonalizationPerUser  Used by the SQL Personalization Provider to store per-user personalization data.
aspnet_Profile  Used by the SQL Profile Provider to store individual instances of property values.
aspnet_Roles  Used by the SQL Role Provider to store role data.
aspnet_SchemaVersions  Used to track the versions of schemas required by ASP.NET features.
aspnet_Users  Used to store information regarding users, including user names and IDs.
aspnet_UsersInRoles  Used by the SQL Role Provider to map roles to users.
aspnet_WebEvent_Events  Used by the SQL Web Event Provider to log event data.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Views

Name  Description 
vw_aspnet_Applications  Displays information for all applications.
vw_aspnet_MembershipUsers  Displays a list of ASP.NET membership users associated with the unique identifier for the user.
vw_aspnet_Profiles  Displays user profile information.
vw_aspnet_Roles  Displays role information.
vw_aspnet_Users  Displays a list of users per application.
vw_aspnet_UsersInRoles  Displays which users are associated with which roles by the unique identifiers for the user and the role.
vw_aspnet_WebPartState_Paths  Displays Web Parts state path information.
vw_aspnet_WebPartState_Shared  Displays Web Parts state information.
vw_aspnet_WebPartState_User  Displays Web Parts user information.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Procedures

Name  Description 
aspnet_AnyDataInTables  Checks to see if there is any data in the specified tables.
aspnet_Applications_CreateApplication  Adds a new application to the aspnet_Application table.
aspnet_CheckSchemaVersion  Checks the compatibility of the schema version for the given feature.
aspnet_Membership_ChangePasswordQuestionAndAnswer  Changes the specified user's password question and answer.
aspnet_Membership_CreateUser  Adds a new membership user to the membership database. Records the user in the aspnet_Users and aspnet_Membership tables and, if necessary, adds a new application to the aspnet_Applications table.
aspnet_Membership_FindUsersByEmail  Retrieves records from aspnet_Membership table with email addresses matching the specified pattern and with the specified application ID.
aspnet_Membership_FindUsersByName  Retrieves records from aspnet_Membership table with user names matching the specified pattern and with the specified application ID.
aspnet_Membership_GetAllUsers  Retrieves all users from the aspnet_Membership table with the specified application ID.
aspnet_Membership_GetNumberOfUsersOnline  Gets the number of users currently online (those whose last activity dates.
aspnet_Membership_GetPassword  Gets the specified user's password data from the database. Used for retrieving passwords with a user-supplied password answer.
aspnet_Membership_GetPasswordWithFormat  Gets the specified user's password from the database. Used by the provider to retrieve passwords for performing password comparisons (for example, when ValidateUser needs to validate a password).
aspnet_Membership_GetUserByEmail  Given an e-mail address and application ID, retrieves the corresponding record from the aspnet_Membership table.
aspnet_Membership_GetUserByName  Given a user name and application ID, retrieves the corresponding record from the aspnet_Membership table.
aspnet_Membership_GetUserByUserId  Given a user ID and application ID, retrieves the corresponding record from the aspnet_Membership table.
aspnet_Membership_ResetPassword  Resets the specified user's password based on a password answer.
aspnet_Membership_SetPassword  Sets the specified user's password to the password input to the stored procedure.
aspnet_Membership_UnlockUser  Restores login privileges for the specified user by setting the user's IsLockedOut bit to 0.
aspnet_Membership_UpdateUser  Updates the user's last activity date in the aspnet_Users table and e-mail address, comment, isapproved status, and last login date in the aspnet_Membership table.
aspnet_Membership_UpdateUserInfo  Updates account locking data for the specified user in the aspnet_Users and aspnet_Membership tables. Used in conjunction with provider methods that track bad password and bad password-answer attempts.
aspnet_Paths_CreatePath  Retrieves a path ID from the aspnet_Paths table, or creates a new one if the specified path doesn't exist.
aspnet_Personalization_GetApplicationId  Converts the application name input to it into an application ID.
aspnet_PersonalizationAdministration_DeleteAllState  Deletes all records from aspnet_PersonalizationAllUsers or aspnet_PersonalizationPerUser corresponding to the specified application ID.
aspnet_PersonalizationAdministration_FindState  Retrieves profile data from aspnet_PersonalizationAllUsers or aspnet_PersonalizationPerUser meeting several input criteria.
aspnet_PersonalizationAdministration_GetCountOfState  Returns a count of records in the aspnet_PersonalizationAllUsers table with path names matching the specified pattern, or a count of records in the aspnet_PersonalizationPerUser table meeting several input criteria.
aspnet_PersonalizationAdministration_ResetSharedState  Resets shared state for the specified page, by deleting the corresponding record from the aspnet_PersonalizationAllUsers table.
aspnet_PersonalizationAdministration_ResetUserState  Resets per-user state for the specified user and the specified page, by deleting the corresponding record from the aspnet_PersonalizationPerUser table. Can also delete records, based on the user's last activity date if it falls on or before the specified date.
aspnet_PersonalizationAllUsers_GetPageSettings  Retrieves shared state for the specified page from the aspnet_PersonalizationAllUsers table.
aspnet_PersonalizationAllUsers_ResetPageSettings  Resets shared state for the specified page, by deleting the corresponding record from the aspnet_PersonalizationAllUsers table.
aspnet_PersonalizationAllUsers_SetPageSettings  Saves shared state for the specified page in the aspnet_PersonalizationAllUsers table.
aspnet_PersonalizationPerUser_GetPageSettings  Retrieves per-user state for the specified page and the specified user from the aspnet_PersonalizationPerUser table.
aspnet_PersonalizationPerUser_ResetPageSettings  Resets per-user state for the specified page and the specified user, by deleting the corresponding record from the aspnet_PersonalizationPerUser table.
aspnet_PersonalizationPerUser_SetPageSettings  Saves per-user state for the specified page and the specified user in the aspnet_PersonalizationPerUser table.
aspnet_Profile_DeleteInactiveProfiles  Deletes profile data from the aspnet_Profile table for users whose last activity dates in the aspnet_Users table fall on or before the specified date.
aspnet_Profile_DeleteProfiles  Deletes profile data from the aspnet_Profile table for the specified users.
aspnet_Profile_GetNumberOfInactiveProfiles  Queries the aspnet_Profile table to get a count of profiles whose last activity dates (in the aspnet_Users table) fall on or before the specified date.
aspnet_Profile_GetProfiles  Retrieves profile data from the aspnet_Profile table for users who match the criteria input to the stored procedure.
aspnet_Profile_GetProperties  Retrieves profile data for the specified user.
aspnet_Profile_SetProperties  Saves profile data for the specified user.
aspnet_RegisterSchemaVersion  Registers the compatible schema required for the given feature.
aspnet_Roles_CreateRole  Adds a role to the aspnet_Roles table and, if necessary, adds a new application to the aspnet_Applications table.
aspnet_Roles_DeleteRole  Removes a role from the aspnet_Roles table. Optionally deletes records referencing the deleted role from the aspnet_UsersInRoles table.
aspnet_Roles_GetAllRoles  Retrieves all roles with the specified application ID from the aspnet_Roles table.
aspnet_Roles_RoleExists  Checks the aspnet_Roles table to determine whether the specified role exists.
aspnet_Setup_RemoveAllRoleMembers  Removes all roles from the given SQL account.
aspnet_Setup_RestorePermissions  Restores permissions to the given SQL account.
aspnet_UnRegisterSchemaVersion  Unregisters the schema version for the given feature.
aspnet_Users_CreateUser  Adds a user to the aspnet_Users table. Called by aspnet_Membership_CreateUser.
aspnet_Users_DeleteUser  Deletes a user from the aspnet_Membership table and optionally from other SQL provider tables, including aspnet_Users.
aspnet_UsersInRoles_AddUsersToRoles  Adds the specified users to the specified roles by adding them to the aspnet_UsersInRoles table.
aspnet_UsersInRoles_FindUsersInRole  Queries the aspnet_UsersInRoles table for all users belonging to the specified role whose user names match the specified pattern.
aspnet_UsersInRoles_GetRolesForUser  Queries the aspnet_UsersInRoles table for all roles assigned to a specified user.
aspnet_UsersInRoles_GetUsersInRoles  Queries the aspnet_UsersInRoles table for all users belonging to the specified role.
aspnet_UsersInRoles_IsUserInRole  Checks the aspnet_UsersInRoles table to determine whether the specified user belongs to the specified role.
aspnet_UsersInRoles_RemoveUsersFromRoles  Removes the specified users from the specified roles by deleting the corresponding records from the aspnet_UsersInRoles table.
aspnet_WebEvent_LogEvent  Records a Web event in the aspnet_WebEvents_Events table.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Membership Providers 

Membership providers provide the interface between Microsoft ASP.NET's membership service and membership data sources. ASP.NET 2.0 ships with two membership providers:
  • SqlMembershipProvider, which stores membership data in Microsoft SQL Server and SQL Server Express databases
  • ActiveDirectoryMembershipProvider, which retrieves membership data from Microsoft Active Directory
The fundamental job of a membership provider is to manage the data regarding a site's registered users, and to provide methods for creating users, deleting users, verifying login credentials, changing passwords, and so on.
System.Web.Security Namespace
Membership Class
MembershipUser Class
MembershipProvider Class
Membership Providers

SqlMembershipProvider

SqlMembershipProvider is the Microsoft membership provider for SQL Server databases.
SqlMembershipProvider Class

SqlMembershipProvider stores membership data in the aspnet_Membership table of the provider database. Each record in aspnet_Membership corresponds to one membership user.
Table: aspnet_Membership
Stored procedures used by SqlMembershipProvider

Relationships


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
Role Providers

Role providers provide the interface between Microsoft ASP.NET's role management service (the "role manager") and role data sources. ASP.NET 2.0 ships with three role providers:
  • SqlRoleProvider, which stores role data in Microsoft SQL Server and Microsoft SQL Server Express databases
  • AuthorizationStoreRoleProvider, which retrieves role information from Microsoft Authorization Manager ("AzMan")
  • WindowTokenRoleProvider, which retrieves role information from each user's Microsoft Windows authentication token, and returns his or her group membership(s).
The fundamental job of a role provider is to interface with data sources containing containing role data mapping users to roles, and to provide methods for creating roles, deleting roles, adding users to roles, and so on.
SqlRoleProvider Class
RoleProvider Class
Role Providers

SqlRoleProvider persists roles in the aspnet_Roles table of the provider database. Each record in aspnet_Roles corresponds to one role. The ApplicationId column refers to the column of the same name in the aspnet_Applications table, and it is used to scope roles by application.
Table: aspnet_Roles
Stored procedures used by SqlRoleProvider

Relationships: membership and roles 



--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
Profile Providers

Profile providers provide the interface between Microsoft ASP.NET's profile service and profile data sources. ASP.NET 2.0 ships with one profile provider: SqlProfileProvider, which stores profile data in Microsoft SQL Server and Microsoft SQL Server Express databases.
The fundamental job of a profile provider is to write profile property values supplied by ASP.NET to a persistent profile data source, and to read the property values back from the data source when requested by ASP.NET.

ASP.NET profiles are used to store and retrieve user settings in a data source such as a database. Profile information and property values are managed by using a profile provider. Profile information can be stored in a Microsoft SQL Server database by using the SqlProfileProvider class, or in a custom data source by using an implementation of the ProfileProvider abstract class.
ASP.NET profiles are configured by using the profile configuration section.
When an application starts that has profiles enabled, ASP.NET creates a new class of type ProfileCommon, which inherits from the ProfileBase class. Strongly typed accessors are added to the ProfileCommon class for each property that is defined in the profile configuration section. An instance of the ProfileCommon class is set as the value of the Profile property of the current HttpContext object. You can create a custom profile implementation that inherits from the ProfileBase abstract class and that defines properties for the user profile that are not specified in the profile configuration element.


System.Web.Profile Namespace
SqlProfileProvider Class
profile Element (ASP.NET Settings Schema)

SqlProfileProvider stores profile data in the aspnet_Profile table of the provider database. Each record in aspnet_Profile corresponds to one user's persisted profile properties.
Table: aspnet_Profile

Brak komentarzy:

Prześlij komentarz