Start/Stop service from an ASP . NET page

谁都会走 提交于 2019-12-01 06:44:39

Solution proposed here http://support.microsoft.com/kb/306158 said

Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0

If LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
    [...]
End if

It didn't work for me.

I replaced LOGON_32_LOGON_INTERACTIVE with LOGON32_LOGON_SERVICE:

Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_LOGON_NETWORK As Integer = 3
Dim LOGON32_LOGON_BATCH As Integer = 4
Dim LOGON32_LOGON_SERVICE As Integer = 5
Dim LOGON32_LOGON_UNLOCK As Integer = 7
Dim LOGON32_LOGON_NETWORK_CLEARTEXT As Integer = 8
Dim LOGON32_LOGON_NEW_CREDENTIALS As Integer = 9
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0

If LogonUserA(userName, domain, password, LOGON32_LOGON_SERVICE,LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
    [...]
End if

And it works for me: the ASP .NET page can start/stop the service.

In my case, both LOGON32_LOGON_INTERACTIVE and LOGON32_LOGON_SERVICE don't work.

However, LOGON32_LOGON_NETWORK works for me. Note that the user has admin privilege therefore is able to start/stop the windows service.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!