Mad*_* Zu 3 vb.net asp.net active-directory .net-2.0
是否有一种方法在Visual Basic中检查用户的密码是否设置为永不在Active Directory中过期?
我找到了一种方法来查找更改的最后日期,但我找不到其他可用选项.
Dim de As DirectoryServices.DirectoryEntry = GetUser(uDetails.username)
Dim objUser = GetObject(de.Path)
If objUser.PasswordLastChanged < DateTime.Now.AddMonths(-3) Then
...
Run Code Online (Sandbox Code Playgroud)
我在哪里可以找到所有可用objUser属性的列表?
如果您使用的是.NET 3.5及更高版本,则应该查看System.DirectoryServices.AccountManagement(S.DS.AM)命名空间.在这里阅读所有相关内容:
基本上,您可以定义域上下文并轻松查找AD中的用户和/或组:
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
if(user != null)
{
// one of the properties exposed is "PasswordNeverExpires" (bool)
if(user.PasswordNeverExpires)
{
// do something here....
...
}
}
Run Code Online (Sandbox Code Playgroud)
新的S.DS.AM使得在AD中与用户和群组玩游戏变得非常容易!
| 归档时间: |
|
| 查看次数: |
8759 次 |
| 最近记录: |