Listing Account PrivilegesLast reviewed: September 25, 1995Article ID: Q119669 |
The information in this article applies to:
SUMMARYWhen a user starts a process, that process takes on the security attributes of the user. The security attributes inherited from the user include privileges, which control access to system services.
MORE INFORMATIONTo list the privileges belonging to a process (and thus to the current user), perform the following steps:
Sample Code
#include <windows.h> #include <stdio.h> void main() { HANDLE hProcess, hAccessToken; UCHAR InfoBuffer[1000]; PTOKEN_PRIVILEGES ptgPrivileges = (PTOKEN_PRIVILEGES)InfoBuffer; DWORD dwInfoBufferSize; DWORD dwPrivilegeNameSize; DWORD dwDisplayNameSize; UCHAR ucPrivilegeName[500]; UCHAR ucDisplayName[500]; DWORD dwLangId; UINT x; hProcess = GetCurrentProcess(); OpenProcessToken( hProcess, TOKEN_READ, &hAccessToken ); GetTokenInformation( hAccessToken, TokenPrivileges, InfoBuffer, sizeof(InfoBuffer), &dwInfoBufferSize); printf( "Account privileges: \n\n" ); for( x=0; x<ptgPrivileges->PrivilegeCount; x++ ) { dwPrivilegeNameSize = sizeof( ucPrivilegeName ); dwDisplayNameSize = sizeof( ucDisplayName ); LookupPrivilegeName( NULL, &ptgPrivileges->Privileges[x].Luid, ucPrivilegeName, &dwPrivilegeNameSize ); LookupPrivilegeDisplayName( NULL, ucPrivilegeName, ucDisplayName, &dwDisplayNameSize, &dwLangId ); printf( "%40s (%s)\n", ucDisplayName, ucPrivilegeName ); } } |
Additional reference words: 3.10 3.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |