如何使用.NET应用Windows组策略?
是否可以使用 .NET 应用(和删除)Windows 组策略设置?
我正在开发一个应用程序,该应用程序需要暂时将机器置于受限的、类似信息亭的状态。我需要控制的事情之一是对 USB 驱动器的访问,我相信我可以通过组策略来做到这一点。我希望我的应用程序在启动时设置策略并在退出时恢复更改...这是我可以通过 .NET 框架调用执行的操作吗?
这些是我的主要要求:
- 在我的控制台应用程序启动时应用组策略设置。
- 识别策略何时拒绝用户操作并将其记录下来。
- 可以记录到系统安全日志。
- 当我的应用程序停止时恢复我的策略更改。
Is it possible to apply (and remove) Windows group policy settings using .NET?
I am working on an application that needs to temporarily put a machine into a restricted, kiosk-like state. One of the things I need to control is access to USB drives which I believe I can do through group policy. I'd like my app to set the policy when it starts and revert the change when it exits... is this something I can do through .NET framework calls?
These are my primary requirements:
- Apply group policy settings when my console app is started.
- Identify when a user action is denied by the policy and log it.
- Logging to the system security log is acceptable.
- Revert my policy changes when my app stops.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 IGroupPolicyObject
您可以像这样调用此函数这..
Try using IGroupPolicyObject
You can call this function like this..
注意:我使用两个 GroupPolicy 程序集引用:
C:\ Windows \程序集\ GAC_MSIL \ Microsoft.GroupPolicy.Management \ 2.0.0.0__31bf3856ad364e35 \ Microsoft.GroupPolicy.Management.dll
和
C:\ Windows \程序集\ GAC_32 \ Microsoft.GroupPolicy.Management.Interop \ 2.0.0.0__31bf3856ad364e35 \ Microsoft.GroupPolicy.Management.Interop.dll
这个框架2.0,所以有混合代码,必须使用app.config: http://msmvps.com/blogs/rfennell/archive/2010 /03/27/mixed-mode- assembly-is-built-against-version-v2-0-50727-error-using-net-4-development-web-server.aspx
我就是这样做的。
NOTE: I use two GroupPolicy assembly references:
C:\Windows\assembly\GAC_MSIL\Microsoft.GroupPolicy.Management\2.0.0.0__31bf3856ad364e35\Microsoft.GroupPolicy.Management.dll
and
C:\Windows\assembly\GAC_32\Microsoft.GroupPolicy.Management.Interop\2.0.0.0__31bf3856ad364e35\Microsoft.GroupPolicy.Management.Interop.dll
This framework 2.0, so there are mixed code, and you must use app.config: http://msmvps.com/blogs/rfennell/archive/2010/03/27/mixed-mode-assembly-is-built-against-version-v2-0-50727-error-using-net-4-development-web-server.aspx
I made it like that.