c# - Getting users of a computer -


I am trying to get the list of local users of a computer using the following code.

  Internal Zero GetUsers () {{list & lt; String & gt; AdUsers = new list & lt; String & gt; (); DirectoryEntry Directory Entry = New DirectoryInterity ("WinNT: //" + Environment.MachineName); Foreach (Direct DirectoryInterityInternetryChildren.) {If (child.SchemaClassName.Equals ("User", String Compiler, OrdinalIgn Case)) {adUsers.Add (child.Name); }}} Hold (exception ex) {// exception}}  

This code works fine in my computer However, when I tested it on some other computers, the following System users were included in the list:

ASPNET, HelpSistent

Can someone put me some light on this system to get rid of these system users and only to real users Log in, i.e., stuff If the user.

Thanks, Ram

There is no such answer, but some suggestions which are helpful May be.

I think the problem is that these accounts are not actual system accounts, so it may not be easy to distinguish.

You can look at the WMI classes and see that there is a property that can indicate which user accounts are normal and which you specifically mention, may be The property of 'SIDType' or 'AccountType' or special Win32_UserProfile class of Win32_UserAccount

Other WMI classes may be looking well.

Or there may be some way that you can ask that a user account is interactive logon (which I can not accept in those two accounts is normal).


Comments