What is the shortest way of getting localized name of builtin Windows user account?

Viewed 160

I need to call CreateProcessWithLogonW, for which I need to pass builtin account name (say Administrator). The problem is that builtin account names are localized. For example in French its "Administrateur" and when I pass "Administrator" to the function, it returns ERROR_LOGON_FAILURE.

In order to get a builtin account name, I can pass its SID to LookupAccountBySid. Pretty easy. The problem is that, according to this, the SID I need to pass is following:

S-1-5-21domain-500

How do I get the domain part?

I found this code, but in order to get current user's SID (from where I could get the domain part), it calls chain of functions including OpenProcessToken, GetTokenInformation, HeapAlloc, GetSidIdentifierAuthority, GetSidSubAuthorityCount, GetSidSubAuthority...

This would be rather insane for getting simple domain string. Is there a shorter way to do this?

0 Answers
Related