Get USER SID in a Service

1.3k views Asked by At

I need to read a software license that is stored in a Registry key located under HKEY_CURRENT_USER.

I'm running in a service in the SYSTEM account, so I cannot read this key.

I discovered that this Registry key has an account in HKEY_USER, where I can read the information. But I need to find out the SID of the logged in user.

How do I find this from a service in Delphi?

1

There are 1 answers

2
Remko On BEST ANSWER

Call LookupAccountName to get the SID belonging to a given username (and the domain it belongs to). ConvertSidToStringSid can be used to convert the SID to a String.

Alternatively use the Delphi Jedi Windows Security Code Library (JWSCL).