Solved

Failure of AllocateAndInitializeSid(...) on Windows 2000 Server

Posted on 2006-07-06
2
466 Views
Last Modified: 2011-10-03
Greetings!

I have written a service in C++ (Microsoft Visual Studio 6.0 SP5) that must coordinate access to a shared set of resources with another application that I've written.  The service normally runs as a Windows system account while the other application is run manually (in user-mode) by whoever is logged in to the system.

To accomplish the needed coordination of resource use, I use a mutex object that is created by the service and shared between the service and the other application.  At the time the service creates the mutex object, I need to ensure that anyone logged into the system isn't blocked from accessing the mutex object for security reasons.

To ensure access by others, I've been giving the necessary rights to the well known group "Everyone."  This worked well on all of my Windows XP systems.  Then, I noticed my application wasn't behaving properly on a Windows 2000 Server system.  After some research, I found the culprit to be the following section of code:
---------------
PSID pEveryoneSID = NULL;
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;

if((!AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID))
  || (!pEveryoneSID))
  return ERROR;
---------------
The call to AllocateAndInitializeSid was returning a success indicator, but the variable pEveryoneSID was still null.  I've not tested on other Windows 2000 Servers to know if this common to all Win2k systems or not.  Either way, I know for sure that this function properly assigns the value to pEveryoneSID on my Windows XP systems but does NOT on the Windows 2000 Server where I need it to work.

Does anyone have any insight about what might cause this?
0
Comment
Question by:dshockey
2 Comments
 
LVL 3

Expert Comment

by:Mikeh926
ID: 17057285
Well, if AllocateAndInitalizeSid is returning TRUE then it should be settings pEveryoneSID to something. Try calling SetLastError() to clear the error code first and then call GetLastError() to see if there is any error code returned. This might give you a hint (especially if you get "access denied").

As for why it works on XP and not on 2000 Server, what user account is the server running in, and are the account permissions the same?
0
 
LVL 41

Accepted Solution

by:
graye earned 125 total points
ID: 17058402
Hummm... I can't offer and explaination, but how about an alternative?

Why not use CreateWellKnownSid instead...

    //BOOL CreateWellKnownSid(
    //  WELL_KNOWN_SID_TYPE WellKnownSidType,
    //  PSID DomainSid,
    // PSID pSid,
    // DWORD* cbSid
    //);
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 132
base64 decode encode 12 134
White board coding practice 3 88
object oriented design (python) and documentation tools 2 43
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

831 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