开发者

make database file hidden from user sight?

开发者 https://www.devze.com 2022-12-18 13:04 出处:网络
i have application which use a local sqlserver file to store data.i made a install package for this application ,but

i have application which use a local sqlserver file to store data.i made a install package for this application ,but i want to make the the database file (*.mdf) hidden from user sight. in fact i do开发者_StackOverflown't want him/her to be able to see tables or other details of database , while he/she can use this by my windows application. is there any solution ?


If the database is on the user's machine and you are most worried about the user accessing it, then you may want to reevaluate your architecture. Is a web solution viable?


You can make it a hidden file:

File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); 

But your best bet is to not store anything confidential on the users machine, there's always ways to bust security. You could also encrypt the database, but as the commentors point out, this is also insecure.


The best solution is to limit rights in the database itself. If you use stored porcs to access data, you do not grant select/insert/update or delete rights to the user on the tables andthen they can't see them and they can only do waht the stored procs they are allowed to execute can do. Of course this won't work if you use any dynamic sql but you shouldn't be doing that anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号