在 C# 中,如何设置 AD 属性“pwdLastSet”的值?
在c#中,如何设置AD属性“pwdLastSet”的值
这不起作用:
DateTime passwordLastSetTarg = System.DateTime.Now.AddHours( -25 );
var adDate = userToActOn.ADEntry.Properties[ "pwdLastSet" ].Value;
long filetime = passwordLastSetTarg.ToFileTimeUtc();
userToActOn.ADEntry.Properties[ "pwdLastSet" ][ 0 ] = filetime;
这与我的上一个问题密切相关,但我希望它不是多余的,如果很抱歉。
In c# how does one set the value of the AD property "pwdLastSet"
This is not working:
DateTime passwordLastSetTarg = System.DateTime.Now.AddHours( -25 );
var adDate = userToActOn.ADEntry.Properties[ "pwdLastSet" ].Value;
long filetime = passwordLastSetTarg.ToFileTimeUtc();
userToActOn.ADEntry.Properties[ "pwdLastSet" ][ 0 ] = filetime;
This is closely related to my last question, but I hope it's not redundant, if so sorry.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能将其设置为日期 - 只能设置为 0 (现在过期)或 -1 (将时间重置为“现在”)
You can't set it to a date - only to 0 (expires now) or -1 (reset the time to 'now' )
除非我误读了 MSDN 文档,这是一个只读属性 - 正如我所期望的那样。当用户更改密码时,由 AD 进行设置。
Unless I'm misreading the MSDN docs, this is a read-only property - as I'd have expected it would be. It's up to AD to set this as and when a user changes their password.