我需要查找是否在AD中启用或禁用了用户帐户.
我找不到标志或属性"userAccountControl".这是可以使用USERPRINCIPAL类实现的吗?
drop_persona1.Items.Clear();
string valor = drop_area.SelectedValue;
List<string> allUsers = new List<string>();
PrincipalContext ctx2 = new PrincipalContext(ContextType.Domain, "xxxxxxxx",
valor);
UserPrincipal qbeUser2 = new UserPrincipal(ctx2);
qbeUser2.Enabled = true; // activo para autenticacion
PrincipalSearcher srch2 = new PrincipalSearcher(qbeUser2);
srch2.QueryFilter = qbeUser2;
foreach (var found2 in srch2.FindAll().OrderBy(x=> x.DisplayName))
{
ListItem lst_user = new ListItem(found2.DisplayName, found2.SamAccountName);
drop_persona1.Items.Insert(drop_persona1.Items.Count, lst_user);
}
//}
}
Run Code Online (Sandbox Code Playgroud)
问候