【问题标题】:Is there any way to validate given password is valid with computer object created in AD?有什么方法可以验证给定密码对于在 AD 中创建的计算机对象是否有效?
【发布时间】:2014-06-04 08:48:03
【问题描述】:

我刚刚在活动目录中创建了计算机对象。我使用 SetPassword 命令为计算机对象设置密码。我们如何验证计算机对象的密码或使用该密码进行身份验证?有什么方法可以验证该计算机的密码是否有效?

【问题讨论】:

  • 您到底为什么要为计算机对象设置密码?它们会定期被 PC 和域控制器之间自动商定的复杂密码自动覆盖。
  • NTLM 身份验证需要服务帐户(计算机对象)才能使此协议正常工作。我正在将 jespa 用于 NTLM SSO。需要将带有密码的计算机对象提供给 jespa 来执行 NTLMSSO。为此,我需要针对计算机对象验证用户密码。

标签: active-directory ldap windows-server-2008 windows-authentication


【解决方案1】:

验证计算机帐户密码的方法与验证用户密码的方法相同。计算机帐户也有一个用户名SamAccountName

我不确定如何提供示例,因为您没有指定任何编程平台,但为了说明,这里是一个使用 c# 和 System.DirectoryServices.AccountManagement 命名空间的示例。

string password = "securepassword";
using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
using (ComputerPrincipal computer = ComputerPrincipal.FindByIdentity(context, "Temp1"))
{
    computer.SetPassword(password);
    Console.WriteLine(context.ValidateCredentials(computer.SamAccountName, string.Empty).ToString()); // Returns False
    Console.WriteLine(context.ValidateCredentials(computer.SamAccountName, password).ToString()); //Returns True
}

【讨论】:

  • 谢谢 ashigore。请用 c++ 举一些例子。我搜索了“C++ 中的 PrincipalContext.validateCredentials”。但我没有得到任何明确的例子。
  • 我不懂 C++ 但是这个问题stackoverflow.com/questions/6019094/… 有一个很好的建议。
猜你喜欢
  • 1970-01-01
  • 2023-04-01
  • 2021-01-25
  • 1970-01-01
  • 2020-03-28
  • 2013-09-28
  • 2013-11-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多