Windows Administrator account check
-
Hello, Is there a decent way to check if the user currently logged in is the Administrator?? Thanks Draco
-
Hello, Is there a decent way to check if the user currently logged in is the Administrator?? Thanks Draco
do you mean something like this: LONG WINAPI IsUserAdmin(void) { BOOL b; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; b = AllocateAndInitializeSid( &NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if(b) { if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) { b = FALSE; } FreeSid(AdministratorsGroup); } return(b); }
Martin -------------------------------------------- C'mon we all know computers are experimental devices and should only be used for playing games. Using them for alternative stuff like business, is clearly not using them for what they are intended. Colin Davies
-
do you mean something like this: LONG WINAPI IsUserAdmin(void) { BOOL b; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; b = AllocateAndInitializeSid( &NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); if(b) { if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) { b = FALSE; } FreeSid(AdministratorsGroup); } return(b); }
Martin -------------------------------------------- C'mon we all know computers are experimental devices and should only be used for playing games. Using them for alternative stuff like business, is clearly not using them for what they are intended. Colin Davies
I am so shocked that anyone understands the security stuff in windows!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
-
I am so shocked that anyone understands the security stuff in windows!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
:) LOL, it is not that difficult, you just need to spend a lot of time reading and experimenting.
Martin -------------------------------------------- C'mon we all know computers are experimental devices and should only be used for playing games. Using them for alternative stuff like business, is clearly not using them for what they are intended. Colin Davies
-
:) LOL, it is not that difficult, you just need to spend a lot of time reading and experimenting.
Martin -------------------------------------------- C'mon we all know computers are experimental devices and should only be used for playing games. Using them for alternative stuff like business, is clearly not using them for what they are intended. Colin Davies
The best thing about windows security -- is that you don't have to understand it. All those functions that want a SECURITY_ATTRIBUTES pointer happily accept a NULL pointer!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
-
The best thing about windows security -- is that you don't have to understand it. All those functions that want a SECURITY_ATTRIBUTES pointer happily accept a NULL pointer!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
:omg::omg::doh::doh: Everyday I think more and more to move on linux ;P :rolleyes:
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson ;)
-
The best thing about windows security -- is that you don't have to understand it. All those functions that want a SECURITY_ATTRIBUTES pointer happily accept a NULL pointer!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc -- PC Power delivered to your phone](http://www.soonr.com)
and still it works, using NULL indicates that default attributes for the process will be used hence the job is done for you. if you need a different attributes then you can set them up, used to be pretty dull and long code but it is getting better. get hold of books 'Writing Secure Code' and 'Writing Secure Code for Windows Vista', that's good start.
Martin -------------------------------------------- C'mon we all know computers are experimental devices and should only be used for playing games. Using them for alternative stuff like business, is clearly not using them for what they are intended. Colin Davies
-
Hello, Is there a decent way to check if the user currently logged in is the Administrator?? Thanks Draco
Lord_Draconis wrote:
Is there a decent way to check if the user currently logged in is the Administrator??
Use
IsUserAnAdmin
.
Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http:\\nibuthomas.wordpress.com
-
Hello, Is there a decent way to check if the user currently logged in is the Administrator?? Thanks Draco
Lord_Draconis wrote:
Is there a decent way to check if the user currently logged in is the Administrator??
char szName[64];
GetUserName(szName, sizeof(szName));
strcmp(szName, "Administrator");I'm not sure how useful this is going to be, however. I would think you'd want to know if the currently logged on user was a member of the Administrator group or not.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Lord_Draconis wrote:
Is there a decent way to check if the user currently logged in is the Administrator??
char szName[64];
GetUserName(szName, sizeof(szName));
strcmp(szName, "Administrator");I'm not sure how useful this is going to be, however. I would think you'd want to know if the currently logged on user was a member of the Administrator group or not.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
:-D
Mark Salsbery Microsoft MVP - Visual C++ :java: