PrincipalContext.ValidateCredentials不设置lastLogon日期为用户

编程入门 行业动态 更新时间:2024-10-26 10:32:03
本文介绍了PrincipalContext.ValidateCredentials不设置lastLogon日期为用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我验证的用户在Active Directory存储如下:

I'm validating users in an Active Directory store as follows:

// using System.DirectoryServices.AccountManagement; // located in System.DirectoryServices.AccountManagement.dll using (var context = new PrincipalContext(ContextType.Domain, server, container, ContextOptions.Negotiate, validateUsername, validatePassword)) { var valid = context.ValidateCredentials(validateUsername, validatePassword); if (valid) { Console.WriteLine("SUCCESS!"); using (var userContext = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, validateUsername)) { Console.WriteLine("LastLogon = " + userContext.LastLogon); } } else Console.WriteLine("FAILED!"); }

验证是成功的,但 lastLogon 值永远不会改变。这是至关重要的,当我们在code用户由于其他软件使用这个值验证此值更改。我知道 ActiveDirectoryMembershipProvider 认证改变了这一属性,所以我不知道是否有一种方法,我可以使用 PrincipalContext (重用AD连接),但执行此验证更改 lastLogon 值。

The validation is successful, but the lastLogon value is never changed. It's essential that this value is changed when we authenticate a user in code due to other software using this value. I know ActiveDirectoryMembershipProvider authentication changes this property, so I'm wondering if there's a way I can use PrincipalContext (to reuse AD connections) but perform this validation to change the lastLogon value.

推荐答案

使用的lastLogonTimestamp 。这是一个获取当你试图通过 PrincipalContext 对象连接AD更新的领域。

Use lastLogonTimestamp. This is the field that gets updated in AD when you're attempting to connect via a PrincipalContext object.

更多推荐

PrincipalContext.ValidateCredentials不设置lastLogon日期为用户

本文发布于:2023-11-17 05:15:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608953.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   用户   PrincipalContext   ValidateCredentials   lastLogon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!