乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      DotNetNuke與MemberShip的結(jié)合 -- 博客園

       kommy 2007-09-13
               DotNetNuke(以下簡(jiǎn)稱DNN)采用與MemberShip結(jié)合的方式實(shí)現(xiàn)身份驗(yàn)證功能。DNN4.3.x和DNN3.3.x版本相對(duì)于以前版本對(duì)用戶部分進(jìn)行了很大的改進(jìn)。具體結(jié)合MemberShip實(shí)現(xiàn)身份認(rèn)證,從數(shù)據(jù)庫(kù)上分析如下:

      關(guān)系圖如下:

      相關(guān)表含義:

      aspnet_Users:用戶信息表

      字段名稱

      含義

      類型

      備注

      ApplicationId

      應(yīng)用程序ID

      Uniqueidentifier

       

      UserId

      用戶ID

      Uniqueidentifier

       

      Username

      用戶名

      Nvarchar(256)

       

      LoweredUserName

       

      Nvarchar(256)

       

      LastName

       

      Nvarchar(50)

       

      MobileAlias

       

      Nvarchar(16)

       

      IsAnonymous

       

      Bit

       

      LastActivityDate

       

      Datetime

       

       

      aspnet_Membership:成員信息表

      字段名稱

      含義

      類型

      備注

      ApplicationId

      應(yīng)用程序ID

      Uniqueidentifier

       

      UserId

      用戶ID

      Uniqueidentifier

       

      Password

      密碼

      Nvarchar(128)

       

      PasswordFormat

      密碼加密方式

      Int

       

      PasswordSalt

      密碼散列

      Nvarchar(128)

       

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

       

       

       

      其余的字段關(guān)系不大,主要是結(jié)合Membership功能的

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

       

       

       

       

      UsersDNN用戶表

      字段名稱

      含義

      類型

      備注

      UserID

      用戶ID

      Int

       

      Username

      用戶名

      Nvarchar(100)

       

      FirstName

      Nvarchar(50)

       

      LastName

      Nvarchar(50)

       

      IsSuperUser

      是否是超級(jí)用戶

      Bit

       

      AffiliateId

      聯(lián)盟商ID

      Int

      會(huì)員介紹人ID

      Email

      電子郵件地址

      Nvarchar(256)

       

      DisplayName

      昵稱

      Nvarchar(128)

       

      UpdatePassword

      是否要求用戶定期更新密碼

      Bit

       

       

      UserProfile:用戶資料表(存儲(chǔ)用戶詳細(xì)資料,如:地址信息,聯(lián)系方式等)

      字段名稱

      含義

      類型

      備注

      ProfileID

      用戶資料ID

      Int

       

      UserID

      用戶ID

      Int

       

      PropertyDefinitionID

      用戶資料信息定義ID

      Int

       

      PropertyValue

      用戶資料信息值

      Nvarchar(3750)

       

      PropertyText

      ---------

       

       

      Visibility

      可見(jiàn)性

      Int

      0:公開(kāi);1:保密;2:管理員可見(jiàn)

      LastUpdatedDate

      最后更新時(shí)間

      Datetime

       

       

      ProfilePropertyDefinition:個(gè)人資料屬性定義

      字段名稱

      含義

      類型

      備注

      PropertyDefinitionID

      個(gè)人資料屬性定義ID

      Int

       

      PortalID

      站點(diǎn)ID

      Int

       

      ModuleDefID

      模塊定義ID

      Int

      指定該屬性可以屬于一個(gè)的制定的模塊,不指定值為-1

      Deleted

      是否刪除

      Bit

       

      DataType

      數(shù)據(jù)類型

      Int

       

      DefaultValue

      默認(rèn)值

      Nvarchar(50)

       

      PropertyCategory

      屬性分類

      Nvarchar(50)

       

      PropertyName

      屬性名稱

      Nvarchar(50)

       

      Length

      屬性值長(zhǎng)度

      Int

       

      Required

      是否必添

      Bit

       

      ValidationExpression

      驗(yàn)證規(guī)則

      Nvarchar(100)

       

      ViewOrder

      排序號(hào)

      Int

       

      Visible

      是否可見(jiàn)

      Bit

       

        

       

      DotNetNuke與MemberShip的結(jié)合(五年版)

      Posted on 2007-08-13 21:01 五年 閱讀(1597) 評(píng)論(3)  編輯  收藏 所屬分類: DotNetNuke

      24畫(huà)生有一篇同名文章(http://www.cnblogs.com/esshs/archive/2006/07/13/449888.html),但他只是列一下數(shù)據(jù)庫(kù)表與字段,并沒(méi)有展開(kāi)講述.

      下面我以DNN4.5.5為源碼版本站在24畫(huà)生的肩旁上再展開(kāi)講述.

       

      DNN_membership1 

      DNN_membership

      由上面三圖可見(jiàn),DNN系統(tǒng)設(shè)計(jì)中的MemberShip是完全獨(dú)立于DNN其他表的,那么能不能將整個(gè)MemberShip獨(dú)立放一個(gè)表中,或直接使用已經(jīng)存在的MemberShip表?由于上面的表是相對(duì)獨(dú)立的,沒(méi)有直接關(guān)系,所以理論上是可以的.實(shí)際上可以嗎?做個(gè)實(shí)驗(yàn).

       在web.config中增加一個(gè)數(shù)據(jù)連接字符串.SiteSqlServer1,并且指向已經(jīng)存在的MemberShip數(shù)據(jù)庫(kù)ASPNETDB,其中DNN4_5_5是空數(shù)據(jù)庫(kù),即DNN并未安裝,ASPNETDB是一個(gè)現(xiàn)存系統(tǒng)的MemberShip數(shù)據(jù)庫(kù).

       <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>

      這樣運(yùn)行的結(jié)果是:

      DNN成功安裝,DNN4_5_5數(shù)據(jù)庫(kù)中有MemberShip的所有表,但是里面全為空,host,admin的賬號(hào)在ASPNETDB的MemberShip表中,用host,admin賬號(hào)登錄成功.DNN運(yùn)行一切正常.

      這面意味著:DNN可以很方便地與其他同樣以MemberShip為身份驗(yàn)證的系統(tǒng)整合.

      再分析相關(guān)代碼:

      AspNetMembershipProvider

      舉例: 刪除用戶方法

      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相關(guān)表在哪里,在這里是透明的,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相關(guān)表在哪里,在這里是透明的,DNN并不在意他在哪里.)
              AspNetSecurity.Membership.DeleteUser(user.Username, True)
          Catch ex As Exception
              retValue = False
          End Try
          Return retValue
      End Function

      我比較喜歡這樣的設(shè)計(jì),因?yàn)檫@樣,不管多少系統(tǒng),只要基于MemberShip就可以很方便地整合在一起.實(shí)現(xiàn)單點(diǎn)登陸.



      本文發(fā)布于:http://shiningrise.cnblogs.com
      轉(zhuǎn)載請(qǐng)保留此簽名.
       
       
       

      添加membership用戶到DNN數(shù)據(jù)庫(kù)

      Posted on 2007-08-22 00:47 五年 閱讀(1241) 評(píng)論(4)  編輯  收藏 所屬分類: DotNetNuke

      在我的 <<DotNetNukeMemberShip的結(jié)合(五年版)>>中提出將DNN的身份認(rèn)證指出現(xiàn)在的membership數(shù)據(jù)庫(kù).而且,admin,host用戶可以正常登錄.但我們用membership數(shù)據(jù)庫(kù)中現(xiàn)在有的用戶登錄,就會(huì)發(fā)現(xiàn)不能成功登錄.

      看相關(guān)源碼: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

      其中有三句關(guān)鍵

      Dim user As UserInfo = Nothing

      user = GetUserByUserName(portalId, username, False)

       

      If Not user Is Nothing Then

      意思就是,要先讀取DNN用戶數(shù)據(jù)表中的用戶即dnn_Users中的用戶.而以<<DotNetNukeMemberShip的結(jié)合(五年版)>>辦法安裝的DNN數(shù)據(jù)庫(kù),membership中原有的用戶,dnn_Users中卻并不存在相應(yīng)的用戶,所以出現(xiàn)用membership中原有的用戶無(wú)法登錄DNN.

      我作了下面修正,讓登錄DNN的用戶如果只存在于membership中而不存在于dnn_Users中的數(shù)據(jù)自動(dòng)添加.

      改到處關(guān)鍵原碼

      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

      按照一個(gè)AspNetMembershipProvider新建一個(gè)項(xiàng)目

      Public Class AspNetMembershipProviderFiveYears

      Inherits DotNetNuke.Security.Membership.MembershipProvider

      web.config增加一個(gè)AspNetMembershipProvider,并設(shè)置為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>

       

      源碼下載:點(diǎn)擊下載

      相關(guān)文章: <<DotNetNukeMemberShip的結(jié)合(五年版)>>
      http://www.cnblogs.com/shiningrise/archive/2007/08/13/854297.html



      本文發(fā)布于:http://shiningrise.cnblogs.com
      轉(zhuǎn)載請(qǐng)保留此簽名.
       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多