[DUG] Detecting admin privilege
Jeremy North
jeremy.north at gmail.com
Mon May 8 15:02:17 NZST 2006
That information is a bit outdated now.
Use the OpenKeyReadOnly method to avoid the issue when the user
doesn't have admin priviledges.
For the OP you need to use OpenProcessToken and GetTokenInformation
and compare the Sid with the administrator Sid which you get from
calling AllocateAndInitializeSid.
OpenProcessToken
ms-help://borland.bds4/security/security/openprocesstoken.htm
Check out the See Also section as you should really use
OpenThreadToken and if that fails use OpenProcessToken.
AllocateAndInitializeSid
ms-help://borland.bds4/security/security/allocateandinitializesid.htm
If you do a search on these keywords you might find a function already
prepared for you.
HTH,
Jeremy
On 5/8/06, Paul McKenzie <paul at smss.org.nz> wrote:
> This may help...
> This is a link I save ages ago (in case I need to do something similar)
>
> http://www.delphi32.com/info_facts/faq/faq_349.asp
> When using the TRegistry component under NT, a user with less than "administrator" rights is unable
> to access information stored in the HKEY_LOCAL_MACHINE. How can I work around this?
>
>
> The problem is caused by the fact that TRegistry (and the derived TRegInifile) always opens a key
> with KEY_ALL_ACCESS, even if only KEY_READ would be needed. You can avoid this by going back to
> using the API registry functions (RegOpenKey et al.), or create a new class from the TRegistry
> component, and change the new TRegistry class to add an access property.
>
>
>
> Regards
> Paul McKenzie
> Wellington
> New Zealand
>
>
> Phil Scadden wrote:
> > I want to detect where current user of program has write access to
> > the hkey_local_machine hive. (so I can choose to display the a settings
> > option on a menu). Short of attempt a write and then read, is there another
> > way to detect this?
> >
> > ----------------------------------------------------------
> > Phil Scadden, Institute of Geological and Nuclear Sciences
> > 764 Cumberland St, Private Bag 1930, Dunedin, New Zealand
> > Ph +64 3 4799663, fax +64 3 477 5232
> >
> > _______________________________________________
> > Delphi mailing list
> > Delphi at ns3.123.co.nz
> > http://ns3.123.co.nz/mailman/listinfo/delphi
> >
> >
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
More information about the Delphi
mailing list