Create a new IIS site using ADSI 
Author Message
 Create a new IIS site using ADSI

I'm trying to find some sample code for creating a new IIS
site using ADSI (all I was able to find was stuff for
creating a virtual directory).  I have some VB6 code to do
this but when I rewrite it, I'm apparently doing it
incorrectly because it doesn't work (I'm new to,
and the code generated by the upgrade wizard doesn't work
either.  Thanks in advance for any help (knowledgebase
articles, books you liked, websites, or anything else) you
can give.

Wed, 29 Dec 2004 07:38:01 GMT  
 Create a new IIS site using ADSI
try this:

Dim de As New System.DirectoryServices.DirectoryEntry()

        de.Path = "IIS://LocalHost/W3svc/1/root"

        Dim oo As System.DirectoryServices.DirectoryEntry

        oo = de.Invoke("Create", "IIsWebVirtualDir", "testdir")

        oo.Invoke("Put", "Path", "c:\test")


Fri, 31 Dec 2004 16:04:07 GMT  
 Create a new IIS site using ADSI
Thanks, but I needed to create a new site, not a new
virutal direcotry.  However, I think I see how I can
apply this method to rework the VB6 code I have to create
a site.

What I have been trying is this:

' at the beginning of the class
Imports System.DirectoryServices

' in the function
Dim DirEntry As New

Dim NewSite As DirectoryEntry = DirEntry.Children.Add
(2, "IIsWebServer")
NewSite.Properties("ServerComment").Value = "TestMe"
NewSite.Properties("Path").Value = "c:\inetpub"


It fails on the first NewSite.Properties statement,
saying that "The system cannot find the path specified".


>-----Original Message-----
>try this:

>Dim de As New System.DirectoryServices.DirectoryEntry()

>        de.Path = "IIS://LocalHost/W3svc/1/root"

>        Dim oo As System.DirectoryServices.DirectoryEntry

>        oo = de.Invoke

("Create", "IIsWebVirtualDir", "testdir")

>        oo.Invoke("Put", "Path", "c:\test")

>        oo.Invoke("SetInfo")


Sat, 01 Jan 2005 05:39:10 GMT  
 Create a new IIS site using ADSI
Try this:

 Dim NewSite As DirectoryEntry

        NewSite = DirEntry.Invoke("Create", "IIsWebServer", 2)

        NewSite.Invoke("Put", "ServerBindings",
        NewSite.Invoke("Put", "ServerComment", "testsite")
        ' NewSite.Invoke("Put", "Path", "c:\inetpub")
        NewSite.Invoke("Put", "KeyType", "IIsWebServer")


Sun, 02 Jan 2005 11:20:23 GMT  
 [ 4 post ] 

 Relevant Pages 

1. Create site in IIS 5/6 using

2. Add FTP site operators using ADSI and VBscript

3. Code problem when creating IIS site?

4. HELP :Creating Sites on IIS

5. VBscript to create FTP site in IIS

6. Create an IIS site by VB code...???

7. Use ASP or VB component to create a virtual web site for IIS

8. A programming methode for IIS 4.0 or IIS 5.0 Config via add new FTP site or add new website

9. Creating NT User accounts using ADSI (WinNT:) within VB.Net

10. How do I create a Group using ADSI?

11. Creating a SHARE using ADSI

12. Creating a share on a Windows95 computer using ADSI


Powered by phpBB® Forum Software