且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"安全"在部署Web应用程序的问题与NHibernate

更新时间:2023-01-18 22:13:20

我们一直在寻找这个很多最近。这里是href=\"http://nhforge.org/wikis/howtonh/run-in-medium-trust.aspx\" rel=\"nofollow\">在中等信任

运行NHibernate的

这是我见过的不同信任级别的最简洁的解释:的信任级别揭秘

从文章:

   - 完全信任 - 你的code可以做任何事情,运行它可以做的帐户。
- 高度信任 - 与上面相同,除了你的code不能调用非托管code。即的Win32 API,COM​​互操作。
- 中等信任 - 与上面相同,除了你的code不能看到除了它的应用程序目录的文件系统的任何部分。
- 低信任 - 与上面相同,除了你的code不能做任何超出过程调用。即,调用一个数据库,网络等
- 最小信任 - code是从什么,但最繁琐的处理(计算算法)的限制。

I've deployed to a server a web application that uses NHibernate. The application compiles and runs fine on my local dev machine, but there's an issue with NHibernate on the new server. I get the following error:

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=tokenkeyhere' failed.

It suggests to change the application's "trust level" in the configuration file. How exactly do I do that? This is the first time I've deployed a NHibernate web app, so I'm at a loss.

We've been looking at this a lot lately. Here is a link on running NHibernate in medium trust

This is the most succinct explanation I've seen of the different trust levels: Trust Levels Demystified

From the article:

- Full trust – your code can do anything that the account running it can do.
- High trust – same as above except your code cannot call into unmanaged code. i.e. Win32 APIs, COM interop.
- Medium trust – same as above except your code cannot see any part of the file system except its application directory.
- Low trust – same as above except your code cannot make any out-of-process calls. i.e. calls to a database, network, etc.
- Minimal trust – code is restricted from anything but the most trival processing (calculating algorithms).