[转]ASP.NET 2.0中MemberShip数据库的安装、配置及文档结构(一)
http://www.cnblogs.com/chenxinyong/archive/2008/07/07/1237741.html
ASP.NET 2.0 提供了许多十分有用的新特性,如MemberShip、RoleManager、Profile等等,可以很方便的在自己的应用程序中使用,解决登录认证、用户注册、权限管理等问题。
1 - AspNetDB数据库的安装。
在Visual Studio 2005菜单中选择Tool->命令提示->运行ASPNET_RegSql.Exe文件,按照提示即可顺利安装成功。
2 - Web.Config中的配置
可参考如下配置:
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<add connectionStringName="ConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="SigooFramework" requiresUniqueEmail="false" passwordFormat="Clear" minRequiredPasswordLength="1" passwordStrengthRegularExpression="" minRequiredNonalphanumericCharacters="0" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web" />
</providers>
</membership>
<roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="AspNetSqlRoleProvider">
<providers>
<add connectionStringName="ConnectionString" applicationName="SigooFramework" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
---------------------------------------------------------------------------------------------------------
一、Membership Provider
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=MySqlServer;Integrated
Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
<providers>
<remove name="AspNetSqlProvider" />
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
passwordFormat="Hashed"
applicationName="/" />
</providers>
</membership>
</system.web>
</configuration>
二、Role Provider
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=MySqlServer;Integrated
Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<roleManager defaultProvider="SqlProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieProtection="Encrypted">
<providers>
<clear/>
<add
name="SqlProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="SqlServices"
applicationName="MyApplication" />
</providers>
</roleManager>
</system.web>
</configuration>
三、Profile
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString=
"Data Source=MySqlServer;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<profile enabled="true" defaultProvider="SqlProvider">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="SqlServices"
applicationName="MyApplication" />
</providers>
</profile>
</system.web>
</configuration>
--------------------------------------------------------------------------------
参考资料:
http://msdn2.microsoft.com/zh-cn/library/system.web.security.membership.providers
(VS.80).aspx
http://msdn2.microsoft.com/zh-cn/library/system.web.security.roles.providers(vs.80).aspx
http://msdn2.microsoft.com/zh-cn/library/system.web.profile.profilemanager.providers
(VS.80).aspx
http://www.cnblogs.com/thcjp/archive/2006/11/19/565092.aspx
http://www.odetocode.com/Articles/427.aspx
http://www.odetocode.com/Articles/
3 - MemberShip数据库结构
aspnet_Applications |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
ApplicationId |
应用程序ID,唯一、主键 |
uniqueidentifier |
16 |
0 |
(newid()) |
|||
ApplicationName |
应用程序名称 |
nvarchar |
512 |
0 |
||||
LoweredApplicationName |
应用程序名称(小写) |
nvarchar |
512 |
0 |
||||
Description |
应用程序描述 |
nvarchar |
512 |
0 |
TOP
aspnet_Membership |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
UserId |
用户ID |
uniqueidentifier |
16 |
0 |
||||
ApplicationId |
应用程序ID |
uniqueidentifier |
16 |
0 |
||||
Password |
密码 |
nvarchar |
256 |
0 |
||||
PasswordFormat |
密码格式 |
int |
4 |
0 |
((0)) |
|||
PasswordSalt |
密码Salt字符串 |
nvarchar |
256 |
0 |
||||
MobilePIN |
验证码 |
nvarchar |
32 |
0 |
||||
|
电子邮件地址 |
nvarchar |
512 |
0 |
||||
LoweredEmail |
电子邮件地址(小写) |
nvarchar |
512 |
0 |
||||
PasswordQuestion |
密码提示问题 |
nvarchar |
512 |
0 |
||||
PasswordAnswer |
密码提示答案 |
nvarchar |
256 |
0 |
||||
IsApproved |
是否通过验证 |
bit |
1 |
0 |
||||
IsLockedOut |
是否解除锁定 |
bit |
1 |
0 |
||||
CreateDate |
创建时间 |
datetime |
8 |
3 |
||||
LastLoginDate |
上次登录时间 |
datetime |
8 |
3 |
||||
LastPasswordChangedDate |
上次密码修改时间 |
datetime |
8 |
3 |
||||
LastLockoutDate |
上次解除锁定时间 |
datetime |
8 |
3 |
||||
FailedPasswordAttemptCount |
密码输入错误次数 |
int |
4 |
0 |
||||
FailedPasswordAttemptWindowStart |
密码输入错误开始时间 |
datetime |
8 |
3 |
||||
FailedPasswordAnswerAttemptCount |
密码提示答案输入错误次数 |
int |
4 |
0 |
||||
FailedPasswordAnswerAttemptWindowStart |
密码提示答案输入开始时间 |
datetime |
8 |
3 |
||||
Comment |
备注 |
ntext |
3000 |
0 |
TOP
aspnet_Paths |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
PathId |
应用程序路径ID |
uniqueidentifier |
16 |
0 |
(newid()) |
|||
ApplicationId |
应用程序ID |
uniqueidentifier |
16 |
0 |
||||
Path |
应用程序路径 |
nvarchar |
512 |
0 |
||||
LoweredPath |
应用程序路径(小写) |
nvarchar |
512 |
0 |
TOP
aspnet_PersonalizationAllUsers |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
PathId |
应用程序路径ID |
uniqueidentifier |
16 |
0 |
||||
PageSettings |
页面设置 |
image |
6000 |
0 |
||||
LastUpdatedDate |
上次更新时间 |
datetime |
8 |
3 |
TOP
aspnet_PersonalizationPerUser |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
Id |
唯一主键 |
uniqueidentifier |
16 |
0 |
(newid()) |
|||
PathId |
应用程序ID |
uniqueidentifier |
16 |
0 |
||||
UserId |
用户ID |
uniqueidentifier |
16 |
0 |
||||
PageSettings |
页面设置 |
image |
6000 |
0 |
||||
LastUpdatedDate |
上传更新时间 |
datetime |
8 |
3 |
TOP
aspnet_Profile |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
UserId |
用户ID、唯一、主键 |
uniqueidentifier |
16 |
0 |
||||
PropertyNames |
属性名称 |
ntext |
6000 |
0 |
||||
PropertyValuesString |
属性值(字符串) |
ntext |
6000 |
0 |
||||
PropertyValuesBinary |
属性值(二进制) |
image |
6000 |
0 |
||||
LastUpdatedDate |
上次更新时间 |
datetime |
8 |
3 |
TOP
aspnet_Roles |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
RoleId |
角色ID、主键 |
uniqueidentifier |
16 |
0 |
(newid()) |
|||
ApplicationId |
应用程序ID |
uniqueidentifier |
16 |
0 |
||||
RoleName |
角色名称 |
nvarchar |
512 |
0 |
||||
LoweredRoleName |
角色名称(小写) |
nvarchar |
512 |
0 |
||||
Description |
描述 |
nvarchar |
512 |
0 |
TOP
aspnet_SchemaVersions |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
Feature |
特性 |
nvarchar |
256 |
0 |
||||
CompatibleSchemaVersion |
并行模式版本 |
nvarchar |
256 |
0 |
||||
IsCurrentVersion |
是否当前版本 |
bit |
1 |
0 |
TOP
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
UserId |
用户ID、唯一、主键 |
uniqueidentifier |
16 |
0 |
(newid()) |
|||
ApplicationId |
应用程序ID |
uniqueidentifier |
16 |
0 |
||||
UserName |
用户名称 |
nvarchar |
512 |
0 |
||||
LoweredUserName |
用户名称(小写) |
nvarchar |
512 |
0 |
||||
MobileAlias |
昵称 |
nvarchar |
32 |
0 |
(NULL) |
|||
IsAnonymous |
是否匿名用户 |
bit |
1 |
0 |
((0)) |
|||
LastActivityDate |
最后一次活动时间 |
datetime |
8 |
3 |
TOP
aspnet_UsersInRoles |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
UserId |
用户ID |
uniqueidentifier |
16 |
0 |
||||
RoleId |
角色ID |
uniqueidentifier |
16 |
0 |
TOP
aspnet_WebEvent_Events |
||||||||
代码 |
注释 |
类型 |
长度 |
小数 |
默认值 |
标识 |
主键 |
空值 |
EventId |
事件ID |
char |
32 |
0 |
||||
EventTimeUtc |
事件时间Utc |
datetime |
8 |
3 |
||||
EventTime |
事件时间 |
datetime |
8 |
3 |
||||
EventType |
事件类型 |
nvarchar |
512 |
0 |
||||
EventSequence |
事件发生顺序 |
decimal |
9 |
0 |
||||
EventOccurrence |
事件发生频率 |
decimal |
9 |
0 |
||||
EventCode |
事件码 |
int |
4 |
0 |
||||
EventDetailCode |
事件明细码 |
int |
4 |
0 |
||||
Message |
消息 |
nvarchar |
2048 |
0 |
||||
ApplicationPath |
应用程序路径 |
nvarchar |
512 |
0 |
||||
ApplicationVirtualPath |
应用程序虚拟路径 |
nvarchar |
512 |
0 |
||||
MachineName |
机器名称 |
nvarchar |
512 |
0 |
||||
RequestUrl |
请求URL |
nvarchar |
2048 |
0 |
||||
ExceptionType |
异常类型 |
nvarchar |
512 |
0 |
||||
Details |
异常明细 |
ntext |
16 |
0 |