Re: DataSnap server DCOM installation.
From: Colin Wilson (colin_at_wilsonc.demon.co.uk)
Date: 12/19/03
- Next message: luca gallo: "need help on WTSQuerySessionInformation"
- Previous message: paudominguez_at_estudioceramico.es: "Re: Power saving management"
- In reply to: Colin Wilson: "Re: DataSnap server DCOM installation."
- Next in thread: Vikram Kulkarni: "Re: DataSnap server DCOM installation."
- Reply: Vikram Kulkarni: "Re: DataSnap server DCOM installation."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Dec 2003 02:54:17 -0700
Colin Wilson wrote:
> I've got some code that does this. I'll try and post it tomorrow -
> for some reason it's not on my website.
Ok - here's how it works...
1. The DefaultLaunchPermissions (and LaunchPermission in AppID) hold a
security descriptor so you can load it like in snippet 1 below.
2. Once you've got the PSECURITY_DESCRIPTOR from the registry you get
the ACL with the standard GetSecurityDecriptorDacl API.
3. Once you've got the ACL you know how many ACEs there are with
ACL^.AceCount.
4. You can then get each ACE with the GetACE API. That gives you the
SID for the account, and the ace type - allowed or denied.
5. To change the permissions you need to reverse the above steps.
First build an ACL with the ACES you want, add them to a new
(initialized) security descriptor (with SetSecurityDescriptorDACL),
then save it to the registry (snippet 2!). Some of this is tricky -
especially building the ACL. But there's free code available in my
website that shows how to do it. Go for the "NT Low Level Utilities"
package, and have a look in unitNTSecurity.pas
--- Snippet 1 ------
function AllocSDFromRegistry (rootKey : HKEY; const regPath, accessKey
: string; var sd : PSECURITY_DESCRIPTOR; var sdLen : DWORD) : boolean;
var
reg : TRegistry;
size : Integer;
begin
result := False;
reg := TRegistry.Create;
try
reg.RootKey := rootKey;
if reg.OpenKeyReadOnly (regPath) then
begin
size := reg.GetDataSize (accessKey);
if size > -1 then
begin
GetMem (sd, size);
reg.ReadBinaryData (accessKey, sd^, size);
sdLen := size;
result := True
end
else
begin
GetMem (sd, SECURITY_DESCRIPTOR_MIN_LENGTH);
InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(sd, True, Nil, False);
sdLen := SECURITY_DESCRIPTOR_MIN_LENGTH
end
end
finally
reg.Free
end
end;
--- Snippet 2
procedure SaveSDToRegistry (rootKey : HKEY; const regPath, accessKey :
string; sd : PSecurityDescriptor; sdLen : DWORD);
var
reg : TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey := rootKey;
if reg.OpenKey (regPath, True) then
reg.WriteBinaryData (accessKey, sd^, sdLen);
finally
reg.Free
end
end;
-- Colin - using XanaNews HTTP Transport e-mail :colin@wilsonc.demon.co.uk web: http://www.wilsonc.demon.co.uk/delphi.htm Posted with XanaNews 1.15.8.4
- Next message: luca gallo: "need help on WTSQuerySessionInformation"
- Previous message: paudominguez_at_estudioceramico.es: "Re: Power saving management"
- In reply to: Colin Wilson: "Re: DataSnap server DCOM installation."
- Next in thread: Vikram Kulkarni: "Re: DataSnap server DCOM installation."
- Reply: Vikram Kulkarni: "Re: DataSnap server DCOM installation."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|