and*_*ndy 14 asp.net security impersonation windows-services
这是我的Windows/.NET安全堆栈:
在我的默认VS2008 DEV环境中,我有这个方法,它从ASP.NET应用程序调用,它工作正常:
private static void StopStartReminderService() {
ServiceController svcController = new ServiceController("eTimeSheetReminderService");
if (svcController != null) {
try {
svcController.Stop();
svcController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
svcController.Start();
} catch (Exception ex) {
General.ErrorHandling.LogError(ex);
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我在生产服务器上运行它时,我从ServiceController收到以下错误:
源:System.ServiceProcess - > System.ServiceProcess.ServiceController - > IntPtr GetServiceHandle(Int32) - > System.InvalidOperationException消息:无法在计算机'.'上打开eTimeSheetReminderService服务.
为什么会发生这种情况,我该如何解决?
编辑:
答案如下,主要是评论,但澄清:
注意:我没有通过web.config模拟,我在代码中执行.请参阅上面的MS KB文章.
Mar*_*ATS 13
授予IIS启动/停止特定服务的权限:
subinacl /service {yourServiceName} /grant=IIS_WPG=F这将为该特定服务授予对内置IIS_WPG组的完整服务控制权限.(这适用于IIS6/Win2k3.)YMMV适用于较新版本的IIS.)
| 归档时间: |
|
| 查看次数: |
29567 次 |
| 最近记录: |