如何修复DNN 5.2.3由于权限表导入错误

时间:2013-06-30 23:57:18

标签: import dotnetnuke

如何修复由于权限表导致的DNN导入错误。

背景:我花了一些时间来解决这个问题,我想发布解决方案以防其他人遇到这个问题。

-

尝试为客户端导入Dot Net Nuke v5.2.3导出文件。它们是企业/教授版本,对于我们的开发站点,我们使用社区版。

尝试导入时遇到此错误:

  

解析UNIQUE KEY约束的Portal TemplateViolation时出错   'IX_FolderPermission'。无法在对象中插入重复键   'dbo.FolderPermission'。重复键值为(18,5,9,)。该   声明已经终止。在   System.Data.SqlClient.SqlConnection.OnError(SqlException异常,   Boolean breakConnection)at   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject   stateObj)在System.Data.SqlClient.TdsParser.Run(RunBehavior   runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,   BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject   stateObj)在System.Data.SqlClient.SqlDataReader.ConsumeMetaData()at   System.Data.SqlClient.SqlDataReader.get_MetaData()at   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,   RunBehavior runBehavior,String resetOptionsString)at   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean   async)at   System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String   方法,DbAsyncResult结果)at   System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String   方法)在System.Data.SqlClient.SqlCommand.ExecuteScalar()at   Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(的SqlConnection   connection,CommandType commandType,String commandText,   SqlParameter [] commandParameters)at   Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(字符串   connectionString,CommandType commandType,String commandText,   SqlParameter [] commandParameters)at   Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(字符串   connectionString,String spName,Object [] parameterValues)at   DotNetNuke.Data.SqlDataProvider.AddFolderPermission(Int32 FolderID,   Int32 PermissionID,Int32 roleID,Boolean AllowAccess,Int32 UserID,   Int32 createdByUserID)at   DotNetNuke.Security.Permissions.PermissionProvider.SaveFolderPermissions(FolderInfo   文件夹)   DotNetNuke.Entities.Portals.PortalController.ParseFolderPermissions(XmlNodeList中   nodeFolderPermissions,Int32 PortalId,FolderInfo文件夹)at   DotNetNuke.Entities.Portals.PortalController.ParseFolders(XmlNode的   nodeFolders,Int32 PortalId)at   DotNetNuke.Entities.Portals.PortalController.ParseTemplate(的Int32   PortalId,String TemplatePath,String TemplateFile,Int32   AdministratorId,PortalTemplateModuleAction mergeTabs,Boolean   IsNewPortal)在   DotNetNuke.Entities.Portals.PortalController.CreatePortal(字符串   PortalName,UserInfo objAdminUser,String Description,String   KeyWords,String TemplatePath,String TemplateFile,String   HomeDirectory,String PortalAlias,String ServerPath,String   ChildPath,Boolean IsChildPortal)

1 个答案:

答案 0 :(得分:0)

错误的来源是新的DNN(社区版)安装没有“权限”表中所需的所有数据。

当我查看新的权限表时,我看到它丢失了ID大于7的所有行。要修复此错误,我们需要导入缺少的权限行。

解决此问题的两种方法,(但在尝试导入之前同时执行这两种操作)。

选项1:

如果您有权访问导出站点的数据库的源,则可以运行SQL命令来导入所需的行。

新数据库:DNN-NEW-DB 源数据库:DNN-SOURCE-DB

  INSERT INTO [DNN-NEW-DB].[dbo].[Permission]
  SELECT [PermissionCode]
        ,[ModuleDefID]
        ,[PermissionKey]
        ,[PermissionName]
        ,[ViewOrder]
        ,[CreatedByUserID]
        ,[CreatedOnDate],[LastModifiedByUserID],[LastModifiedOnDate]
   FROM [DNN-SOURCE-DB].[dbo].[Permission]
   WHERE[DNN-SOURCE-DB].[dbo].[Permission].[PermissionID] > 7
   ORDER BY permissionid

-

选项2:

是手动导入丢失的记录。我不确定我是否得到了你需要的一切,如果我错过了什么,请告诉我:

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_FOLDER', -1, 'DELETE', 'Can Delete', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_FOLDER', -1, 'ADD', 'Add', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_FOLDER', -1, 'COPY', 'Copy', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_FOLDER', -1, 'MANAGE', 'Manage', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'CONTENT', 'Content', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'ADD', 'Add', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'COPY', 'Copy', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'DELETE', 'Delete', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'EXPORT', 'Export', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'IMPORT', 'Import', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'MANAGE', 'Manage', 9999);

INSERT INTO Permission (PermissionCode, ModuleDefID, PermissionKey, PermissionName, ViewOrder)
    VALUES ('SYSTEM_TAB', -1, 'Navigate', 'Navigate', 9999);