我有一个UserPrincipal
具有很多属性的对象,但我找不到密码过期日期的属性。
如何才能做到这一点?
这是我能想到的最简单的方法......
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using ActiveDs;
//...
PrincipalContext domain = new PrincipalContext(ContextType.Domain);
UserPrincipal user = UserPrincipal.FindByIdentity(domain, "username");
DirectoryEntry entry = (DirectoryEntry)user.GetUnderlyingObject();
IADsUser native = (IADsUser)entry.NativeObject;
Console.WriteLine(user.GivenName + "'s password will expire on " + native.PasswordExpirationDate);
注意#1:ActiveDs
列于COM的选项卡添加参考对话框为活动 DS 类型库
注意#2:据我所知,PasswordExpirationDate
是 UTC 时间。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)