Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-02
1
Medium Priority
?
695 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
This article is about my experience upgrading my consulting machine to Windows 10 Version 1709 (The Fall 2017 Creator Update)
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

916 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