If you are not talking about a terminal server session, you will need LogonUser () if you are logged in as this user or ImpersonateLoggedOnUser () if you want to do something as an already registered user. Both of them can be found in Advapi32.lib.
source share