如何使用 ADAM 使密码过期
我们正在使用 ADAM 在我们的开发环境中模拟 AD 服务器。我们需要使几个用户的密码过期,以测试几个关键代码路径。
我们一直通过将密码到期窗口设置为较低(1 天),然后等待该间隔直到密码到期来实现此目的。然而,这很慢,一旦我们更改密码,我们必须再等待一天才能看到另一个到期窗口。
有没有人有一个简单的解决方案来解决这个问题?
We are using ADAM to simulate an AD server in our development environment. We need to expire passwords for a couple of our users to test several key code paths.
We have been doing this by setting the password expiry window low (1 day) and then waiting that interval until the password expires. However, this is slow and once we change the password we must wait another day for anothe expiry window.
Does anyone have an easy solution to this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过在用户属性中将 pwdExpiryInterval 设置为 0 来使密码过期。
You can expire password by setting pwdExpiryInterval to 0 in the user's properties.
我很久以后才想到这个问题,并想找到更直接的答案。经过一番研究,我发现了两个:
如果您使用程序集
System.DirectoryServices.AccountManagement
并且您有一个UserPrincipal
,您可以使用myUser.ExpirePasswordNow( )
。如果您使用程序集
System.DirectoryServices
并且您有一个DirectoryEntry
,您可以myEntry.Properties["pwdLastSet"].Value = 0
code>。我会有点担心按照之前的建议使用 pwdExpiryInterval 因为可能会有副作用(尽管对于OP所述的情况可能没问题)。
I happened on this question much later and wanted to find a more direct answer. After some research I found two:
If you're using assembly
System.DirectoryServices.AccountManagement
and you have aUserPrincipal
you can usemyUser.ExpirePasswordNow()
.If you're using assembly
System.DirectoryServices
and you have aDirectoryEntry
you canmyEntry.Properties["pwdLastSet"].Value = 0
.I'd be a little concerned about using pwdExpiryInterval as suggested before because there might be side effects (although for the OP's stated case it's probably fine).