在 SQL Server 2008 数据库中存储和使用 Microsoft 用户帐户凭据

发布于 2024-08-29 23:28:40 字数 314 浏览 4 评论 0原文

为了标题的缘故,我不太确定如何措辞,所以请原谅我。另外,我似乎不知道如何用谷歌搜索这个问题,所以我希望我能找到正确的方向。

我的部分软件(VB.NET 应用程序)需要能够访问/读取/写入共享网络文件夹。我可以选择让用户指定访问所述文件夹可能需要的任何凭据。

我想将这些凭据存储在 SQL Server 数据库中作为配置的一部分(我有一个包含配置的表)。

我担心的是用户帐户的密码将被解密。然而,如果我加密密码,VB.NET 应用程序和/或数据库将无法使用文件 I/O 操作的凭据,除非密码在使用前未加密。

我正在寻求有关如何更好地处理这种情况的建议。

I'm not exactly positive how to word this for the sake of the title so please forgive me. Also I can't seem to figure out how to even google this question, so I'm hoping that I can get a lead in the right direction.

Part of my software(VB.NET App) requires the ability to access/read/write a shared network folder. I have an option for the user to specify any credentials that might be needed to access said folder.

I want to store these credentials given in the SQL Server database as part of the config (I have a table which contains configuration).

My concern is that the password for the user account will be unencrpyted. Yet, if I encrypt the password the VB.NET App And/Or database will be unable to use the credentials for file i/o operations unless the Password is unencrypted before use.

I'm fishing for suggestions on how to better handle this situation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

热风软妹 2024-09-05 23:28:40

SQL Server 本身具有存储 Windows 凭据的方法,请参阅CREATE CREDENTIAL

凭证是包含以下内容的记录
认证信息是
连接到资源所需的
SQL Server 之外。大多数凭证
包括 Windows 用户和密码。

但以任何形式将用户凭据存储在应用程序中始终都是一个坏主意。其一,当用户更改密码时,它们就会不同步。其次,冒充用户访问资源永远不是正确的解决方案。正确的解决方案是实际设置组成员身份并正确定义资源的访问控制列表。

访问资源的唯一正确场景是:

  • 作为运行应用程序的用户,即。正常的普通用例
  • 作为模拟连接用户的服务,这是通过从 SSPI 身份验证获取远程身份令牌来完成的,例如 NegotiateStream.RemoteIdentity

SQL Server itself has means to store Windows credentials, see CREATE CREDENTIAL:

A credential is a record that contains
the authentication information that is
required to connect to a resource
outside SQL Server. Most credentials
include a Windows user and password.

But storing user credentials in the application, in any form, is always a bad idea. For one, they go out of sync when the user changes the password. Second, impersonating users to access resources is never the correct solution. The correct solution is to actually set up group membership and properly define access control lists on the resources.

The only correct scenarios for accessing resources are:

  • as the user running the application, ie. the normal run-of-the-mill use case
  • as a service that impersonates the connected user, which is done by obtaining a remote identity token from an SSPI authentication, like the NegotiateStream.RemoteIdentity
樱桃奶球 2024-09-05 23:28:40

我建议在您的应用程序中使用 Windows 身份验证。如果这样做,则可以在共享文件夹和数据库中设置权限,并避免在数据库中存储任何类型的凭据。

I would suggest using Windows authentication in your application. If you do that, then you can set permissions on the shared folder and in the database and avoid storing credentials of any sort in the database.

眼前雾蒙蒙 2024-09-05 23:28:40

如果您想以加密方式存储密码,则需要使用自己的加密算法或允许您再次解密密码的算法。有很多方法可以做到这一点,最常见的一种是使用安全词对其进行加密,这样您就可以使用相同的词再次解密。

好吧,可能不是一个真正的单词,而是类似随机字节数组或类似的东西。

You need to use your own encryption algorithm or one that allows you to decrypt the password again if you want to store it encrypted. There are many ways to do this one of the more common is to encrypt them with a safeword so you can use the same word to decrypt again.

Well, probably not a real word but something like a random byte-array or anything similar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文