代码之家  ›  专栏  ›  技术社区  ›  BlackICE

使用vb.net作为非特权用户以编程方式在iis 6中创建虚拟目录

  •  2
  • BlackICE  · 技术社区  · 16 年前

    我正在尝试编写一个应用程序,允许非管理员用户在IIS6中创建虚拟目录。我尝试了许多不同的方法来模拟管理帐户,但似乎没有任何方法能够创建虚拟目录。

    以下是我尝试过的一些方法:

    dim sDirPath as string = "IIS://remotehost/W3svc/1/root"
    Dim de As DirectoryEntry = New DirectoryEntry()
    de.Path = sDirPath
    de.AuthenticationType = AuthenticationTypes.Secure
    de.Username = tbxUsername.Text
    de.Password = tbxPassword.Text
    ''Fails here
    virtualId = CType(de.Invoke("Create", "IIsWebVirtualDir", dirName), DirectoryEntry)
    

    使用来自的AccountAlias类 here :

    aa.BeginImpersonation()
    Try
        dim sDirPath as string = "IIS://remotehost/W3svc/1/root"
        Dim de As DirectoryEntry = New DirectoryEntry()
        de.Path = sDirPath
        de.AuthenticationType = AuthenticationTypes.Secure
        ''Fails Here
        virtualId = CType(de.Invoke("Create", "IIsWebVirtualDir", dirName), DirectoryEntry)
    Finally
        aa.EndImpersonation()
    End Try
    

    在winforms应用程序中模拟另一个用户的正确方法是什么?该方法允许我创建虚拟目录,而运行该应用程序的用户不是web服务器上的管理员?我知道这是可以做到的,IIS管理器允许您使用“连接为”复选框来做到这一点。

    1 回复  |  直到 16 年前
        1
  •  2
  •   JaredPar    16 年前

    IIS的根目录受ACL保护,ACL需要管理权限才能创建新目录。一个简单的模拟可能无法解决这个问题,因为我相信在幕后,您将同时结合COM和RPC或本地RPC。在本机代码中,跨越COM边界的模拟很棘手,而在托管代码中,则非常棘手。很有可能你在这方面遇到了一个问题,你的模仿技巧。

    推荐文章