Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check username and password of Windows account

Tags:

winapi

I have an installation package that installs a service process that I create. I'd like to prompt the user for the username/password of the account that the service process should run under. I'd like to verify the the username/password combination are valid before continuing with the installation. I have a C DLL that I am using for special installation behavior, but I can't figure out how to use the Windows API to verify an account's credentials. I'd like to be able to support the same account name syntax used by the service control manager.

like image 998
Jason Avatar asked Oct 20 '08 20:10

Jason


2 Answers

The function you want to use is LogonUser. You can even be extra-cool and specify the LOGON32_LOGON_SERVICE flag which checks to make sure the user has the appropriate permissions to run a service.

like image 160
Nick Avatar answered Oct 14 '22 23:10

Nick


LogonUser is the canonical way to do this, though Microsoft somewhat discourages it.

like image 2
Mark Brackett Avatar answered Oct 14 '22 23:10

Mark Brackett