Exception: System.UnauthorizedAccessException

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
12/5/2009 8:01:47 AM
Gravatar
Total Posts 31
There are 10 kinds of people in the world, those who know binary, and those who don't

Exception: System.UnauthorizedAccessException

I get this error in the log, see below.

Note: I already added the asp process account to get full permissions on the data folder and all subfolders.

The web site frequently, multiple times per hour, just "freezes" and becomes unresponsive.

Why is this happening?

 

 

An unhandled exception occurred and the process was terminated.

 

Application ID: /LM/W3SVC/1/ROOT

 

Process ID: 3616

 

Exception: System.UnauthorizedAccessException

 

Message: Access to the path 'C:\Inetpub\wwwroot\...\Data\Sites\1\index\' is denied.

 

StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity)

at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity)

at mojoPortal.Business.WebHelpers.IndexWriterTask.ProcessIndexingQueue()

at mojoPortal.Business.WebHelpers.IndexWriterTask.RunTask()

at mojoPortal.Business.WebHelpers.IndexWriterTask.RunTaskOnNewThread(Object oTask)

at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)

at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

12/6/2009 8:22:35 AM
Gravatar
Total Posts 18439

Re: Exception: System.UnauthorizedAccessException

Hi,

That error message does not tell a lie, you may think you have configured permissions correctly but the evidence says not. It is trying to create the folder at /Data/Sites/1/index and it fails to create it due to file system permissions.

You did not mention your operating system or whether it is a shared host or a server you have full control over. That information would make it easier to help.

Best,

Joe

12/14/2009 10:33:28 PM
Gravatar
Total Posts 31
There are 10 kinds of people in the world, those who know binary, and those who don't

Re: Exception: System.UnauthorizedAccessException

Thank you for helping. Obviously the permission setting on the NTFS file system (e.g. Access Control List) is the issue.

The server is a Windows Server 2003 R2 SP2, we have full administrative control over it.

I tried to create the folder manually and granted the following users "Modify" permission:

1. IIS_WPG
2. Internet Guest Account
3. NETWORK SERVICE

I can now see a few files created in the folder with extensions CFS, GEN and a file without extension.
I do no longer see any exceptions raised in the log so far. So I believe the issue is solved.

Note that the folder path from your proposed message is slightly different.
In our case, the path for which permission was denied is c:\inetpub\wwwroot\our_domain_name\Data\Sites\1\Index. ("Path A")
However, there is also a \Data folder directly under \wwwroot, e.g. c:\inetpub\wwwroot\Data\Sites\1\Index. ("Path B")

I granted permissions to "Path B" above before, and it did not work. However, when I granted permission to "Path A", it worked fine.

Is this path difference due to a multi-site configuration?

It would be nice if the MojoPortal system could recommend these permission settings automatically. Permissions can be a tricky issue.

I also would like to know which user(s) that exactly need permissions to reduce the "attack surface area" exposed by granting permissions.

 

12/15/2009 5:44:50 AM
Gravatar
Total Posts 18439

Re: Exception: System.UnauthorizedAccessException

Hi,

On Win 2003 by default it is the IIS_WPG user who needs permissions, read permissions for the whole web and full control for /Data and /App_Data

mojoPortal only has 1 Data folder beneath the root of the mojoportal installation so I am confused by your question. Do you have 2 copies of mojoportal installed, 1 in the wwwroot folder and one in wwwroot/yourdomain? 

It sounds like it is really running from the wwwroot//yourdomain folder not the wwwroot folder so any /Data folder directly beneath wwwroot is not being used by mojoportal.

Even in a multi site installation there is only 1 Data folder and site specific data is stored under /Data/Sites/[SiteID]/

The Setup page does test file system permissions and indicates if there are problems, /Setup/Default.aspx

So I can only guess you have an extra copy of mojoportal files in the wwwroot folder.

Hope it helps,

Joe

12/15/2009 6:08:35 AM
Gravatar
Total Posts 31
There are 10 kinds of people in the world, those who know binary, and those who don't

Re: Exception: System.UnauthorizedAccessException

I would also expect there to be one Data folder. There is only one mojoportal in our installation.

However

(1) The exception is raised for subfolder wwroot\mydomain\data\... , not wwwroot\data

(2) The wwwroot\data exists and contains lots of files eg. skins, which are obviously in use

(3) The folder(s) wwwroot\data\ and all subfolders in that path in the exception did not exist. I just had to create this path manually and subsequently set the permissions.

Maybe this is a special case but you may consider to look into wheter the indexing feature would ever attempt to access a mydomain subfolder under wwwroot rather than under wwwroot\data even though wwwroot\data is still used for ither content.

Thank you for the help.

 

12/15/2009 6:16:32 AM
Gravatar
Total Posts 18439

Re: Exception: System.UnauthorizedAccessException

Does your site run as a root level site or in a virtual directory?

Are you using the multi site feature? Host name or folder name?

I cannot check for specific folder names, there is no rule about where mojoportal is installed, it does not have to be in wwwroot, it can exist anywhere in the file system. The code is just checking relative to the root of the installation, it resolves the actual physical path with Server.MapPath("~/Data");

I think you have some unusual configuration, maybe url forwarding or url rewriting that happens before the mojoportal code executes or else some strange virtual directory mappings.

1/4/2010 12:11:12 AM
Gravatar
Total Posts 31
There are 10 kinds of people in the world, those who know binary, and those who don't

Re: Exception: System.UnauthorizedAccessException

The site is the only IIS Web Site site on the IIS 6.0 server.
Home directory = "A directory located no this computer", c:\inetpub\wwwroot.
It is configured to be an application. No virtual directory is used.

The following settings may be relevant (from user.config and web.config) and are used:

UseRelatedSiteMote: True
RelatedSiteID: 1
UseFolderInsteadOfHostnamesForMultipleSites: True
AllowMultipleSites: True
RunningInMediumTrust: False

No URL forwarding or rewriting plug-in is installed.

It may be difficult to diagnose and reproduce this configuration, so perhaps easier would be, if the indexing folder cannot be created automatically, whatever ther reason, the system could throw a custom exception or log message with configuration recommendations if it does not exist. It could make the error message a bit easier to understand.

You must sign in to post in the forums. This thread is closed to new posts.