Windows 7 - Determining an administrator on Vista

Asked By A
03-Feb-09 03:46 PM
I am using the techinque to get the TokenElevationType using the API
GetTokenInformation on Vista to determine if a user is an admin. It seems to
work fine on Vista Business/Ultimate etc. However, it fails on Vista Home.
Does anyone have any clues?

The code is along the following lines:

TOKEN_ELEVATION_TYPE elevationType;
DWORD dwSize;

GetTokenInformation(hUserToken, TokenElevationType, &elevationType,
sizeof(elevationType), &dwSize);

switch (elevationType)
{
case TokenElevationTypeDefault:
TRACE(_T("TokenElevationTypeDefault - User is not using a split token\n"));
m_bAdmin = FALSE;
break;

case TokenElevationTypeFull:
TRACE(_T("TokenElevationTypeFull - User has a split token, and the
process is running elevated\n"));
m_bAdmin = TRUE;
break;

case TokenElevationTypeLimited:
TRACE(_T("TokenElevationTypeLimited - User has a split token, but the
process is not running elevated\n"));
m_bAdmin = TRUE;
break;

}

Thanks.
Windows Vista
(1)
Vista
(1)
TokenElevationTypeDefault
(1)
TokenElevationType
(1)
GetLastError
(1)
HUserToken
(1)
ElevationType
(1)
D6b96f0bac0c419cce51220fb62c841e
(1)
  Sam Hobbs replied...
04-Feb-09 03:02 PM
First, when posting questions about a function that returns potential
errors, include the error code. This function returns an error code that is
obtained by GetLastError. If you have not used GetLastError for this then if
you do use it for this you might have an answer. If the error code does not
immediately tell you what the problem is then search for GetTokenInformation
with the error code. You might need to convert the error code to a symbolic
name; look in winerror.h to do that. Or you might need to search the error
code with a "0x" prefix. Search the MSDN, and if that does not help, search
the Windows programming security group (Google groups might help) and if
that does not help search the internet.

Second, any time a question says something such as "doesn't work" or
I describe above.

Finally, this is not a programming group. You should ask in the Windows
programming security group.
  SuperXero replied...
04-Feb-09 03:57 PM
How about this instead. Right Click on my computer, click manage, local
users and groups, users, right click, properties, member of. If they are
in the administrators group they are an admin.

SuperXero
*'HackingManual.Net' (http://hackingmanual.net)*


--
SuperXero
  A replied...
04-Feb-09 04:05 PM
You obviously are clueless about what I asked. If you do not know, that is
fine but please do not waste everyone's time by responding with useless
messages.
  Mark H replied...
04-Feb-09 04:25 PM
http://www.developmentnow.com/groups/post.aspx?newsgroupid=21&threadid=851943

http://blogs.msdn.com/cjacks/archive/2006/10/09/How-to-Determine-if-a-User-is-a-Member-of-the-Administrators-Group-with-UAC-Enabled-on-Windows-Vista.aspx


If that doesn't answer it, contact Wang. (e-mail at end of post, first link)

to
token\n"));
  FromTheRafters replied...
04-Feb-09 05:11 PM
http://blogs.msdn.com/cjacks/archive/2006/10/09/How-to-Determine-if-a-User-is-a-Member-of-the-Administrators-Group-with-UAC-Enabled-on-Windows-Vista.aspx

Maybe these guys can be more help.
  Sam Hobbs replied...
04-Feb-09 08:20 PM
So do you think this is a programmer's group?

The answer I gave is typical of answers given in the MSDN forums. It is very
normal for people in a programmer's forum to ask for details of "fails"; in
particular what does GetLastError return when it is relevant. If this
question were responded to by a Microsoft person, they would certainly ask
for that.

What in particular do you consider incorrect?
  Sam Hobbs replied...
04-Feb-09 08:29 PM
Al (the person asking the question) needs to do it in a program. If I am
incorrect about that then the source code is misleading. In programming
forums, when someone provides source code, they cannot use a "manual"
(non-automated) solution.
  SuperXero replied...
04-Feb-09 10:38 PM
I get it sam, like if a program needs to validate someone as admin or
not admin. Yep I am not a programmer just a network admin.


--
SuperXero
  Sam Hobbs replied...
05-Feb-09 12:14 PM
Yes, there you go; there are many reasons that might be done. Generally it
would be useful for issuing a message informing someone they need to have
Administrator privileges when they don't, instead of letting them proceed
and then get a more obscure crash message.
Create New Account
help
App blocked by UAC Windows 7 hi, we developed an application and want it to run on Vista, but crashes whenever UAC is on. The error comes only When our App. trys to no need for "full administrator access token" and that is correct according to the new Vista architecture, but when our App. presents a form to registy the full version, the user User Access token, or if there's a recommended way to do this. Thanks, Najash Windows Vista Installation Discussions Vista (1) TokenElevationTypeDefault (1) TokenElevationType… (1) TokenElevationType (1) GetCurrentProcess (1) OpenProcessToken (1) RequireAdministrator (1) Najash (1) Hi Najash user, you could call: OpenProcessToken(GetCurrentProcess(), … ) then . . . GetTokenInformation( … TokenElevationType… ); then, if TokenElevationType is TokenElevationTypeDefault or TokenElevationTypeLimited, you have a standard user. There are probably other ways to do it
windows mail Windows 7 how do you setup the email account for windows? Windows Vista Mail Discussions Windows Vista (1) Windows Vista Windows Mail (1) Volunteer J Microsoft (1) Windows Vista fabian allen (1) Volunteer Solutions
Lisence & Versions Windows 7 Hi, I have new PC without OS. I want to install Windows Vista Ultimate but when I searched a little I found so MANY versions that are confusing me: Windows Vista Home Basic 32-bit Windows Vista Home Premium 32-bit Windows Vista Business 32-bit Windows Vista Ultimate 32-bit Windows Vista Home Basic 32-bit
New list: The 10 Worst Operating Systems of All Time Windows 7 1 Windows Vista starters 2 Windows Vista home 3 Windows Vista home Premium Retail 4 Windows Vista business Retail 5 Windows Vista Ultimate Retail 6 Windows Vista Enterprise 7 Windows Vista