News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Enumerate Users

Started by Darrel, April 24, 2009, 08:47:12 PM

Previous topic - Next topic

Darrel

I'm looking for a method to find all the user accounts on a computer.

Thanks for your time and consideration,

Darrel

dedndave

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



Darrel

It looks like I'm suppose to use NetQueryDisplayInformation. Will test it.

dedndave

you want to use that first link above and
RegOpenKeyEx / RegCloseKeyEx
RegQueryKeyEx

Obivan

Hi Darrel,

you must use the API NetUserEnum to do this.

Darrel

What I settled on.

Use NetQueryDisplayInformation 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 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