使用 C# 检测用户是否必须在 Active Directory 中重置密码
在 Active Directory 中,如果用户的帐户被禁用然后又启用,则默认情况下,用户必须在首次登录时更改其密码。我正在努力使用 C# 以编程方式检测此问题?如果用户必须重置其属性,是否存在已设置的属性或类似的内容?
假设我有一个指向用户的 DirecotryEntry
对象:
DirectoryEntry user = ...
是否有一个我可以使用的属性:
user.Properties[someProperty];
In Active Directory, if a user's account is disabled and then enabled, by default, the user must change their password on first login. I am struggling to be able to detect this programmaticly using C#? Is there a property that is set or something along those lines if a user must reset their property?
Say I have a DirecotryEntry
object pointing to a user:
DirectoryEntry user = ...
Is there a property that I can use:
user.Properties[someProperty];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
该条件存储在两个属性中:
来自此处。
The condition is stored in two attributes:
From here.
这是我为此而写的内容。不完全回答你的问题,但对后来阅读它的其他人有用。
重要的部分是从PrincipalContext开始的。
上面的所有内容就是我试图始终以完全正确的大写形式返回 AdName 的方法。
请注意,这只是第一个答案的代码,使用用户主体而不是 DE 来测试 LastPasswordSet。
埃里克-
Here is what I wrote to do this. Not exactly answering your question but useful to others who read it later.
The important bits are from PrincipalContext on.
All the stuff above that is just how I tried to always get the AdName back with the exact correct capitalization.
Note this is just the code do do the first answer, test LastPasswordSet using a user principal instead of a DE.
Eric-
能够使用以下代码获取它:
Was able to get it using the following code:
如果 LastPasswordSet 具有空值,则“用户必须在下次登录时更改密码”。
If LastPasswordSet has a null value, the "user must change password at next logon".