拒绝访问应用程序外部的文档

本文关键字:文档 外部 应用程序 拒绝访问 | 更新日期: 2023-09-27 18:23:37

我正在开发一个应用程序,用于保存文档存储库并从中进行搜索。我希望防止用户在应用程序之外查看/添加/修改/删除文档。目前,我将文档存储在windows中的普通文件夹结构中,任何授权的windows用户都可以轻松访问该结构。我正在寻找一些方法,我可以确保,只有我的应用程序才能访问这些文件。

有没有可用的库或技术,我可以使用它向windows用户隐藏这些文件,但我的应用程序可以以正常方式使用它?

拒绝访问应用程序外部的文档

如果您必须在窗口中保存文档,并且希望限制用户,请尝试以加密形式保存文档,并可能使用密码。因此,即使有人可以访问它,它对他来说也变得毫无用处。像这样的东西应该适用于加密

 using (var fileStream = File.OpenWrite(theFileName))
 using (var memoryStream = new MemoryStream())
 {
// Serialize to memory instead of to file
var formatter = new BinaryFormatter();
formatter.Serialize(memoryStream, customer);
// This resets the memory stream position for the following read operation
memoryStream.Seek(0, SeekOrigin.Begin);
// Get the bytes
var bytes = new byte[memoryStream.Length];
memoryStream.Read(bytes, 0, (int)memoryStream.Length);

var encryptedBytes = yourCrypto.Encrypt(bytes);
fileStream.Write(encryptedBytes, 0, encryptedBytes.Length);
}

您可以使用此库进行密码保护和压缩

如果您使用的是Windows Server 2012,则可以使用Windows Server 2012动态访问控制,它具有两个功能,即SDDL(安全描述符定义语言)和DACL(动态访问控制)。

以下是几篇值得一读的文章:

  • http://blogs.technet.com/b/wincat/archive/2012/07/20/diving-deeper-into-windows-server-2012-dynamic-access-control.aspx
  • http://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/SIA341

使用动态访问控制,您可以根据分类和用户声明定义哪些用户查看/编辑哪些文件和文件夹。