c# 使用加密密码创建 Directoryentry

c# create Directoryentry with encrypted password

我们将管理员用户和密码(加密)存储在数据库中。并希望在像这样使用 DirectoryEntry C# 时使用加密的管理员密码。

DirectoryEntry loginDirectory = new DirectoryEntry("ldap_path", "administrator", "Password");

我该怎么做,我不想在代码中写管理员密码。 谢谢

您要做的是使用某种形式的双向加密。您可以在此处阅读更多相关信息:Encrypt and decrypt a string

然后你会在你的数据库中拥有加密的字符串,然后在你要像这样使用它时解密它:

DirectoryEntry loginDirectory = new DirectoryEntry("ldap_path", "administrator", decrypt(database["Password"]));