![](/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.