I'm looking for a method to find all the user accounts on a computer.
Thanks for your time and consideration,
Darrel
Query the registry - best way
there are certain numbers set aside for certain "users"
administrator, default, so on
if i remember correctly, the first created user also always has a specific value
i saw these listed in a book about the system registry
i hope that helps you find the information
http://support.microsoft.com/kb/154599
http://msdn.microsoft.com/en-us/library/ms162144(SQL.90).aspx
It looks like I'm suppose to use NetQueryDisplayInformation. Will test it.
you want to use that first link above and
RegOpenKeyEx / RegCloseKeyEx
RegQueryKeyEx
Hi Darrel,
you must use the API NetUserEnum (http://msdn.microsoft.com/en-us/library/aa370652(VS.85).aspx") to do this.
What I settled on.
Use NetQueryDisplayInformation (http://msdn.microsoft.com/en-us/library/aa370610(VS.85).aspx) level 1 to fill an array of NET_DISPLAY_USER structures (they say to use this method over NetUserEnum). Go to the registry and open HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Profilelist then enumerate the subkeys and open them and retrieve the Sid values. Then using GetWellKnownUserSIDFromRID (http://support.microsoft.com/kb/288900) build the Sid, then use your NET_DISPLAY_USER.usri1_user_id and see if it matches any of the Sid values from the registry, if it does then NET_DISPLAY_USER.usri1_name is an actual user account.
Regards,
Darrel