Solved

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

Posted on 2006-07-06
2
459 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
FizzBuzz challenge 9 71
MaxSpan challenge 9 65
strCount chalenge 3 50
move one pixel 4 38
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 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

11 Experts available now in Live!

Get 1:1 Help Now