NB_Store does not work under medium trust.

May 7, 2009 at 1:19 AM
Hi!

NB_Store does not work when portal permissions is set to medium trust. As medium trust is common practice, this is a major problem. I *think* the problem resides in the SharedFunctions.vb, when creating, modifying and deleting files.

Under medium trust, no folders are created by the module(productimages, LogFiles etc.)

Public Shared Sub CreateDir(ByVal PortalSettings As DotNetNuke.Entities.Portals.PortalSettings, ByVal FolderName As String) If Not Directory.Exists(PortalSettings.HomeDirectoryMapPath & FolderName) Then Dim objFolderCtrl As New DotNetNuke.Services.FileSystem.FolderController 'add folder and permissions Dim folderid As Integer = objFolderCtrl.AddFolder(PortalSettings.PortalId, FolderName) Dim objPermissionController As New DotNetNuke.Security.Permissions.PermissionController Dim arr As ArrayList = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "") For Each objpermission As DotNetNuke.Security.Permissions.PermissionInfo In arr If objpermission.PermissionKey = "READ" Then ' add READ permissions to the All Users Role FileSystemUtils.SetFolderPermission(PortalSettings.PortalId, folderid, objpermission.PermissionID, Integer.Parse(glbRoleAllUsers), "") End If If objpermission.PermissionKey = "WRITE" Then ' add READ permissions to the All Users Role FileSystemUtils.SetFolderPermission(PortalSettings.PortalId, folderid, objpermission.PermissionID, Integer.Parse(glbRoleAllUsers), "") End If Next Dim strNewDir As String strNewDir = FolderName MkDir(PortalSettings.HomeDirectoryMapPath & strNewDir) End If End Sub
May 7, 2009 at 1:20 AM
Oh, and really, really nice module, it has a LOT of potential!

If we get this up and running, i'll send you a swedish language pack ;)

Sincerely, Esse
May 7, 2009 at 2:02 AM
Edited May 7, 2009 at 2:39 AM
It seems like this error could be related to the usage of paths outside of the modules own folder "(PortalSettings.PortalId, FolderName)"

Will be checking this out some more...brb

EDIT:

I'm no VB.net fanatic, however i think something like this would at least partially solve the trust issue(?);


Public Shared Sub CreateDir(ByVal PortalSettings As DotNetNuke.Entities.Modules.PortalModuleBase, ByVal FolderName As String) If Not Directory.Exists(PortalSettings.PortalId & FolderName) Then Dim objFolderCtrl As New DotNetNuke.Services.FileSystem.FolderController 'add folder and permissions Dim folderid As Integer = objFolderCtrl.AddFolder(PortalSettings.PortalId, FolderName) Dim objPermissionController As New DotNetNuke.Security.Permissions.PermissionController Dim arr As ArrayList = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "") For Each objpermission As DotNetNuke.Security.Permissions.PermissionInfo In arr If objpermission.PermissionKey = "READ" Then ' add READ permissions to the All Users Role FileSystemUtils.SetFolderPermission(PortalSettings.PortalId, folderid, objpermission.PermissionID, Integer.Parse(glbRoleAllUsers), "") End If If objpermission.PermissionKey = "WRITE" Then ' add READ permissions to the All Users Role FileSystemUtils.SetFolderPermission(PortalSettings.PortalId, folderid, objpermission.PermissionID, Integer.Parse(glbRoleAllUsers), "") End If Next Dim strNewDir As String strNewDir = FolderName MkDir(PortalSettings.PortalId & strNewDir) End If End Sub


Don't know to much about either VB.Net or DNN libraries, but my thought was to put the individual portal folders in the PortalModuleBase instead of the PortalId X directory. Haven't tried myself yet as i have to sleep. Used this doc. as reference: http://www.dotnetnuke.com/LinkClick.aspx?fileticket=ko3NOxfqlno%3D&tabid=478&mid=857
Coordinator
May 7, 2009 at 8:49 AM
Hi,

Thanks for the feedback, I'm unsure of the exact problem, but I think I need to look into this when I get the chance.  Hopefully I'll be able to find an answer for the next release.

If you have any more feedback or solutions I'll be more than happy to hear them.

Thanks,
Dave.
May 11, 2009 at 11:05 AM

Hi,

I have just moved my site to live shared environment and I am having same problem when trying to add an image to a product.

Following is the stack trace in event viewer of my dnn (v 4.9) installation.

DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 21f604ef-8c4d-4285-adfa-b4214c1ca51f
InnerException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: NEvoWeb.Modules.NB_Store.SharedFunctions.CreateDir
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action) at NEvoWeb.Modules.NB_Store.SharedFunctions.CreateDir(PortalSettings PortalSettings, String FolderName) at NEvoWeb.Modules.NB_Store.AdminProduct.updateProduct() at NEvoWeb.Modules.NB_Store.AdminProduct.productimage_NewButton(Object sender, EventArgs e) at NEvoWeb.Modules.NB_Store.AdminProductImage.cmdAddNewImage_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) The action that failed was: LinkDemand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The Zone of the assembly that failed was: MyComputer --- End of inner exception stack trace ---

 

Please help me to make things round as I have to make the site bug free and I don't know how to overcome this medium trust level issue.

Coordinator
May 11, 2009 at 12:59 PM

HI,

Yes definatly a medium trust issue.  I'm currently working on a fix for this.   Although I'm currently having big problems testing the fixes.   When I've finished the changes I'll be let you know (Hopefully today or tomorrow)

Regards,

Dave.

May 11, 2009 at 1:17 PM

Thanks Dave, 

Your provision of fix would bring me out of the fix reallu :)

Anyways I am also looking into it to resolve the matter but as I didn have VS 2008 so right now Installing it.

Waiting for you to succeed n very best of luck...