1

我们正在使用 Active Directy 和 C# 实施数字签名 ad-hoc 方案。我们想知道我们应该如何从 AD 上的用户帐户条目中检索私钥(或用户的 PFX 文件),以便我们可以使用该私钥签署一些信息。同时,如何在 AD 中为每个用户正确安装 PFX 文件?(以便我们以后可以通过编程方式检索它)

我们已经在访问 AD 并从“userCert”字段中检索公钥信息,我们现在使用它来验证签名文件,但我们需要先访问私钥来签署这些文件!

我们正在使用 LDAP 访问 AD。像这样的东西:

DirectoryEntry o2ADEntry = new DirectoryEntry("LDAP://darwin.charles/DC=domain, DC=info", "user", "password");
DirectorySearcher o2objSearch = new System.DirectoryServices.DirectorySearcher(o2ADEntry);

o2objSearch.PropertiesToLoad.Add("samaccountname");
o2objSearch.PropertiesToLoad.Add("displayname");
o2objSearch.PropertiesToLoad.Add("userCert");
o2objSearch.Filter = (string.Format("(samaccountname={0})", "user")); 

SearchResult res = o2objSearch.FindOne();
if (res != null)
{
   CreateNavigator().SelectSingleNode("/my:myFields/my:name", NamespaceManager).SetValue(res.GetDirectoryEntry().Properties["displayname"].Value.ToString());
   FormState["certificate"] = res.GetDirectoryEntry().Properties["userCert"].Value;
}

我们还使用标准的 Microsoft Crypto API(没有 bouncycastle,没有 OpenSSL.NET)。

我们在这里检查了http://technet.microsoft.com/en-us/library/aa996408(v=exchg.65).aspx,但没有说明如何访问私钥。

非常感谢,朋友们!

4

0 回答 0