I have the following piece of code that is used to share data between
terminal server sessions, it simply sets up a memory map using the swap
file, all standard stuff. It works just fine when used on when the user is
logged on as an Adminstrator, however if the user is NOT logged on as an
Administrator, for some reason the CreateFileMapping function fails with the
error message 'Access is denied' (retrieved using GetLastError). Furthermore
if the Adminisrator first logs on and creates the filemapping then
subsequent non-adminstrative users can open the file map.
cSPMemoryMap := 'Global\SP_MEMORYMAP';
InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDACL(@SD, True, nil, False);
SA.bInheritHandle := False;
SA.lpSecurityDescriptor := @SD;
SA.nLength := SizeOf(SA);
hSPMemoryMap := OpenFileMapping(FILE_MAP_WRITE, False, cSPMemoryMap);
if hSPMemoryMap = 0 then
hSPMemoryMap := CreateFileMapping($FFFFFFFF, @SA, PAGE_READWRITE, 0, 4095,
cSPMemoryMap);
SPMemoryMapData := MapViewOfFile(hSPMemoryMap, FILE_MAP_WRITE, 0, 0, 0);
I would be very grateful for any insight into this problem, or any
alternative approaches to sharing data between sessions under terminal
server.
Thank you
"A Parmar" <An...@StaffPlan.co.uk> schrieb im Newsbeitrag
news:41a4...@newsgroups.borland.com...
>cSPMemoryMap := 'Global\SP_MEMORYMAP';
>
>InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION);
>SetSecurityDescriptorDACL(@SD, True, nil, False);
>SA.bInheritHandle := False;
>SA.lpSecurityDescriptor := @SD;
>SA.nLength := SizeOf(SA);
One of two issues:
1. Perhaps non-admins don't have enough privileges for the ACL.
2. The memory map name seems to indicate it might be in the global
namespace?
I'd suggest playing with it, and seeing what happens.
MH.
"Jahanmir" <BJahan...@SageKHK.de> wrote in message
news:41a4c8a5$1...@newsgroups.borland.com...
> cSPMemoryMap := 'Global\SP_MEMORYMAP';
>
> InitializeSecurityDescriptor(@SD, SECURITY_DESCRIPTOR_REVISION);
> SetSecurityDescriptorDACL(@SD, True, nil, False);
> SA.bInheritHandle := False;
> SA.lpSecurityDescriptor := @SD;
> SA.nLength := SizeOf(SA);
Set bInheritHandle := True; That's the only difference I have in code
that works with different desktops (IIS user vs. logged on user)
--
Deepak Shenoy (TeamB)
Agni Software
http://www.agnisoft.com