Board index » delphi » Windows User rights

Windows User rights


2003-07-25 12:16:17 AM
delphi57
Two questions 1. In delphi how can I tell what the window users permissions
settings are. 2
before I install an application. does anyone know what registry value
might need to be changed so a program
can used be used by "all users" admin
Thanks if you know
 
 

Re:Windows User rights

On Thu, 24 Jul 2003 12:16:17 -0400, "dhastas"
<XXXX@XXXXX.COM>writes:
Quote
Two questions
1. In delphi how can I tell what the window users permissions
settings are.
In regards to what?
If you just need to see if the user is an administrator, you can use
the following code:
const
SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority =
(Value: (0, 0, 0, 0, 0, 5));
const
SECURITY_BUILTIN_DOMAIN_RID = $00000020;
DOMAIN_ALIAS_RID_ADMINS = $00000220;
function IsAdmin: Boolean;
var
hAccessToken: THandle;
ptgGroups: PTokenGroups;
dwInfoBufferSize: DWORD;
psidAdministrators: PSID;
x: Integer;
bSuccess: BOOL;
begin
Result := False;
bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True,
hAccessToken);
if not bSuccess then
begin
if GetLastError = ERROR_NO_TOKEN then
bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY,
hAccessToken);
end;
if bSuccess then
begin
GetMem(ptgGroups, 1024);
bSuccess := GetTokenInformation(hAccessToken, TokenGroups,
ptgGroups, 1024, dwInfoBufferSize);
CloseHandle(hAccessToken);
if bSuccess then
begin
AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2,
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, psidAdministrators);
for x := 0 to ptgGroups.GroupCount - 1 do
if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then
begin
Result := True;
Break;
end;
FreeSid(psidAdministrators);
end;
FreeMem(ptgGroups);
end;
end;
Quote
2 before I install an application.does anyone know what registry value
might need to be changed so a program
can used be used by "all users" admin
"All Users" and "admin" are not the same thing. I am not sure what
you're asking here.
---
Yorai Aminov (TeamB)
develop.shorterpath.com/yorai
(TeamB cannot answer questions received via email.)