Active Directory中的ServiseController [英] ServiseController in Active Directory

查看:122
本文介绍了Active Directory中的ServiseController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.

我有一个InvalidOperationException,原因不明.该代码在临时网络中工作正常,但是当您升级到Active Directory时,出现了此问题.

我具有足够的访问权限. Windows工具服务"使我有机会更改服务状态.但是,当您尝试使用ServiseController进行操作时,我是InvalidOperationException.


一个简单的例子:

Hello.

I have InvalidOperationException for an unknown reason to me. The code worked fine in an ad hoc network, but when you upgrade to Active Directory, I got this problem.

I have sufficient access rights. Windows tool "Services" give me the opportunity to change the status of services. However, I am InvalidOperationException when you try to do this with ServiseController.


a simple example:

ServiceController sc = new ServiceController(@"SomeService", @"SomeMachine");


在这里,我得到一个具有所有成员值的服务实例.


Here I get an instance of service with all members values.

sc.Refresh();
if (sc.Status == ServiceControllerStatus.Runing)


同时更新和读取状态.


update and read state as well.

sc.Stop();


但是(以及其他任何更改状态的尝试)都收到了InvalidOperationException.

您能否告诉我们使用优质的服务工具执行此代码的可能原因是什么?


非常感谢.


But (and any other attempt to change the state) are getting an InvalidOperationException.

Can you please tell what are the possible reasons for this execution of the code wiht fine working Services tool.


Thank you very much.

推荐答案

我相信这里的问题是权限之一.我知道您说您拥有必要的权限,但这并不意味着您的应用程序拥有.首先,如果您在Windows 7上运行,则需要确保以管理员身份运行应用程序(模式,而不仅仅是以管理员身份登录).

接下来,您可能需要查看模拟.看起来这个Stack Overflow问题描述了类似的问题,并且列出了解决方案:

> http://stackoverflow.com/questions/2996282/how- to-remotely-control-a-windows-service-with-servicecontroller [ http://stackoverflow.com/questions/6866104/c-sharp-service-远程计算机上的状态 [ ^ ]
I believe the issue here is one of permissions. I know you stated you have the necessary permissions, but that doesn''t mean your application does. First, if you are running on Windows 7, you will need to make sure you are running your app as administrator (the mode, not just logged in as admin).

Next, you might need to look at impersonation. It looks like this Stack Overflow question describes a similar issue and it has a listed solution:

http://stackoverflow.com/questions/2996282/how-to-remotely-control-a-windows-service-with-servicecontroller[^]

Here is another one with code listed:

http://stackoverflow.com/questions/6866104/c-sharp-service-status-on-remote-machine[^]


这篇关于Active Directory中的ServiseController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆