Solved

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

Posted on 2006-07-06
2
467 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article will show, step by step, how to integrate R code into a R Sweave document
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

856 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