Solved

Getting the current user information?

Posted on 2004-03-29
10
528 Views
Last Modified: 2013-11-20
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

 
0
Comment
Question by:vjayaprasen
  • 5
  • 4
10 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 125 total points
ID: 10702549
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
 

Author Comment

by:vjayaprasen
ID: 10703142
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
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10703264
including "Advapi32.lib" will work...

Project->Settings=>Link

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

Rosh :)
0
 

Author Comment

by:vjayaprasen
ID: 10703500
i already inluded that .lib ..
but it doesnt seems to work
:-(
regards
prakash
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10703523
Plz copy/paste the error text here
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:vjayaprasen
ID: 10703530
error C2065: 'CheckTokenMembership' : undeclared identifier
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10703558
I think u hav to install platform sdk 2000
0
 

Author Comment

by:vjayaprasen
ID: 10703748
mine PC have already platform sdk 2000 installed
:-(
vjayaprasen
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10704459
Did you include the header file

#include <winbase.h>

I see no other reason why it should not work.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 10710395
put this in your stdafx.h

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now