首页 > 解决方案 > C# Active Directory App - How do I store service account credentials?

问题描述

I'm creating a web front end for some common Active Directory tasks. I'm planning to store service account credentials in the database so that they are able to be changed by the end user. How can I safely store the password when I need to pass it to AD?

标签: c#asp.netsecurityauthentication

解决方案


您是否需要支持不同的域/使用不同的帐户来访问 AD?

如果不是,我建议根本不存储凭据,而是让您的进程在特定用户帐户下运行。(使用 IIS 或独立服务。)前段时间,我为此使用了 Windows 服务(参见https://www.rsprog.de/aspnet-webapi2-angularjs/)。

如果你真的想要/需要存储密码,你可以使用 MS Data Protection API。请参阅 https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.protecteddata

我已经使用了几次,它已被证明是一种可靠且可靠的方法。

但请注意,任何知道您的算法和熵并在服务器上拥有管理员权限的人都能够解密(如果他能够让进程在服务用户下运行)。


推荐阅读