Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I find if user is Admin?

Status
Not open for further replies.

IRABYY

Programmer
Apr 18, 2002
221
US
Colleagues:

Wery interesting problem: I need to find if the user, curently logged in, is Admin or not. This should work in any WinOS, from Win95B to WinME and from WinNT4 to WinXP.

I need it because I ammaking a program that is supposed to be used by Administrators only, whether it is WS or stand-alone machine. It is a utility program, that is to configure the environment for my mainstreem product. Therefore, I need to protect this program from being used by unsophisticated user.

I searched Windows Registry on my WinME machine trying to find my own name (and I was not logged into our LAN). I found it a-planty in MRU sections (my general folder for my projects carries my name), not much in any other section. The only place I found that seemed somewhat promising was

HKEY_USERS\DEFAULT\Software\Microsoft\MS Setup (ACME)\User Info\DefName

registry key.

I also searched my MSDN library (July 2001) trying to find if there is any API function for finding Admin's name - alas!

Any ideas, please?

TIA!


Regards,

Ilya
 
Ilya,
The registry only keeps track of whether the user is a local Administrator (and then only on NT/2000/XP - and unless you are one, you can see the other users!).

If you need to know if the user has Admin level security on the network, then it depends on whether they are part of a workgroup or a domain as to how this information is kept - and therefore how you retrieve it.

I don't believe there is a simple answer to this question, but I've always been amazed at how much I don't know too!

Rick
 
I think Microsoft is rather weak in their design of Win98/98se/Me in particular since there is poor support for such "obvious" keys. They are just now getting a handle on things that other OS environments have had for years. Of course, their likely excuse for not improving those versions is that in the office environment they feel you should use only NT/2000/XP, more secure computing environment, but also more expensive.

You may end up having to add that code within your FoxPro program for detection of administrator status. You could set it up as another field in the table you use for logging in to the application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top