国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
DotNetNuke與MemberShip的結合 -- 博客園
DotNetNuke與MemberShip的結合
Posted on 2006-07-13 15:05二十四畫生 閱讀(3015)評論(4)  編輯  收藏 所屬分類:DotNetNuke(DNN)
DotNetNuke(以下簡稱DNN)采用與MemberShip結合的方式實現身份驗證功能。DNN4.3.x和DNN3.3.x版本相對于以前版本對用戶部分進行了很大的改進。具體結合MemberShip實現身份認證,從數據庫上分析如下:
關系圖如下:
相關表含義:
aspnet_Users:用戶信息表
字段名稱
含義
類型
備注
ApplicationId
應用程序ID
Uniqueidentifier
UserId
用戶ID
Uniqueidentifier
Username
用戶名
Nvarchar(256)
LoweredUserName
Nvarchar(256)
LastName
Nvarchar(50)
MobileAlias
Nvarchar(16)
IsAnonymous
Bit
LastActivityDate
Datetime
aspnet_Membership:成員信息表
字段名稱
含義
類型
備注
ApplicationId
應用程序ID
Uniqueidentifier
UserId
用戶ID
Uniqueidentifier
Password
密碼
Nvarchar(128)
PasswordFormat
密碼加密方式
Int
PasswordSalt
密碼散列
Nvarchar(128)
----------------
其余的字段關系不大,主要是結合Membership功能的
-----------------
Users:DNN用戶表
字段名稱
含義
類型
備注
UserID
用戶ID
Int
Username
用戶名
Nvarchar(100)
FirstName
Nvarchar(50)
LastName
Nvarchar(50)
IsSuperUser
是否是超級用戶
Bit
AffiliateId
聯盟商ID
Int
會員介紹人ID
Email
電子郵件地址
Nvarchar(256)
DisplayName
昵稱
Nvarchar(128)
UpdatePassword
是否要求用戶定期更新密碼
Bit
UserProfile:用戶資料表(存儲用戶詳細資料,如:地址信息,聯系方式等)
字段名稱
含義
類型
備注
ProfileID
用戶資料ID
Int
UserID
用戶ID
Int
PropertyDefinitionID
用戶資料信息定義ID
Int
PropertyValue
用戶資料信息值
Nvarchar(3750)
PropertyText
---------
Visibility
可見性
Int
0:公開;1:保密;2:管理員可見
LastUpdatedDate
最后更新時間
Datetime
ProfilePropertyDefinition:個人資料屬性定義
字段名稱
含義
類型
備注
PropertyDefinitionID
個人資料屬性定義ID
Int
PortalID
站點ID
Int
ModuleDefID
模塊定義ID
Int
指定該屬性可以屬于一個的制定的模塊,不指定值為-1
Deleted
是否刪除
Bit
DataType
數據類型
Int
DefaultValue
默認值
Nvarchar(50)
PropertyCategory
屬性分類
Nvarchar(50)
PropertyName
屬性名稱
Nvarchar(50)
Length
屬性值長度
Int
Required
是否必添
Bit
ValidationExpression
驗證規(guī)則
Nvarchar(100)
ViewOrder
排序號
Int
Visible
是否可見
Bit
DotNetNuke與MemberShip的結合(五年版)
Posted on 2007-08-13 21:01五年 閱讀(1597)評論(3)  編輯  收藏 所屬分類:DotNetNuke
24畫生有一篇同名文章(http://www.cnblogs.com/esshs/archive/2006/07/13/449888.html),但他只是列一下數據庫表與字段,并沒有展開講述.
下面我以DNN4.5.5為源碼版本站在24畫生的肩旁上再展開講述.
由上面三圖可見,DNN系統設計中的MemberShip是完全獨立于DNN其他表的,那么能不能將整個MemberShip獨立放一個表中,或直接使用已經存在的MemberShip表?由于上面的表是相對獨立的,沒有直接關系,所以理論上是可以的.實際上可以嗎?做個實驗.
在web.config中增加一個數據連接字符串.SiteSqlServer1,并且指向已經存在的MemberShip數據庫ASPNETDB,其中DNN4_5_5是空數據庫,即DNN并未安裝,ASPNETDB是一個現存系統的MemberShip數據庫.
<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>
將AspNetSqlMembershipProvider的配置connectionStringName="SiteSqlServer"改成 connectionStringName="SiteSqlServer1"如下.
<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]"      Should the provider support password retrievals
enablePasswordReset="[true|false]"          Should the provider support password resets
requiresQuestionAndAnswer="[true|false]"    Should the provider require Q & A
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]"          Should 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" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="false" passwordFormat="Encrypted" applicationName="/" description="Stores and retrieves membership data from the local Microsoft SQL Server database" />
</providers>
</membership>
這樣運行的結果是:
DNN成功安裝,DNN4_5_5數據庫中有MemberShip的所有表,但是里面全為空,host,admin的賬號在ASPNETDB的MemberShip表中,用host,admin賬號登錄成功.DNN運行一切正常.
這面意味著:DNN可以很方便地與其他同樣以MemberShip為身份驗證的系統整合.
再分析相關代碼:
舉例: 刪除用戶方法
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) ‘ 刪除dnn_User表中的用戶記錄
‘Delete AspNet MemrshipUser
retValue = DeleteMembershipUser(user)  ‘刪除Membership表中的用戶記錄(至于Membership相關表在哪里,在這里是透明的,DNN并不在意他在哪里.)
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
‘刪除Membership表中的用戶記錄(至于Membership相關表在哪里,在這里是透明的,DNN并不在意他在哪里.)
AspNetSecurity.Membership.DeleteUser(user.Username, True)
Catch ex As Exception
retValue = False
End Try
Return retValue
End Function
我比較喜歡這樣的設計,因為這樣,不管多少系統,只要基于MemberShip就可以很方便地整合在一起.實現單點登陸.
本文發(fā)布于:http://shiningrise.cnblogs.com轉載請保留此簽名.
添加membership用戶到DNN數據庫
Posted on 2007-08-22 00:47五年 閱讀(1241)評論(4)  編輯  收藏 所屬分類:DotNetNuke
在我的 <<DotNetNuke與MemberShip的結合(五年版)>>中提出將DNN的身份認證指出現在的membership數據庫.而且,admin,host用戶可以正常登錄.但我們用membership數據庫中現在有的用戶登錄,就會發(fā)現不能成功登錄.
看相關源碼:Provider.Membership.AspNetProvider(AspNetMembershipProvider.vb)
Public Overrides Function UserLogin(ByVal portalId As Integer, ByVal username As String, ByVal password As String, ByVal verificationCode As String, ByRef loginStatus As UserLoginStatus) As UserInfo
‘For now, we are going to ignore the possibility that the User may exist in the
‘Global Data Store but not in the Local DataStore ie. A shared Global Data Store
‘Initialise Login Status to Failure
loginStatus = UserLoginStatus.LOGIN_FAILURE
‘Get a light-weight (unhydrated) DNN User from the Database, we will hydrate it later if neccessary
Dim user As UserInfo = Nothing
user = GetUserByUserName(portalId, username, False)
If Not user Is Nothing Then
‘Get AspNet MembershipUser
Dim aspnetUser As AspNetSecurity.MembershipUser = Nothing
aspnetUser = GetMembershipUser(user)
‘Fill Membership Property from AspNet MembershipUser
FillUserMembership(aspnetUser, user)
‘Check if the User is Locked Out (and unlock if AutoUnlock has expired)
If aspnetUser.IsLockedOut Then
Dim intTimeout As Integer = Null.NullInteger
If Not HostSettings("AutoAccountUnlockDuration") Is Nothing Then
Dim strTimeout As String = Convert.ToString(HostSettings("AutoAccountUnlockDuration"))
If Not String.IsNullOrEmpty(strTimeout) Then
intTimeout = Convert.ToInt32(strTimeout)
End If
End If
If intTimeout <> 0 Then
If intTimeout = Null.NullInteger Then
intTimeout = 10
End If
If aspnetUser.LastLockoutDate < Date.Now.AddMinutes(-1 * intTimeout) Then
‘Unlock User
user.Membership.LockedOut = False
‘Persist to Data Store
aspnetUser.UnlockUser()
Else
loginStatus = UserLoginStatus.LOGIN_USERLOCKEDOUT
End If
End If
End If
‘Check in a verified situation whether the user is Approved
If user.Membership.Approved = False And user.IsSuperUser = False Then
‘Check Verification code
If verificationCode = (portalId.ToString & "-" & user.UserID) Then
‘Approve User
user.Membership.Approved = True
‘Persist to Data Store
UpdateUser(user)
Else
loginStatus = UserLoginStatus.LOGIN_USERNOTAPPROVED
End If
End If
‘Verify User Credentials
Dim bValid As Boolean = False
If loginStatus <> UserLoginStatus.LOGIN_USERLOCKEDOUT And loginStatus <> UserLoginStatus.LOGIN_USERNOTAPPROVED Then
If user.IsSuperUser Then
If ValidateUser(Null.NullInteger, username, password) Then
loginStatus = UserLoginStatus.LOGIN_SUPERUSER
bValid = True
End If
Else
If ValidateUser(portalId, username, password) Then
loginStatus = UserLoginStatus.LOGIN_SUCCESS
bValid = True
End If
End If
End If
If Not bValid Then
‘Clear the user object
user = Nothing
End If
End If
Return user
End Function
其中有三句關鍵
Dim user As UserInfo = Nothing
user = GetUserByUserName(portalId, username, False)
If Not user Is Nothing Then
意思就是,要先讀取DNN用戶數據表中的用戶即dnn_Users中的用戶.而以<<DotNetNuke與MemberShip的結合(五年版)>>辦法安裝的DNN數據庫,在membership中原有的用戶,在dnn_Users中卻并不存在相應的用戶,所以出現用membership中原有的用戶無法登錄DNN.
我作了下面修正,讓登錄DNN的用戶如果只存在于membership中而不存在于dnn_Users中的數據自動添加.
改到處關鍵原碼
Public Overrides Function UserLogin(ByVal portalId As Integer, ByVal username As String, ByVal password As String, ByVal verificationCode As String, ByRef loginStatus As UserLoginStatus) As UserInfo
‘For now, we are going to ignore the possibility that the User may exist in the
‘Global Data Store but not in the Local DataStore ie. A shared Global Data Store
‘Initialise Login Status to Failure
loginStatus = UserLoginStatus.LOGIN_FAILURE
‘Get AspNet MembershipUser
Dim aspnetUser As AspNetSecurity.MembershipUser = Nothing
aspnetUser = GetMembershipUser(username)
If aspnetUser Is Nothing Then
Return Nothing
End If
‘Get a light-weight (unhydrated) DNN User from the Database, we will hydrate it later if neccessary
Dim user As UserInfo = Nothing
user = GetUserByUserName(portalId, username, False)
If (user Is Nothing) Then
按照一個AspNetMembershipProvider新建一個項目
Public Class AspNetMembershipProviderFiveYears
Inherits DotNetNuke.Security.Membership.MembershipProvider
改web.config增加一個AspNetMembershipProvider,并設置為defaultProvider
<members defaultProvider="AspNetMembershipProviderFiveYears">
<providers>
<clear />
<add name="AspNetMembershipProvider" type="DotNetNuke.Security.Membership.AspNetMembershipProvider, DotNetNuke.Provider.AspNetProvider" providerPath="~\Providers\MembershipProviders\AspNetMembershipProvider\" />
<add name="AspNetMembershipProviderFiveYears" type="DotNetNuke.Security.Membership.AspNetMembershipProviderFiveYears, DotNetNuke.Provider.AspNetProviderFiveYears" providerPath="~\Providers\MembershipProviders\AspNetMembershipProviderFiveYears\" />
</providers>
</members>
源碼下載:點擊下載
相關文章: <<DotNetNuke與MemberShip的結合(五年版)>>
http://www.cnblogs.com/shiningrise/archive/2007/08/13/854297.html
本文發(fā)布于:http://shiningrise.cnblogs.com轉載請保留此簽名.
本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現有害或侵權內容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
DNN系統構架圖 - m2land-專注DNN(DotNetNuke) - 博客園
我的未來學習方向
掌握 asp.net 之路:自定義實體類簡介
使用membership(System.Web.Security)來進行角色與權_2009...
DNN模塊開發(fā)系列文章(2)——建立模塊開發(fā)項目
搭建基于ASP.NET 2.0的DNN 4.X模塊開發(fā)環(huán)境及模塊實例
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯系客服!

聯系客服