Solved

GetTokenInformation fails (error 998) on windows server 2003 but works on 2008

Posted on 2013-06-02
1
658 Views
Last Modified: 2013-12-03
Hi,
I have a problem when calling GetTokenInformation,
for some reason it fails on windows server 2003 32bit but succeeds on server 2008 64bit.
   PTOKEN_USER pSIDTokenUser = NULL;
   DWORD       dwReturnLength;   
   
      if (!GetTokenInformation(hToken, TokenUser, NULL, 0, &dwReturnLength) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
      {
               //handle error
      }

      pSIDTokenUser = (PTOKEN_USER)new BYTE[dwReturnLength];
      memset(pSIDTokenUser, 0, dwReturnLength); 


      if (!pSIDTokenUser)
               //handle error

      if (!GetTokenInformation(hToken, TokenUser, pSIDTokenUser, dwReturnLength, NULL))
               //handle error 

Open in new window


the second call to GetTokenInformation on windows 2003 always return 0 with the error 998 ("Invalid access to memory location").
I assume it has something to do with the pSIDTokenUser size/alignment (I use the default)  etc, but could not find the reason.

Thanks.
0
Comment
Question by:Cyber-EE
1 Comment
 

Accepted Solution

by:
Cyber-EE earned 0 total points
ID: 39215404
Found the answer:
last parameter is not optional. you need to pass it even though it is not used.
this was probably fixed in 2008, since its works there.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

770 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