System.Security.SecurityException: Request for principal permission failed
I finally found a solution. This error about permissions is a bit misleading. After lots of trial and errors, I finally accepted the Application Pool user's permissions had nothing to do with this problem. Which lead me to investigate the web.config
settings and that is where I found the problem.
The problem was that the supplied web.config
file was missing <authentication>
tag and the required settings. This tag (from my understanding) is what enables cookies. I hope this helps others with this error even if not related to LiveDocx. Seems Request for principal permission failed.
can be caused for various reasons which makes it a frustrating error.
This article was very helpful How To: Use Membership in ASP.NET 2.0
I would suspect the identity of the user that is executing the request, which is most likely the ASP.Net Application Pool user for the web site your IIS application is running in.
The easiest way to test this is to create a new application pool for your IIS application (unless there are no other apps in your current app pool), choose a different identity for the app pool (you could start with network service, but it may require a local user), then assign your app to that pool.
This should tell you if it's a permissions problem with the app pool identity.
I ran into this because I had an application under a website configured to use the wrong cookie name.
The web.config at my root web site looked like this
<authentication mode="Forms">
<forms name="AuthCookie" path="/"></forms>
</authentication>
and the application under it had a web.config under that looked like this
<authentication mode="Forms">
<forms name="WRONGCOOKIENAME" path="/"></forms>
</authentication>
The application had web form with a constructor that looked like this
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = "Foo", Authenticated = true)]
So it required authentication but it didn't have it because the cookie name was wrong. Fixing the cookie name resolved the error.