Starting a service in ASP.NET/C# with the right permissions

前端 未结 1 1234
小鲜肉
小鲜肉 2021-01-28 07:06

on my website (written in ASP.NET/C#) I want the moderaters to be able to start a certain service. The code I have for this is:

    ServiceController svcControll         


        
相关标签:
1条回答
  • 2021-01-28 07:33

    You have to make sure that your web site is running under a user who have enough right to start the service. Make sure also that the anonymous authentication is disabled on IIS A good way could be to create a user who has rights for starting service on the server web then create an application pool that runs under that user.then you have to make your web site use that application pool. Using this approach all the web site will run under the user you have just create. If you want be more granular you can still create the user that have the rights for starting the service but instead of use it for the application pool you can make only the page that needs to start the service run under that user using the impersonation. You can use the imporsonation feature only for this method!

    for more details have a look at the links below:

    http://forums.asp.net/t/1137962.aspx/1

    http://support.microsoft.com/kb/306158

    0 讨论(0)
提交回复
热议问题