从 ASP.NET 站点创建 Windows 帐户并设置文件权限
我正在构建一个 ASP.NET 应用程序,它将在服务器上创建 Windows 帐户和组,并为这些帐户设置文件/文件夹权限。
我该如何做到这一点?
我曾考虑过使用 CACLS.exe,但我有一种感觉,这最终会让我陷入其他问题。 .NET 框架中还有其他选项吗?
I’m building an ASP.NET application, which will create Windows accounts and groups on the server, and set file/folder permissions for those accounts.
How do I accomplish that?
I’ve considered shelling out to CACLS.exe, but I got a feeling that’s going to get me into other problems eventually. Are there any other options in the .NET framework?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我实现类似目标的一种方式。这就是某些操作或进程需要管理权限的情况,而您尝试通过 ASP.NET 来执行此操作的方法是构建 WCF 服务应用程序(理想情况下作为自托管服务)并让它以管理员身份运行。
然后,从 ASP.NET 应用程序中调用服务中的方法,它就可以工作了。
编辑
这是使控制台应用程序成为WCF自托管应用程序的代码
上面代码清单中的类
AppCmdService
是我的WCF服务类One way in which I've achieved something similar. That is where some operation or process requires administrative privileges and you're trying to do this via ASP.NET is to build a WCF service application (ideally as a self hosted service) and have it running as Administrator.
Then from your ASP.NET application you call methods in your service and it works.
EDIT
Here is the code to make a console application a WCF self hosted application
The class
AppCmdService
in the code listing above is my WCF service class似乎是 System.DirectoryServices.AccountManagement 命名空间我在找。我将把它很好地包装在 WCF 服务中(感谢 Shiv Kumar),并从我的应用程序。
It seems it's the System.DirectoryServices.AccountManagement Namespace I'm looking for. I'm going to wrap that up nicely in a WCF service (thanks, Shiv Kumar) and call that from my app.