ServiceController的权限 [英] servicecontroller permissions

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

问题描述

我已经写了这一个网站可以使用该方法的ExecuteCommand远程执行命令的服务。我注意到,如果网站是不是一个用户是远程计算机上的管理员,然后在运行,我得到的,就是要执行命令的权限被拒绝例外。

I have written a service which a website can execute a command on remotely using the ExecuteCommand method. I have noticed that if the website is not running under a user that is an admin on the remote machine then I get a permission denied exception on trying to execute command.

该ServiceController的类甚至没有让你指定任何认证参数。这是正确的吗?是否有一组特定的privelages的用户需要,而​​不是管理员,因为我不愿意在我们的集群中添加所有的Web服务器的用户作为服务机器?

The servicecontroller class doesn't even allow you to specify any authentication parameters. Is this right? Are there a specific set of privelages the user need rather than an admin, as I am reluctant to add all the webservers users in our cluster as local admins on the service machine?

推荐答案

您将有冒充当前线程的管理员用户暂时再回复。查找 WindowsIdentity.Impersonate() MSDN中

You will have to impersonate an admin user for the current thread temporarily then revert back. Look up WindowsIdentity.Impersonate() in MSDN.

的ServiceController将使用当前线程的主体,使注册表和服务控制管理器调用,你必须确保它被设置为一个管理员用户,如果你要处理的服务。缺点是,你需要在一些地方保存的密码帐户,请确保您使用的 SecureString的,而不是存储在纯文本的密码。

ServiceController will use the current thread's principal to make the registry and service control manager calls and you have to make sure it is set to an admin user if you want to manipulate the services. The downside is that you will need to store the password somewhere for the account, make sure you are using SecureString and not storing the password in plain-text.

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

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