c# - Query only returns groups that have users -


the code below returns list of groups , associated members on machine. why return populated groups. example create new user group on machine , not returned on query. if add user user group return in query. there fix query?

c# code

var sgroupname = ""; var susername = ""; managementobjectsearcher searchresult = new managementobjectsearcher("root\\cimv2", "select * win32_groupuser");   foreach (managementobject queryobj in searchresult.get()) {          sgroupname = queryobj["groupcomponent"].tostring().split(new[] { "name=" }, stringsplitoptions.none).last().trim('"');          susername = queryobj["partcomponent"].tostring().split(new[] { "name=" }, stringsplitoptions.none).last().trim('"'); } 

try this:

var searchresult =      new managementobjectsearcher("root\\cimv2", "select * win32_group"); 

Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -