Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting the current user information?

Posted on 2004-03-29
10
531 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

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
 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 140
string initialization in java 11 115
maven archtype selection in eclipse 1 57
Path of Workbook 3 86
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.

808 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