The painting has an article of the same name (http://www.cnblogs.com/esshs/archive/2006/07/13/449888.html), but he just columns the database table and fields, and did not show.
Next I will use dnn4.5.5 as the source code to stand on the shoulder of the 24-day painting.
As shown in the preceding three figures, the membership in the dnn system design is completely independent from other dnn tables.Can I independently store the entire membership in one table or directly use an existing membership table?Since the table above is relatively independent and has no direct relationship, it is theoretically possible. Is it actually possible? Make an experiment.
In the web. add a data connection string in config. sitesqlserver1, pointing to the existing membership database aspnetdb, where dnn4_5_5 is an empty database, that is, the dnn is not installed, and aspnetdb is an existing membership database.
<Connectionstrings>
<! -- Connection string for SQL Server 2005 Express
<Add
Name = "sitesqlserver"
Connectionstring = "Data Source =. \ sqlexpress; Integrated Security = true; user instance = true; attachdbfilename = | datadirectory | database. MDF ;"
Providername = "system. Data. sqlclient"/>
-->
<! -- Connection string for SQL Server 2000/2005 -->
<Add name = "sitesqlserver" connectionstring = "Data Source = (local); initial catalog = dnn4_5_5; user id = sa; Password =" providername = "system. data. sqlclient "/>
<Add name = "sitesqlserver1" connectionstring = "Data Source = (local); initial catalog = aspnetdb; user id = sa; Password =" providername = "system. data. sqlclient "/>
</Connectionstrings>
Change the configuration connectionstringname = "sitesqlserver" of aspnetsqlmembershipprovider to connectionstringname = "sitesqlserver1" as follows.
<Membership defaultprovider = "aspnetsqlmembershipprovider" userisonlinetimewindow = "15">
<Providers>
<Clear/>
<! -- Configuration for dnnsqlmembershipprovider:
Connectionstringname = "string" name corresponding to the entry in <connectionstrings> section where the connection string for the provider is specified
Passwordattemptthreshold = "int" the number of failed password attempts, or failed password answer attempts that are allowed before locking out a user? S account
Passwordattemptwindow = "int" the time window, in minutes, during which failed password attempts and failed password answer attempts are tracked
Enablepasswordretrieval = "[true | false]" shocould the provider support password retrievals
Enablepasswordreset = "[true | false]" shocould the provider support password resets
Requiresquestionandanswer = "[true | false]" shocould the provider require Q &
Minrequiredpasswordlength = "int" the Minimum Password Length
Minrequirednonalphanumericcharacters = "int" the minimum number of non-alphanumeric characters
Applicationname = "string" Optional string to identity the application: defaults to application metabase path
Requiresuniqueemail = "[true | false]" shocould the provider require a unique email to be specified
Passwordformat = "[clear | hashed | encrypted]" storage format for the password: hashed (sha1), clear or encrypted (triple-DES)
Description = "string" description of what the provider does
-->
<Add name = "aspnetsqlmembershipprovider" type = "system. web. security. sqlmembershipprovider "connectionstringname =" sitesqlserver1 "feature =" true "enablepasswordreset =" true "feature =" false "feature =" 7 "feature =" 0 "requiresuniqueemail =" false "passwordformat =" encrypted "applicationname ="/"Description =" stores and retrieves membership data from the local Microsoft SQL Server database "/>
</Providers>
</Membership>
The result is as follows:
Dnn is successfully installed. dnn4_5_5 has all membership tables, but it is empty. The host and Admin accounts are successfully logged on to the membership table of aspnetdb with the host and Admin accounts. dnn runs normally.
This means:Dnn can be easily integrated with other systems that are also authenticated by membership.
Analyze the relevant code:
Example: how to delete a user
Public overrides function deleteuser (byval user as userinfo) as Boolean
Dim retvalue as Boolean = true
Dim Dr as idatareader
Try
Dr = dataprovider. getrolesbyuser (user. userid, user. portalid)
While dr. Read
Dataprovider. deleteuserrole (user. userid, convert. toint32 (DR ("roleid ")))
End while
Dr. Close ()
'Check if user exists in any other portal
Dr = dataprovider. getuserbyusername (-1, user. username)
Dr. Read ()
If not dr. Read then
Dataprovider. deleteuser (user. userid) 'deletes user records in the dnn_user table
'Delete ASPnet memrshipuser
Retvalue = deletemembershipuser (User) 'deletes user records in the membership table (where the membership table is located, it is transparent here, And dnn does not care where it is .)
Else
Dataprovider. deleteuserportal (user. userid, user. portalid)
End if
Dr. Close ()
Catch ex as exception
Retvalue = false
End try
Return retvalue
End Function
Private function deletemembershipuser (byval user as userinfo) as Boolean
Dim retvalue as Boolean = true
Try
'Delete the user records in the membership table (where the membership table is located, it is transparent here, And dnn does not care where it is .)
Aspnetsecurity. Membership. deleteuser (user. username, true)
Catch ex as exception
Retvalue = false
End try
Return retvalue
End Function
I prefer this design because, no matter how many systems, it is easy to integrate membership-based systems to achieve single-point login.