I wrote a quite simple c# app that scans our active directory for locked out accounts and returns the usernames to a list box (LB1). Here is the code for the search. It falls under the Button_Click event:
try
{
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "DOMAIN", "OU=OUnAme,DC=DOMAIN,DC=com");
UserPrincipal qbeUser = new UserPrincipal(ctx);
qbeUser.Enabled = true;
PrincipalSearcher search = new PrincipalSearcher(qbeUser);
foreach (UserPrincipal user in search.FindAll())
{
if (user.IsAccountLockedOut())
{
LB1.Items.Add(user.SamAccountName.ToString());
}
}
}
Is there a way to implement a progress bar that fills for the FindAll() event? Would I just want to do a count function first, to determine the max value for the progress bar and then add an incrament as the first step of the foreach loop?
Thank you, Wes