Installing CS 1.1 under DNN 3.1

本文介绍了Dot Net Nuke和Community Server的集成方法。包括上传CS二进制文件、配置IIS、更新相关配置文件、复制文件、安装CS到数据库等步骤,还提及了集成登录的操作及处理新用户创建和用户管理的问题。

As we continue to look at potential integration paths between Dot Net Nuke and Community Server, I thought it would be nice to get the two running under the same IIS website...  Actually to do this is rather quite simple...  All you HAVE to do, is:

  1. Upload the latest CS binaries to a folder on your site
  2. Mark the \Web directory as an application in IIS, or better yet, make it a Virtual Directory in IIS under DNN called something original like "CS"
  3. You *should* ensure that the ASPNET or NETWORK SERVICE accounts have at least write access to the CS folders, well BLOGS and GALLERIES, (this will already be the case if you installed this under your DNN directory)
  4. Update the DNN siteurls.config to tell DNN where to send requests to your CS installation (where the CS below is the web path to the CS install)

    <RewriterRule>
         <LookFor>.*/CS/(.*)</LookFor>
         <SendTo>~/CS/$1</SendTo>
    </RewriterRule>


  5. Update the Web.Config for Community Server, You need to remove some HTTPModules (by adding the following tags) and comment out the CS "TimeZone" provider property.

    <httpModules>
    <!-- remove DNN modules that interfere with CS-->
          <remove name="ProfilePrototype"/>
          <remove name="AnonymousIdentificationPrototype"/>
          <remove name="RoleManagerPrototype"/>
          <remove name="DNNMembership"/>
          <remove name="Personalization"/>
          <remove name="UrlRewrite" />
          <remove name="Exception"/>
          <remove name="UsersOnline"/>



    and

    <properties>
          <!--add name="timezone" type="System.Double" defaultValue="0" /-->

  6. Copy the following files from your DNN \bin folder into the CS \bin folder

    DNNSQLMembershipProvider.dll
    DNNSQLProfileProvider.dll
    DNNSQLRoleProvider.dll
    DotNetNuke.dll
    DotNetNuke.HttpModules.DNNMembership.dll
    DotNetNuke.HttpModules.Exception.dll
    DotNetNuke.HttpModules.Personlization.dll
    DotNetNuke.HttpModules.URLRewrite.dll
    DotNetNuke.HttpModules.UsersOnline.dll

  7. Edit the CS\Web\Installer\Default.aspx file and set INSTALLER_ENABLED = true;
  8. Navigate to the CS installer page (something like http://localhost/DotNetNuke/CS/Installer)...  Installing CS into any Database you Choose...  I recommend the same database as your DNN installation.

Now that should get you a working CS install under DNN, the only real "magic" involved was the DNN siteurls.config.  This allows you to have a CS site running along side you DNN installation...  Also if you have installed CS into your DNN directory you are a step closer to having integrated logins.

To integrate the logins with a portal on your DNN installation, you need to have created your CS install under your DNN application, and then you need do a couple more steps. (I highly recommend you do these, they extend the steps before 6 above and replace 7 and 8)

  1. Remove the "MachineValidationKey", "MachineDecryptionKey", "MachineValidationMode" and the entire "Authentication" region from the CS Web.Config; we are going to let the DNN Web.Config specify these settings.
  2. Add a MachineKey tag to the system.web section of the DNN Web.Config.  This is required to let CS and DNN share your login token.

    <machineKey
                validationKey= "[PUT YOUR ValidationDecryptionKey HERE]"
                decryptionKey= "[PUT YOUR MachineDecryptionKey HERE]"
                validation="SHA1"/>


  3. Go into your DNN portal Security Roles, and Add: "BlogAdministrator", "Everyone" (Go ahead and make this one Auto Assign), "FourmsAdministrator", "GalleryAdministrator", "SystemAdministrator", "Moderator", and "Editor" (CS will also share the existing Registered Users role)
  4. Go into your DNN portal User Accounts and create a user named "Anonymous"; also if you want to make a separate user for the CS admin you should do that now, I just use the DNN "admin" user.
  5. Install the CS database by running the following SQL scripts in order against your DNN database.. (the scripts are located in the CS\Web\Installer\SQLScripts folder)

    cs_Schema.SQL
    cs_Default.SQL
    cs_Procedures.SQL

  6. Now we need to update the CS 1.1 stored procedure named cs_system_CreateCommunity, to make it DNN friendly.  Download an run this sql script against your DNN database.
  7. Manually edit the CS Web.Config and comment out the "SiteSQLServer" key, we are going to inherit the one from DNN
  8. Run the cs_system_CreateCommunity sproc against the portal you wish to link the logins to: (replace the ApplicationName with the portal number you want to link the logins to, and of course use your SiteURL, Admin UserName, and Admin Password for this step)

    DECLARE @RC int
    DECLARE @SiteUrl nvarchar(512)
    DECLARE @ApplicationName nvarchar(512)
    DECLARE @AdminUserName nvarchar(256)
    DECLARE @AdminPassword nvarchar(256)
    DECLARE @CreateSamples bit

    SET @SiteURL = 'localhost/dotnetnuke/cs';
    SET @ApplicationName = '0';
    SET @AdminUserName = 'admin'
    SET @AdminPassword = 'admin'
    SET @CreateSamples = 0;

    EXECUTE @RC = [dbo].[cs_system_CreateCommunity]
       @SiteUrl
      ,@ApplicationName
      ,@AdminUserName
      ,@AdminPassword
      ,@CreateSamples

That should do it, you can register multiple DNN portals in CS, the only rule is that they have to have a unique "SiteURL"; so under this scheme, only portals with unique URLS can be tied to CS installs, DNN "Sub Portals" are not part of the CS URL and therefore do not qualify.

This leaves us with a couple of loose ends; new users created in DNN will not be automatically created in the CS tables (the following SQL snippit will fix this)

Declare @ApplicationName nvarchar(512)
Declare @SettingsID int
Declare @ApplicationID uniqueidentifier

Set @ApplicationName = 'YourPortalID'
Select @ApplicationID = ApplicationId FROM aspnet_Applications where  LoweredApplicationName = Lower(@ApplicationName)
Select @SettingsID = SettingsID FROM cs_SiteSettings where ApplicationName = @ApplicationName

 --Import ApplicationID specific users from aspnet_Users if they dont already exists

INSERT INTO [cs_Users]([MembershipID], [ForceLogin], [UserAccountStatus], [AppUserToken], [LastActivity], [LastAction])
 SELECT aspnet.UserID, 0,1, null, getdate(), '' from dbo.vw_aspnet_MembershipUsers aspnet LEFT OUTER JOIN dbo.cs_vw_Users_FullUser cs on aspnet.UserID = CS.UserID WHERE aspnet.ApplicationID = @ApplicationID and cs.UserID is null

 --Create cs_UserProfile records for any cs_Users without Profiles

INSERT INTO [cs_UserProfile]([UserID], [TimeZone], [TotalPosts], [PostSortOrder], [PostRank], [IsAvatarApproved], [ModerationLevel], [EnableThreadTracking], [EnableDisplayUnreadThreadsOnly], [EnableAvatar], [EnableDisplayInMemberList], [EnablePrivateMessages], [EnableOnlineStatus], [EnableHtmlEmail], [MembershipID], [SettingsID], [PropertyNames], [PropertyValues])
 SELECT cs_Users.UserID, 0, 0, 0, 0x01, 0, 0, 0, 0, 0, 0, 0, 1, 0, cs_Users.MembershipID, @SettingsID, NULL, NULL FROM cs_Users LEFT OUTER JOIN cs_UserProfile on cs_Users.UserID = cs_UserProfile.UserID Where cs_UserProfile.UserID is null

And finally all of your user admin must be done through DNN, actually the CS user admin screen will be broken as a result of us removing the timezone key...  I am working on a fix for this one at the moment...  If you have the CS 1.1 source code here is a fix that will work, Edit the CommunityServerComponents\Componets\Profile.cs:



/// <summary>
/// Specifies the user's timezone offset.
/// </summary>

public
double Timezone {     
  get
 
  {
      object
obj = GetObject("timezone");
      if (profilebase["timezone"].GetType() == Timezone.GetType())

         return obj == null ? 0 : ( double )obj;
      else //DNN stores this as an INT (Minutes off GMT)
         returnobj == null? 0 : Convert.ToDouble(obj)/60;  
   }
   set 
   {
      if(profilebase["timezone"].GetType() == Timezone.GetType())

      {
         if ( value < -12 || value
> 12)
            Set("timezone",0);
         else 
            Set("timezone",value
);
      }
      else //DNN stores this as an INT (Minutes off GMT)
      {
         Set("TimeZone",Convert.ToInt32( value
*60));
      }
   }
}
#endregion

Happy Hacking =)

Dan  http://blog.danbartels.com/articles/753.aspx?CommentPosted=true#commentmessage

转载于:https://www.cnblogs.com/leeichang/archive/2005/08/23/221056.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值