We ran into this issue yesterday, and none of the 'easy' fixes helped.
Here's what finally worked:
Note: In our case, portal 0 had the problem, but other portals were ok. you'll need to modify the portalID if you want to reuse any of the SQL included below.
DO NOT try to run the following SQL scripts if you do not understand what they do. If you modify them incorrectly, you could cripple your DNN installation.
We made sure no one was on the site, and did a full backup.
We ran the following SQL to clear out all the Folder and File data:
-- Get table counts. rerun this block at the end to compare results.
select COUNT(*) from FolderPermission where FolderID in (select FolderID from Folders where PortalId = 0)
select COUNT(*) from Files where PortalId = 0
select COUNT(*) from Folders where PortalId = 0
-- Purge all Folder and File info from the system
delete from FolderPermission where FolderID in (select FolderID from Folders where PortalId = 0)
delete from Files where PortalId = 0
delete from Folders where PortalId = 0
We then cleared cache and restarted DNN from Host Settings and did a recursive sync from the Admin File Manager.
We then ran the following SQL to rebuild the folder permissions:
insert into FolderPermission
(FolderID,PermissionID,AllowAccess,RoleID,UserID,CreatedByUserID,CreatedOnDate,LastModifiedByUserID,LastModifiedOnDate)
select f.FolderID, 5 ,1, 0 ,NULL,1,GETDATE(),1,GETDATE()
from
Folders f where PortalId = 0
and FolderID not in
(select FolderID from FolderPermission where PermissionID=5 and RoleID=0)
insert into FolderPermission
(FolderID,PermissionID,AllowAccess,RoleID,UserID,CreatedByUserID,CreatedOnDate,LastModifiedByUserID,LastModifiedOnDate)
select f.FolderID, 8 ,1, 0 ,NULL,1,GETDATE(),1,GETDATE()
from
Folders f where PortalId = 0
and FolderID not in
(select FolderID from FolderPermission where PermissionID=8 and RoleID=0)
insert into FolderPermission
(FolderID,PermissionID,AllowAccess,RoleID,UserID,CreatedByUserID,CreatedOnDate,LastModifiedByUserID,LastModifiedOnDate)
select f.FolderID, 6 ,1, 0 ,NULL,1,GETDATE(),1,GETDATE()
from
Folders f where PortalId = 0
and FolderID not in
(select FolderID from FolderPermission where PermissionID=6 and RoleID=0)
insert into FolderPermission
(FolderID,PermissionID,AllowAccess,RoleID,UserID,CreatedByUserID,CreatedOnDate,LastModifiedByUserID,LastModifiedOnDate)
select f.FolderID, 8 ,1, -1 ,NULL,1,GETDATE(),1,GETDATE()
from
Folders f where PortalId = 0
and FolderID not in
(select FolderID from FolderPermission where PermissionID=8 and RoleID=-1)
insert into FolderPermission
(FolderID,PermissionID,AllowAccess,RoleID,UserID,CreatedByUserID,CreatedOnDate,LastModifiedByUserID,LastModifiedOnDate)
select f.FolderID, 5 ,1, -1 ,NULL,1,GETDATE(),1,GETDATE()
from
Folders f where PortalId = 0
and FolderID not in
(select FolderID from FolderPermission where PermissionID=5 and RoleID=-1)
That cleared up the problem for us.