设置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.
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="/link/to?link=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.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfjjfk
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20