![](/img/trans.png)
[英]extract LastLogon from Active Directory and set it equal to lastlog.txt text box using C#
[英]C# Authentication with active directory is not reflecting lastLogon attribute in AD
我正在使用以下代码通过活动目录对用户进行身份验证,并且在凭据正确的情况下验证成功,但是如果我检查 AD 中的属性“lastLogon”,它似乎没有改变
using (LdapConnection connection = new LdapConnection(domain))
{
connection.AuthType = AuthType.Basic;
connection.Credential = new NetworkCredential(username, password);
try
{
connection.Bind();
return "Authentication succeeded.";
}
catch (LdapException ex)
{
return "Authentication failed: " + ex.Message;
}
}
我还尝试使用“DirectorySearcher”检索属性,但它没有检索更新日期。
我猜你有多个域lastLogon
属性不会在 DC 之间复制。 因此,您只会在您进行身份验证的 DC 上看到更新后的值。
如果您的domain
属性只是域的名称,我相信您可以在通过查看connection.SessionOptions.HostName
进行身份验证后获得 DC 的名称。 (我认为)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.