Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Sun, 13 Jul 2008 16:53:46 -0400,    group: microsoft.public.platformsdk.security        back       


GetNamedSecurityInfo, AddAceToObjectsSecurityDescriptor and Error 87   
Using a MSDN supplied code to modify sacls on a registry entry and I am 
getting an error 87 when GetNamedSecurityInfo is called. The error best 
I can tell from googling is a bad parameter but I can't for the life of 
me find the bad parameter. The code is below. It is probably really 
obvious but I am completely missing it. The problem is almost definitely 
in szKey or SE_REGISTRY_KEY (first 2 arguments) because everything else 
is from within the example function.
Thanks,
Tom

AddAceToObjectsSecurityDescriptor is from 
http://msdn.microsoft.com/en-us/library/aa379283(VS.85).aspx and has not 
been modified.

HKEY hHkey;
LPCTSTR sTrust;
PSID psidTrust;
LPCTSTR szKey;
//HKEY hKey = HKEY_LOCAL_MACHINE;

szKey = (LPCTSTR)"MACHINE\\SOFTWARE\\TerraNovum";
sTrust = (LPCTSTR)"Users";

printf("about to add ace\n");
AddAceToObjectsSecurityDescriptor(
	(LPTSTR)szKey,
	SE_REGISTRY_KEY,
	(LPTSTR)sTrust,
	TRUSTEE_IS_NAME,
	STANDARD_RIGHTS_ALL,
	GRANT_ACCESS,
	CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE);
date: Sun, 13 Jul 2008 16:53:46 -0400   author:   Thomas Bolioli

Re: GetNamedSecurityInfo, AddAceToObjectsSecurityDescriptor and Error 87   
Thomas Bolioli  writes:

> szKey = (LPCTSTR)"MACHINE\\SOFTWARE\\TerraNovum";
> sTrust = (LPCTSTR)"Users";

Those casts are wrong if UNICODE is defined, and unnecessary otherwise.
Try instead:

szKey = TEXT("MACHINE\\SOFTWARE\\TerraNovum");
sTrust = TEXT("Users");

In addition, I suspect some localized versions of Windows may not
recognize the "Users" name.  Using the well-known SID instead
would avoid that risk.
date: Mon, 14 Jul 2008 08:26:02 +0300   author:   Kalle Olavi Niemitalo

Re: GetNamedSecurityInfo, AddAceToObjectsSecurityDescriptor and Error 87   
That was it. Thanks, I knew it was going to be something obvious because 
  I had looked into all of the least likely stuff it could be... :-)
What is the well known SID of Users? I don't know it. Also, is that 
guaranteed to be that number always?
Tom

Kalle Olavi Niemitalo wrote:
> Thomas Bolioli  writes:
> 
>> szKey = (LPCTSTR)"MACHINE\\SOFTWARE\\TerraNovum";
>> sTrust = (LPCTSTR)"Users";
> 
> Those casts are wrong if UNICODE is defined, and unnecessary otherwise.
> Try instead:
> 
> szKey = TEXT("MACHINE\\SOFTWARE\\TerraNovum");
> sTrust = TEXT("Users");
> 
> In addition, I suspect some localized versions of Windows may not
> recognize the "Users" name.  Using the well-known SID instead
> would avoid that risk.
date: Mon, 14 Jul 2008 09:22:13 -0400   author:   Thomas Bolioli

Re: GetNamedSecurityInfo, AddAceToObjectsSecurityDescriptor and Error 87   
Thomas Bolioli  writes:

> What is the well known SID of Users? I don't know it.

BUILTIN\Users is S-1-5-32-545.  It consists of these components:
1 is the SID revision level.
5 is SECURITY_NT_AUTHORITY.
32 is SECURITY_BUILTIN_DOMAIN_RID.
545 is DOMAIN_ALIAS_RID_USERS (not DOMAIN_GROUP_RID_USERS).

To add that to an access control list, you'll need TRUSTEE_IS_SID,
and a PSID that you can get from any of AllocateAndInitializeSid,
CreateWellKnownSid, or ConvertStringSidToSid.

> Also, is that guaranteed to be that number always?

According to KB243330, the values of well-known SIDs "remain
constant across all operating systems."
date: Mon, 14 Jul 2008 19:15:15 +0300   author:   Kalle Olavi Niemitalo

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us