Hi all, can anyone show me some (MASM) code to tell if the current user is Admin or not? Or direct me to a website? I need to know if the user is Admin or has Admin rights so my program can display some values from the Registry that the Admins can only set. I was going to add this feature to my program when I wrote in VB but never gotten around to it, all I remember was that is has to do with tokens or SID or something.

Any help much appreciated!
Posted on 2002-09-06 17:56:08 by Gunner
Posted on 2002-09-06 18:44:05 by stryker
Odd that I didn't find that post stryker cause I did a search of the board before my post. Hmmm

Thanks
Posted on 2002-09-06 18:49:34 by Gunner
lol, that thread doesn't contain any key words of Is Admin or whatever but it does contain similar purpose to what your after.

Don't worry. :grin:
Posted on 2002-09-06 18:58:33 by stryker
Posted on 2002-09-06 19:47:24 by bazik
IsUserAnAdmin.
Jeesh, how'd I miss this one? Anyway, this is for Win 2K and higher:
Minimum operating systems:
Windows 2000

So this function would work on 2000 and XP. How about something that would work on NT4 an maybe lower?


Ok ya crazy penguin, just tried it and DUH, it is not in my user32.lib/inc, how do I updated my lib files? I do have the platform sdk installed with the header and include files....
Posted on 2002-09-06 19:59:42 by Gunner

So this function would work on 2000 and XP. How about something that would work on NT4 an maybe lower?


"Lower" than NT 4.0 are no security rights. Or do you mean NT 3.51? :)
Originally posted by Gunner

Ok ya crazy penguin, just tried it and DUH, it is not in my user32.lib/inc, how do I updated my lib files? I do have the platform sdk installed with the header and include files....


Well, download the PlatformSDK, copy the *.lib files to the MASM32 lib directory and run the "rebuild.bat" (\masm32\rebuild.bat) to rebuild the include files. That should work ;)


I wrote "download", because you really need the latest SDK. The "IsUserAnAdmin" function is part of the shortly released MS Middleware APIs, so I doubt it will be documented in earlier SDKs.
Posted on 2002-09-07 03:27:05 by bazik
gunner,

shouldn't the link I just gave enough for win NT/2K/XP.

quoting from this link: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q118626&
HOWTO: Determine Whether a Thread Is Running in User Context of Local Administrator Account

The information in this article applies to:

Microsoft Win32 Application Programming Interface (API), when used with:
the operating system: Microsoft Windows NT

the operating system: Microsoft Windows 2000

the operating system: Microsoft Windows XP
Instead of updating the .lib files you can use LoadLibrary/GetProcAddress...
Posted on 2002-09-07 03:31:26 by stryker
Rob,

You can use the complete XP set of libraries if you have a late enough platformsdk but be aware that a couple of the libraries that have no APIs in them cause a problem with the L2INCA utility so the trick is to delete them out as you don't use them and keep going until the whole set build OK into the matching include files.

Its no big deal to do and it means you have a complete set for XP and lower.

Regards,

hutch@movsd.com
Posted on 2002-09-07 03:31:35 by hutch--
Thank you all! I have some things to play around with now. Never thought about LoadLibrary/GetProcAddress, still new to this great thing ya know ;-)
Posted on 2002-09-07 07:32:46 by Gunner