Creating an HTTP-Redirected Virtual Directopry in IIS 6.0 without specifying physical path & WMI/ADS
Posted
by Steve Johnson
on Stack Overflow
See other posts from Stack Overflow
or by Steve Johnson
Published on 2010-05-26T06:55:13Z
Indexed on
2010/05/26
7:01 UTC
Read the original article
Hit count: 299
My question is : Is it possible to create a working IIS 6.0 Virtual Directory with providing Physical Path of the Virtual Directory.?
I know that manually, it is not possible via IIS but programmatically such a virtual directory can be created. If an HTTPRedirect is set on that virtual directory but the site physical path is not specified, then will it work?
Simply stated, how to create an HTTp-redirected Virtual Directory , directly without specifying any physical path to a folder or network share.
Here is my code.
Try
If Directory.Exists(HomeDirectory) = False And Path.StartsWith("http://") = False Then
Directory.CreateDirectory(HomeDirectory)
End If
Dim website As DirectoryEntry
website = New DirectoryEntry("IIS://" & IISServer & "/W3SVC/" & WebsiteId & "/Root")
Dim NewVDir As DirectoryEntry = website.Children.Add(VDirName, "IIsWebVirtualDir")
If Path.StartsWith("http://") = False Then
NewVDir.Properties("Path")(0) = Path
NewVDir.Properties("HttpRedirect").Clear()
Else
NewVDir.Properties("HttpRedirect")(0) = Path
End If
If ((Perm And Permission.Read) = Permission.Read) Then
NewVDir.Properties("AccessRead")(0) = True
End If
If ((Perm And Permission.Write) = Permission.Write) Then
NewVDir.Properties("AccessWrite")(0) = True
End If
If ((Perm And Permission.DirBrowse) = Permission.DirBrowse) Then
NewVDir.Properties("EnableDirBrowsing")(0) = True
End If
If ((Perm And Permission.CreatetApplication) = Permission.CreatetApplication) Then
NewVDir.Invoke("AppCreate", True)
End If
If ((Perm And Permission.ScriptOnly) = Permission.ScriptOnly) Then
NewVDir.Properties("AccessScript")(0) = True
End If
If ((Perm And Permission.ScriptNExecute) = Permission.ScriptNExecute) Then
NewVDir.Properties("AccessExecute")(0) = True
End If
NewVDir.Properties("AuthAnonymous")(0) = True
NewVDir.Properties("AuthNTLM")(0) = True
NewVDir.Properties("AnonymousUserName")(0) = AnonUserName
NewVDir.Properties("AnonymousUserPass")(0) = AnonPassword
NewVDir.Properties("AppFriendlyName")(0) = AppFriendlyName
NewVDir.CommitChanges()
website.CommitChanges()
NewVDir.Close()
website.Close()
Success = True
Catch Err As Exception
Throw New Exception("My Custom Exception Here: " & Err.Message)
End Try
© Stack Overflow or respective owner