How do I get the GUID of the currently logged in user?

RainMakker used Ask the Experts™
I would like to be able to get the Active Directory GUID of the logged in user from the windows registry.  I see my GUID in:

HLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*\<guid>

But looking through all of these values to see if the "ProfileImagePath" matches the logged in user name seems goofy.  I can easily get the logged in user name with my Delphi app, so this is very doable, but it seems a strange way to go about it.

Any suggestions?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


Thanks, but . . .

1.  The first one gets users logging into a remote computer.  I need the user logged into the local machine.
2.  The second gets the GUID from Active Directory, I need the GUID from the local machine to validate against active directory.
3.  I really need to make this work within my computer, not in a command window.
Sinisa VukSoftware architect
Top Expert 2012

Please take a look at theroadtodelphi blog. This is a good delphi resource. Using ADSI interface - you should be able to get a lots of information about AD without to dig in registry.
I'm using CoADSystemInfo (part of unit ActiveDs_TLB;).  It appears that if the user is not logged into Active Directory that calls to the CoADSystemInfo object throw and error.  This is all I need to know (that the user is not logged in to Active Directory).


No other answer helped.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial