Why does my console application freezes when using Win32_UserAccount class
-
28-10-2019 - |
سؤال
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.
لا تنتمي إلى StackOverflow