Getting the current user information?

hi guys,
In my application,i need to enabling or disabling the controls based on the user privilege .ie if the user is an administrator some of the option is visible otherwise it has to be hide.

So whether there is an possiblity for checking the useris an administrator,poweruser or guest etc...
Thx in advance
Regards
vjayaprasen

 
vjayaprasenAsked:
Who is Participating?
 
Roshan DavisConnect With a Mentor Commented:
BOOL 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);
}
0
 
vjayaprasenAuthor Commented:
hi roshman,
i got a error message like
CheckTokenMembership undeclared identifier..
i also try it for including advapi32.lib .
i am using MFC dialog based application
thx
regards
vijayaprasen
0
 
Roshan DavisCommented:
including "Advapi32.lib" will work...

Project->Settings=>Link

type "Advapi32.lib" in the Object Modules text box

Rosh :)
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
vjayaprasenAuthor Commented:
i already inluded that .lib ..
but it doesnt seems to work
:-(
regards
prakash
0
 
Roshan DavisCommented:
Plz copy/paste the error text here
0
 
vjayaprasenAuthor Commented:
error C2065: 'CheckTokenMembership' : undeclared identifier
0
 
Roshan DavisCommented:
I think u hav to install platform sdk 2000
0
 
vjayaprasenAuthor Commented:
mine PC have already platform sdk 2000 installed
:-(
vjayaprasen
0
 
akalmaniCommented:
Did you include the header file

#include <winbase.h>

I see no other reason why it should not work.
0
 
Roshan DavisCommented:
put this in your stdafx.h

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
0
All Courses

From novice to tech pro — start learning today.