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