0

I need to get custom user objects using WMI from a remote server. It's possible that number of users is > 500,000. Is it safe to run the following code?

var queryStr = "select * from MyUserClass";
var query = new SelectQuery(queryStr);
var searcher = new ManagementObjectSearcher(MngScope, query);

var result = searcher.Get();

I can't find any info on response size limitations. I am worrying that data size will be over threshold for response over ethernet. Or ManagementObjectSearcher gets data sequentially and then returns result?

Also it looks like COUNT keyword doesn't present in WQL. So how I can get number of objects then?

fresh
  • 33
  • 1
  • 7

1 Answers1

0

As you can see in this question it's impossible to limit the amount of results in WQL.

With that said, there is no reason for a system to have more than 500,000 users.

If you are afraid of a system "cheating" you and returning so many users anyway you can limit the query time by executing it in another Thread.

Community
  • 1
  • 1
Tamir Vered
  • 10,187
  • 5
  • 45
  • 57
  • I am worrying that data size will be over threshold for response over ethernet. Or ManagementObjectSearcher gets data sequentially and then returns result? – fresh Jan 29 '16 at 20:20
  • Even though the data will not be returned sequentially, you shouldn't worry about your Ethernet you should worry about your application freezing, even if the result (for some very-not-standard-reason) is too large, just set a timeout. still, a standard system will never provide you so many users... – Tamir Vered Jan 29 '16 at 20:30
  • The code runs in separate thread as a service. Its a custom objects and I need to sync them with my system, Number of users is probably number of employees in the company. But I have no chance to test my code with such amount of data before release. Maybe I need to find some systems objects that are present on the remote server and which number is huge and try to pull them. Anyway, thanks for the response! – fresh Jan 29 '16 at 20:56