我System.DirectoryServices.AccountManagement.dll
用来处理Active Directory以获取"域用户"组中的所有用户.
这将返回域中的所有用户,但我需要获取已启用的用户.
以下是一些示例代码:
List<string> users = new List<string>();
PrincipalContext pcContext = GetPrincipalContext();
GroupPrincipal grp = GroupPrincipal.FindByIdentity(pcContext,
IdentityType.Name,
"Domain Users");
foreach (Principal user in grp.GetMembers(true).OfType<UserPrincipal>())
{
if (user.Enabled != false)
{
users.Add(user.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
其他组工作正常,但当该组是"域用户"时,该Enabled
属性的值false
适用于所有用户.这使得无法在不对每个用户进行进一步查询的情况下区分启用和禁用用户.
可能重复:
如何使用Javascript进行页面重定向?
我有一个HTML页面,我想用来从一个页面重定向到另一个页面,如ASP.Net中的response.redirect.我想我必须使用JavaScript.