IIS and ADSI (Trying to add a new Web Site) 
Author Message
 IIS and ADSI (Trying to add a new Web Site)

Hi!

Why does this code throw an exception:

*clip*

cWeb = (DirectoryEntry)iis.Invoke("Create",
           new Object [] {  "IIsWebServer", "3" });

string [] nBindings = new string[2];
nBindings[0] = ip + ":80:" + domain;
nBindings[1] = ip + ":80:www." + domain;

cWeb.Invoke("Put",
new Object [] {"DeafultDoc", "default.htm, default.html, default.asp,
default.aspx, default.php, default.cgi, index.htm, index.html,
index.asp, index.aspx, index.php, index.cgi, welcome.htm, welcome.html,
welcome.asp, welcome.aspx, welcome.php, welcome.cgi"});
cWeb.Invoke("Put", new Object [] {"ServerComment", description});
cWeb.Invoke("Put", new Object [] {"ConnectionTimeout", 600 });
cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings });

cWeb.Invoke("SetInfo", null);
iis.CommitChanges();

*clip*

Both "DeafultDoc" and "ServerBindings" throws an exception. If I comment
out the two lines, the code works.

Is there any example code on how to add a Web Site in IIS. (C#)? The VB
version of the code, didn't help me.

Lars Andre



Sun, 05 Dec 2004 17:18:16 GMT  
 IIS and ADSI (Trying to add a new Web Site)
Lars, two questions for you:
1. are nBindings[0] and nBindings[1] what you would expect them to be?
2. It's probably just a type in your post but Default is spelled wrong, that
would throw an exception by itself.
3. What is the exception that is thrown on each line?

--
Greg
http://www.claritycon.com/


Quote:
> Hi!

> Why does this code throw an exception:

> *clip*

> cWeb = (DirectoryEntry)iis.Invoke("Create",
>            new Object [] {  "IIsWebServer", "3" });

> string [] nBindings = new string[2];
> nBindings[0] = ip + ":80:" + domain;
> nBindings[1] = ip + ":80:www." + domain;

> cWeb.Invoke("Put",
> new Object [] {"DeafultDoc", "default.htm, default.html, default.asp,
> default.aspx, default.php, default.cgi, index.htm, index.html,
> index.asp, index.aspx, index.php, index.cgi, welcome.htm, welcome.html,
> welcome.asp, welcome.aspx, welcome.php, welcome.cgi"});
> cWeb.Invoke("Put", new Object [] {"ServerComment", description});
> cWeb.Invoke("Put", new Object [] {"ConnectionTimeout", 600 });
> cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings });

> cWeb.Invoke("SetInfo", null);
> iis.CommitChanges();

> *clip*

> Both "DeafultDoc" and "ServerBindings" throws an exception. If I comment
> out the two lines, the code works.

> Is there any example code on how to add a Web Site in IIS. (C#)? The VB
> version of the code, didn't help me.

> Lars Andre




Sun, 05 Dec 2004 20:53:00 GMT  
 IIS and ADSI (Trying to add a new Web Site)

Quote:

> Lars, two questions for you:
> 1. are nBindings[0] and nBindings[1] what you would expect them to be?

nBindings[0] = "10.10.1.59:80:sol.no"
nBindings[1] = "10.10.1.59:80:www.sol.no"

And that is correct...

Quote:
> 2. It's probably just a type in your post but Default is spelled wrong, that
> would throw an exception by itself.

oops, thats my fault. Type too much too fast.

Quote:
> 3. What is the exception that is thrown on each line?

cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings }) :
Error: Exception has been thrown by the target of an invocation.
Error: Exception from HRESULT: 0x8000500C.

I get the same error if try to pass one string (no array).

Documentaion:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisr...

Quote:
> --
> Greg
> http://www.claritycon.com/



>>Hi!

>>Why does this code throw an exception:

>>*clip*

>>cWeb = (DirectoryEntry)iis.Invoke("Create",
>>           new Object [] {  "IIsWebServer", "3" });

>>string [] nBindings = new string[2];
>>nBindings[0] = ip + ":80:" + domain;
>>nBindings[1] = ip + ":80:www." + domain;

>>cWeb.Invoke("Put",
>>new Object [] {"DeafultDoc", "default.htm, default.html, default.asp,
>>default.aspx, default.php, default.cgi, index.htm, index.html,
>>index.asp, index.aspx, index.php, index.cgi, welcome.htm, welcome.html,
>>welcome.asp, welcome.aspx, welcome.php, welcome.cgi"});
>>cWeb.Invoke("Put", new Object [] {"ServerComment", description});
>>cWeb.Invoke("Put", new Object [] {"ConnectionTimeout", 600 });
>>cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings });

>>cWeb.Invoke("SetInfo", null);
>>iis.CommitChanges();

>>*clip*

>>Both "DeafultDoc" and "ServerBindings" throws an exception. If I comment
>>out the two lines, the code works.

>>Is there any example code on how to add a Web Site in IIS. (C#)? The VB
>>version of the code, didn't help me.

>>Lars Andre




Sun, 05 Dec 2004 21:41:22 GMT  
 IIS and ADSI (Trying to add a new Web Site)
Lars, check out this KB article.  It's not exactly what you are seeing but
the underlying error looks to be the same.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q241981

--
Greg
http://www.claritycon.com/


Quote:

> > Lars, two questions for you:
> > 1. are nBindings[0] and nBindings[1] what you would expect them to be?

> nBindings[0] = "10.10.1.59:80:sol.no"
> nBindings[1] = "10.10.1.59:80:www.sol.no"

> And that is correct...

> > 2. It's probably just a type in your post but Default is spelled wrong,
that
> > would throw an exception by itself.

> oops, thats my fault. Type too much too fast.

> > 3. What is the exception that is thrown on each line?

> cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings }) :
> Error: Exception has been thrown by the target of an invocation.
> Error: Exception from HRESULT: 0x8000500C.

> I get the same error if try to pass one string (no array).

> Documentaion:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisr...

- Show quoted text -

Quote:

> > --
> > Greg
> > http://www.claritycon.com/



> >>Hi!

> >>Why does this code throw an exception:

> >>*clip*

> >>cWeb = (DirectoryEntry)iis.Invoke("Create",
> >>           new Object [] {  "IIsWebServer", "3" });

> >>string [] nBindings = new string[2];
> >>nBindings[0] = ip + ":80:" + domain;
> >>nBindings[1] = ip + ":80:www." + domain;

> >>cWeb.Invoke("Put",
> >>new Object [] {"DeafultDoc", "default.htm, default.html, default.asp,
> >>default.aspx, default.php, default.cgi, index.htm, index.html,
> >>index.asp, index.aspx, index.php, index.cgi, welcome.htm, welcome.html,
> >>welcome.asp, welcome.aspx, welcome.php, welcome.cgi"});
> >>cWeb.Invoke("Put", new Object [] {"ServerComment", description});
> >>cWeb.Invoke("Put", new Object [] {"ConnectionTimeout", 600 });
> >>cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings });

> >>cWeb.Invoke("SetInfo", null);
> >>iis.CommitChanges();

> >>*clip*

> >>Both "DeafultDoc" and "ServerBindings" throws an exception. If I comment
> >>out the two lines, the code works.

> >>Is there any example code on how to add a Web Site in IIS. (C#)? The VB
> >>version of the code, didn't help me.

> >>Lars Andre




Sun, 05 Dec 2004 22:39:43 GMT  
 IIS and ADSI (Trying to add a new Web Site)
I read the KB article, and since im not have used ADSI very much I
didn't excactly understand how this should solve my problem, but I can
always try it.

But I still need help with the following line:
Set oSchema = GetObject("LDAP://ServerName:<port #>/Schema") 'get schema
object

What should the port number be?

I appreciate your help. :-)

Lars Andre

Quote:

> Lars, check out this KB article.  It's not exactly what you are seeing but
> the underlying error looks to be the same.

> http://support.microsoft.com/default.aspx?scid=kb;EN-US;q241981

> --
> Greg
> http://www.claritycon.com/




>>>Lars, two questions for you:
>>>1. are nBindings[0] and nBindings[1] what you would expect them to be?

>>nBindings[0] = "10.10.1.59:80:sol.no"
>>nBindings[1] = "10.10.1.59:80:www.sol.no"

>>And that is correct...

>>>2. It's probably just a type in your post but Default is spelled wrong,

> that

>>>would throw an exception by itself.

>>oops, thats my fault. Type too much too fast.

>>>3. What is the exception that is thrown on each line?

>>cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings }) :
>>Error: Exception has been thrown by the target of an invocation.
>>Error: Exception from HRESULT: 0x8000500C.

>>I get the same error if try to pass one string (no array).

>>Documentaion:

> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisr...
> /psdk/asp/apro7tmb.asp

>>>--
>>>Greg
>>>http://www.claritycon.com/



>>>>Hi!

>>>>Why does this code throw an exception:

>>>>*clip*

>>>>cWeb = (DirectoryEntry)iis.Invoke("Create",
>>>>          new Object [] {  "IIsWebServer", "3" });

>>>>string [] nBindings = new string[2];
>>>>nBindings[0] = ip + ":80:" + domain;
>>>>nBindings[1] = ip + ":80:www." + domain;

>>>>cWeb.Invoke("Put",
>>>>new Object [] {"DeafultDoc", "default.htm, default.html, default.asp,
>>>>default.aspx, default.php, default.cgi, index.htm, index.html,
>>>>index.asp, index.aspx, index.php, index.cgi, welcome.htm, welcome.html,
>>>>welcome.asp, welcome.aspx, welcome.php, welcome.cgi"});
>>>>cWeb.Invoke("Put", new Object [] {"ServerComment", description});
>>>>cWeb.Invoke("Put", new Object [] {"ConnectionTimeout", 600 });
>>>>cWeb.Invoke("Put", new Object [] {"ServerBindings", nBindings });

>>>>cWeb.Invoke("SetInfo", null);
>>>>iis.CommitChanges();

>>>>*clip*

>>>>Both "DeafultDoc" and "ServerBindings" throws an exception. If I comment
>>>>out the two lines, the code works.

>>>>Is there any example code on how to add a Web Site in IIS. (C#)? The VB
>>>>version of the code, didn't help me.

>>>>Lars Andre




Mon, 06 Dec 2004 19:48:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Controling a web site (IIS)?

2. READ THE WEB-SITE THAT THE KIKES TRY TO CENSOR

3. Advertisement - New Web Site

4. New *HOT* Web site for c/c++, 3d graphics, artificial intelligence and more

5. Great New Bargain Web Site

6. +1 Software Engineering's New Web Site

7. New Web Site-WIN CASH

8. new programming web site.

9. New C Web Site

10. New web site especially for C/C++ developers

11. new web site for developpers

 

 
Powered by phpBB® Forum Software