سؤال

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 ?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top