如何设置ACL的Windows服务在.net中? [英] How do I set ACL for a Windows Service in .net?

查看:134
本文介绍了如何设置ACL的Windows服务在.net中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我需要能够启动和停止按钮的服务。我正在使用一个单独的程序ServiceController的,当我运行这个单独的程序作为管理员的一切工作按预期。不过,我需要能够控制这种服务为任何人。为我服务,我如何设置权限,以便每个人都有完全控制了吗?这需要被编程作为服务的任一部分进行,或者安装。这是写在vb.net一个本地服务。

I have a service that I need to be able to start and stop with a button. I am using a ServiceController in a seperate program and everything works as intended when I run this seperate program as an administrator. However, I need to be able to control this service as anyone. How can I set the permissions for my service so that everyone has full control of it? This needs to be done programatically as either part of the service, or the install. It is a localservice written in vb.net.

推荐答案

您有几种选择:

1)你可以要求你的应用程序作为管理员运行。您的应用程序启动时,都将与UAC(在Windows 7和Vista)的提示,你的申请将被提升到所需要的水平。

1) You can require that your application runs as an administrator. Every time your application starts, you will be prompted with the UAC (on Windows 7 and Vista) and your application will be elevated to the required level.

运行.NET应用程序以管理员身份

2)你的应用程序可以请求当需要采取行动,停止和启动服务的提升。这将通过启动其他应用程序在一个较高的水平,这等应用程序将进行实际的启动和停止这样做。

2) Your application can request an elevation when the action is required to stop and start the service. It would do this by starting another application at a higher level and this other application will do the actual start and stop.

如何提升权限仅在需要时?

3)preferred选项,恕我直言 - 你应该建立自己的服务来运行所有的时间,但只是没有做任何事情,除了监听通过TCP / IP,命名管道或其他一些通信机制的请求。那么你的服务可以启动或停止一个线程执行的实际工作。

3) Preferred option, IMHO - You should build your service to run all of the time but just not do anything other than listen for requests via TCP/IP, Named Pipes or some other communication mechanism. Your service can then start or stop a thread that performs the real work.

4)你可以修改服务的权利。这里有一些帖子,让一些这方面的信息(我仍然preFER选项3):

4) You can modify the service rights. Here are some posts that give some information on this (I would still prefer option 3):

<一个href="http://stackoverflow.com/questions/4436558/start-stop-a-windows-service-from-a-non-administrator-user-account">Start /从非管理员用户帐户停止Windows服务

Start / Stop a Windows Service from a non-Administrator user account

<一个href="http://msmvps.com/blogs/erikr/archive/2007/09/26/set-permissions-on-a-specific-service-windows.aspx" rel="nofollow">http://msmvps.com/blogs/erikr/archive/2007/09/26/set-permissions-on-a-specific-service-windows.aspx

http://fstaal01.home.xs4all.nl/swsc-us.html

更新

我已经改变了一些文本,并添加基于哈里的评论选项4。它似乎有调整的权限的方法。这些都需要管理员权限最初,但如果你捆绑像申万证券(第三个链接)您的安装,你可以用它来设置权限为您服务。我不知道是否有这样做的任何许可含义。或者,你可以使用的code,他贴一个变种。

I have changed some text and added option 4 based on Harry's comment. It seems that there are ways of tweaking the permissions. These require administrator rights initially but if you bundle something like swsc (third link) with your installation, you could use it to set the rights for you. I am not sure if there are any license implications for doing this. Alternatively, you could use a variant of the code he pasted.

这篇关于如何设置ACL的Windows服务在.net中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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