IADs, adsObject and other stories

M

Martin c

Hi all. (please excuse the cross post, I'm none too sure where to pitch this
question)
I'm trying to write some ASP.NET to create a web site on a server form a
given set of variables, and found seom code on teh internet that does
roughly what i need. (http://www.panayot.com/articles/iis.htm) but is a
little too long winded. Between that and a C# example
(http://weblogs.asp.net/jezell/archive/2003/09/17/27869.aspx) i'm definately
starting to make prorgess.

Unfortuantely though, i am revieving the follwoing error:
"The value provided for adsObject does not implement IADs."
from the following line:
dim iisroot as new
directoryentry(cType(iisObj.invoke("Create","IIsWebServer",txtID),DirectoryE
ntry))

Does anyone know how i can fix that problem, The internet seems blank on the
subject.

T.I.A
Martin


function addSite(txtid, txtDom)
' 1) Connect to Server root
dim iisObj as new Directoryentry("IIS://Localhost/W3SVC")
' 2) Create IIsWebServer Object
dim iisroot as new
directoryentry(cType(iisObj.invoke("Create","IIsWebServer",txtID),DirectoryE
ntry))
iisroot.Invoke("Put","ServerComment",txtDom)
iisroot.Invoke("Put","KeyType", "IIsWebServer")
iisroot.Invoke("Put","ServerBindings",":80:")
iisroot.Invoke("Put","ServerState",2)
iisroot.Invoke("Put","FrontPageWeb",0)
iisroot.Invoke("Put","ServerAutoStart",1)
iisroot.Invoke("SetInfo")
' 3) Create vRoot 'Root'
iisweb = iisRoot.Children.Add("Root", "IIsWebVirtualDir")
iisWeb.Properties("AppIsolated")(0)=2
iisWeb.Properties("Path")(0)="D:\Intetpub\wwwroot"+getpath(txtDom)
iisWeb.Properties("AccessFlags")(0)=513
iisWeb.Properties("AppRoot")(0)="LM/W3SVC/"+txtID+"/Root"
iisWeb.CommitChanges()
iisRoot.CommitChanges()
' 4) Return
addSite="Created Web site for "+txtDom+" at instance "+txtID
end function
 
M

[MSFT]

Hi Martin,

Thank you for using the community. As I understand, you want to create a
web site and virtual directory with the code.

From the C# sample you mentioned:

DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");

...
// Create web site
DirectoryEntry site = (DirectoryEntry)root.Invoke("Create", "IIsWebServer",
siteID);

As you see, first we get the IIS root object ("iisObj" in your code), and
then create/find the site object. The site object is also a DirectoryEntry.
Therefore, I think your code should be:

dim iisrootsite as
directoryentry=cType(iisObj.invoke("Create","IIsWebServer",txtID),DirectoryE
ntry)

instead of

dim iisroot as new
directoryentry(cType(iisObj.invoke("Create","IIsWebServer",txtID),DirectoryE
ntry))

The Constructor of DirectoryEntry:

public DirectoryEntry(
object adsObject
);

Will accept an adsObject as parameter, not a DirectoryEntry. This is the
source of orginal error.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top