我正在尝试做一些我甚至不知道是否可能的事情。 我有一个基于C#的Web应用程序,它运行在特定的服务器上。我想构建一个代码,其中用户介绍应用程序运行的域(此服务器依赖于客户端,显然它在不同服务器上运行的每个客户端),应用程序返回该域的本地Windows用户帐户和信息说明用户是否被锁定。
我尝试过使用Win32_UserAccount但它似乎得到了我正在使用的网络用户。
这可能吗?
非常感谢你 问候, FlávioJustino
答案 0 :(得分:3)
尝试
using(PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain"))
{
using(UserPrincipal usr = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, "username"))
{
usr.IsAccountLockedOut(); //Gets if account is locked out
}
}
您需要为上述代码添加dpendency System.DirectoryServices.AccountManagement.dll
才能正常工作。