Microsoft.Web.Administration VirtualDirectory 权限

发布于 2024-08-08 09:36:48 字数 518 浏览 5 评论 0原文

我可以在下面所示的代码中使用 Microsoft.Web.Administration dll 轻松地在 IIS7 中创建虚拟目录,但我一直在绞尽脑汁地试图找出如何授予“网络服务”写入权限虚拟目录创建后。有人能指出我正确的方向吗?

Private Sub CreateVirDir(ByVal WebSite As String, ByVal AppPath As String, ByVal VirPath As String, ByVal DirPath As String)
    Dim sm As New Microsoft.Web.Administration.ServerManager()
    Dim cpapp As Microsoft.Web.Administration.Application = sm.Sites(WebSite).Applications(AppPath)
    cpapp.VirtualDirectories.Add(VirPath, DirPath)
    sm.CommitChanges()
End Sub

I'm able to create a Virtual Directory in IIS7 using the Microsoft.Web.Administration dll pretty easily in the code shown below but I've been pulling my hair out trying to find out how to give "Network Service" write permissions to the Virtual Directory once it's been created. Can anyone point me in the right direction?

Private Sub CreateVirDir(ByVal WebSite As String, ByVal AppPath As String, ByVal VirPath As String, ByVal DirPath As String)
    Dim sm As New Microsoft.Web.Administration.ServerManager()
    Dim cpapp As Microsoft.Web.Administration.Application = sm.Sites(WebSite).Applications(AppPath)
    cpapp.VirtualDirectories.Add(VirPath, DirPath)
    sm.CommitChanges()
End Sub

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

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

发布评论

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

评论(1

别低头,皇冠会掉 2024-08-15 09:36:48

假设这是 NTFS 写入权限,则您不会对虚拟目录本身应用写入权限。您需要在虚拟目录指向的文件夹上应用此权限。

您可以使用以下命名空间以编程方式设置 NTFS 权限:

System.IO
System.Security.AccessControl

以下链接包含演示如何操作 NTFS ACL 的示例代码:

文件安全类(MSDN 库)

Assuming this is NTFS write permissions, you don't apply write permissions on the virtual directory itself. You would need to apply this permission on the folder that the virtual directory points to.

You can use the following namespaces to programmatically set NTFS permissions:

System.IO
System.Security.AccessControl

The following link has example code that demonstrates how to manipulate NTFS ACL's:

FileSecurity Class (MSDN Library)

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