Question

When i add this code to my console application freezes.

List<string> User = new List<string>(); 

objectSearcher = new ManagementClass("Win32_UserAccount");
foreach (var item in objectSearcher.GetInstances())
{
    User.Add(item["FullName"].ToString());

}

I have no idea why, can anyone help ?

Was it helpful?

Solution

Probably it freezes due to large amount of data, objectSearcher.GetInstances() grabs every account from AD controller over network. How long it takes depends on number of accounts, network configuration and controller performance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top