我正在尝试编写一个允许非管理员用户在 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 类:
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 管理器允许您使用“连接为”复选框来做到这一点。