Solved

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

Posted on 2013-06-02
1
652 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

910 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

22 Experts available now in Live!

Get 1:1 Help Now