Thursday, November 02, 2006

HOWTO: Change the ID of an IIS Website

Question:

Hello,

When I install Sharepoint Services, it creates a web site with an identifier. (Ex. ID 4).

I need to change that ID for another one. So I use this command :

cscript adsutil.vbs move w3svc/4 w3svc/4243.

It does the trick...

But, when I look in IIS I see that the site is stopped and I have this error in the event logs:

Event Type:           Error 
Event Source: W3SVC
Event Category: None
Event ID: 1007
Date: 2006-10-25
Time: 13:19:46
User: N/A
Computer: U1U206V
Description:

Cannot register the URL prefix 'http://*:24051/' for site '42'. The
necessary network binding may already be in use. The site has been
deactivated. The data field contains the error number.

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Data:
0000: b7 00 07 80 ·..€

If I start the site manually, the site starts fine with no errors.

I just want to know if there's a way to not receive this error message when I change the ID of my site.

Can someone confirm that?

Or is there another way to do it to prevent errors?

Thx in advance for your help.

Answer:

The reason you get that error event when you MOVE a running website is due to how ADSUTIL.VBS MOVE works. You can treat the MOVE operation as a non-atomic COPY-then-DELETE... because it is designed to move arbitrary metabase nodes (for example, one vdir to another vdir in a different tree hierarchy).

Thus, when you use it to move from website ID 4 to website ID 42, what happens is this:

  1. The entire metabase node under website ID 4 is copied to website node with ID 42
  2. Since website ID 4 is running and website node with ID 42 is a website, website ID 42 also attempts to run
  3. However, since both website nodes are duplicates and have the exact same bindings, the new website ID 42 cannot start due to duplicate bindings and trigger the error event
  4. After website ID 42 finishes copying, node ID 4 is deleted
  5. But website ID 42 has already failed to start; there is no state change here

The key is to STOP the source website ID prior to executing the MOVE. In that case, there will be no duplicate bindings simultaneously running during the COPY-the-DELETE, and one will not see the error event.


CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs STOP_SERVER W3SVC/4
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs MOVE W3SVC/4 W3SVC/42
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs START_SERVER W3SVC/42

//David

9 comments:

Unknown said...

Can you use names for the ID's instead of the numbers? If so can you epxlain? I want to be able to find the directory to grep a log quicker instead of an id number for each web site (since I run several)

Thanks

Jim

David Wang said...

IIS uses an ID number to uniquely identify websites. Each website has a "Friendly name" associated with it, and this "Friendly name" is what the UI displays.

You can certain use the "Friendly name" to search and map back to an ID number, but internally all operations have to be made with the ID number.

I am not certain what you mean by "I want to be able to find the directory to grep a log quicker instead of an id number for each website".

The IIS log file uses the website ID, which is the easiest way to map back to a directory. You can use the ID to map back to a "Friendly name" if you want.

//David

Anonymous said...

This also helped me resolve an issue with Exchange 2007 and Outlook Anywhere. The cmdlet Enable-OutlookAnywhere was failing because I had no website at /W3SVC/1/ROOT.

I used the commands here to move my website and was able to enable outlook anywhere.

I did have to go into ADSIedit and update the MetaBasePath for my existing OWA sites to adjust for the moved website.

Anonymous said...

Cheers for the help.

Unknown said...

lv features Monogram canvas with natural cowhide trim. The classic louis vuitton and quatrefoil signature design always can attract appreciations from someone special hidden in the crowd. The shiny brass hardware and the modern, feminine shape make Louis vuitton bags exude a more luxurious look. Besides the pleasing appearance, louis vuitton handbags is multi-functional.

Sildenafil Citrate said...

I was wondering how to change the ID of an IIS website yesterday and honestly I had no freaking idea, thanks to you now I know better thanks for the information!

Unknown said...

However, ugg boots which owns a array of acclaimed designers, not abandoned delights women by contemporary styles, but aswell by absolute abundance and practicality.Sheepskin ugg is absolutely crafted from wool. Many times, uggs are befuddled abroad because they get adulterated or channelled afterwards getting beat for one season, instead of acceptable out of date. There are lots of styles in the accumulating of affidavit ugg sundance , accoutrement tall, abbreviate and abate versions. Due to adaptable sheepskin, these ugg sundance boots do not get channelled or torn even admitting you bend and extend them times.

cialis prescription said...

hey buddy,this is one of the best posts that I�ve ever seen; you may include some more ideas in the same theme. I�m still waiting for some interesting thoughts from your side in your next post.

Cafe24 Extension said...

I have multiple sites running in IIS7 with host headers. I would like be able to change the default website or site ID 1 to another site.
I deleted the site with Site ID = 1 and then modified the side ID for another website in the applicationHost.config to be Side ID = 1.