Server 2008无法设置用户权限

发布于 2024-09-25 16:47:44 字数 546 浏览 3 评论 0原文

我尝试在 C# 3.5 中执行一些 Win32 操作,以获得控制台应用程序的提升用户权限。我在 Visual Studio 2008 SP1/GDR 上进行开发,在调试器下运行时一切正常。当我独立运行控制台应用程序时,一切也正常。当我将所有内容打包到 MSI 并将其安装在 2003 服务器上并运行控制台应用程序时,一切也运行良好。

如果我采用相同的 MSI 并将其安装在启用了 UAC 的 2008 服务器上,然后运行控制台应用程序,我会收到如下消息:

Unable to set right for the account "DOMAIN\QAUSER": SeCreateGlobalPrivilege
System.UnauthorizedAccessException    Attempted to perform an unauthorized operation.

我不能指望我的部署/服务器管理员除了安装它之外对我的应用程序执行任何操作,并且他们不会关闭 UAC。必须有某种编程方式来正确设置我可以添加到控制台应用程序的用户权限 - 有人知道如何做吗?

谢谢。

I attempted to do some Win32 stuff in C# 3.5 to get elevated User Rights for a console app. I develop on Visual Studio 2008 SP1/GDR and things work fine when run under the debugger. Things also work fine when I run the console app stand-alone. Things also run fine when I package everything into an MSI and install it on a 2003 server and run the console app.

If I take the same MSI and install it on a 2008 server with UAC enabled, then run the console app, I get messages like this:

Unable to set right for the account "DOMAIN\QAUSER": SeCreateGlobalPrivilege
System.UnauthorizedAccessException    Attempted to perform an unauthorized operation.

I cannot expect my deployment/server admins to do anything with my app other than install it, and they are not going to turn off UAC. There must be some programmatic way to properly set user rights that I can add to the console app - anyone know how?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫﹏色ふ单纯 2024-10-02 16:47:44

可能您使用“Global\”前缀应用程序中的对象名称,并且您的应用程序将在远程桌面会话主机(RD 会话主机)服务器会话内启动。如果您的程序必须启用 SE_CREATE_GLOBAL_NAME (SeCreateGlobalPrivilege) 权限。请参阅 C# – 如何启用 SeDebugPrivilege?(但使用 SE_CREATE_GLOBAL_NAME 而不是 SE_DEBUG_NAME)或操纵权限以可靠、安全、高效的托管代码为例。

Probably you use "Global\" prefix to the object name in your application and your application will be started inside a Remote Desktop Session Host (RD Session Host) server session. In the case your program have to enable SE_CREATE_GLOBAL_NAME (SeCreateGlobalPrivilege) privilege. See C# – How to enable SeDebugPrivilege? (but use SE_CREATE_GLOBAL_NAME instead of SE_DEBUG_NAME) or Manipulate Privileges in Managed Code Reliably, Securely, and Efficiently as an example.

弃爱 2024-10-02 16:47:44

我假设 2008 机器上启用了 UAC,但我还无法对您的问题发表评论以找出答案。

如果是这样,请确保在 VS 的 app.manifest 文件(在属性下)中,更改

<requestedExecutionLevel  level="asInvoker" uiAccess="false" />

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

即使代码以管理员身份运行,您也必须克服 UAC 警告。

I assume that UAC is enabled on the 2008 machine and I cannot comment yet on your question to find out.

If so, ensure that in your app.manifest file in VS (under properties), change

<requestedExecutionLevel  level="asInvoker" uiAccess="false" />

to

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />

Even if the code is running as an administrator, you have to get by the UAC warning.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文