尝试编写只读数据库 - System.Data.SQLite

时间:2022-09-11 17:05:32

I'm having a little bit of a problem that I thought was related to Security but, turns out can't be as I did almost everything ...

我有一个问题,我认为这与安全有关,但事实证明不能像我几乎做的一切......

Plenty of information on this on the web but nothing has an answer to fix the issue.

网上有大量关于此的信息,但没有解决问题的答案。

Let me tell my steps:

让我告诉我的步骤:

  • Have a Website on VS2k8 that when I debug or start from Cassini, all works fine
  • 在VS2k8上有一个网站,当我调试或从Cassini开始时,一切正常
  • When setting up IIS 7.5 (Win7) to point to this website and after adding IIS_IUSRS Modify rights I get the error
  • 当设置IIS 7.5(Win7)指向此网站并添加IIS_IUSRS修改权限后,我收到错误
  • Same thing using IIS 6.0!
  • 使用IIS 6.0也一样!

Img: Security on Database File from IIS 7.5

Img:IIS 7.5中的数据库文件安全性

alt text http://www.balexandre.com/temp/2010-02-25_1028.png

替代文字http://www.balexandre.com/temp/2010-02-25_1028.png

Note that all other files and folders have the same rights as above

请注意,所有其他文件和文件夹具有与上述相同的权限

The full Error is:

完整的错误是:

Log: Executing query on SQLite Database

Message ***************************************
Attempt to write a read-only database
attempt to write a readonly database

Stack Trace ***********************************
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
at soDatabaseManager.CommitPersonsToKitchenDatabase() in c:\Adwiza\Kitchen\App_Code\soDatabaseManager.cs:line 242

P.S. Keep in mind that this has to work with IIS 6 (windows 2003) as well, the IIS 7.5 is only for troubleshooting as we have more control in everything...

附:请记住,这也必须与IIS 6(Windows 2003)一起使用,IIS 7.5仅用于故障排除,因为我们可以更好地控制所有内容......

2 个解决方案

#1


11  

Make sure that the anonymous web user account (NETWORK SERVICE or maybe something else) under which your web application executes has read/write/create/delete access to the folder where the sqlite database resides.

确保Web应用程序执行的匿名Web用户帐户(NETWORK SERVICE或其他内容)具有对sqlite数据库所在文件夹的读/写/创建/删除访问权限。

#2


0  

The other answer give me an idea about the problem, but my solution was a bit differente. The problem was that the user did not have permissions to modify the folder and the .db file. So I give permission to the user Everyone (collective group for Authenticated Users and Guest). The permisions on NETWORK SERVICE (or similars) did not solve in my case.

另一个答案给了我一个关于这个问题的想法,但我的解决方案有点不同。问题是用户没有权限修改文件夹和.db文件。所以我向用户Everyone(Authenticated Users and Guest的集体组)授予权限。在我的案例中,网络服务(或类似物)的权限没有得到解决。

Note: The IIS must be restarted, after the change, to load the change made.

注意:更改后,必须重新启动IIS才能加载所做的更改。

#1


11  

Make sure that the anonymous web user account (NETWORK SERVICE or maybe something else) under which your web application executes has read/write/create/delete access to the folder where the sqlite database resides.

确保Web应用程序执行的匿名Web用户帐户(NETWORK SERVICE或其他内容)具有对sqlite数据库所在文件夹的读/写/创建/删除访问权限。

#2


0  

The other answer give me an idea about the problem, but my solution was a bit differente. The problem was that the user did not have permissions to modify the folder and the .db file. So I give permission to the user Everyone (collective group for Authenticated Users and Guest). The permisions on NETWORK SERVICE (or similars) did not solve in my case.

另一个答案给了我一个关于这个问题的想法,但我的解决方案有点不同。问题是用户没有权限修改文件夹和.db文件。所以我向用户Everyone(Authenticated Users and Guest的集体组)授予权限。在我的案例中,网络服务(或类似物)的权限没有得到解决。

Note: The IIS must be restarted, after the change, to load the change made.

注意:更改后,必须重新启动IIS才能加载所做的更改。