Results 1 to 3 of 3

Thread: Modification of IIS config by software

  1. #1
    Join Date
    Oct 2005
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Modification of IIS config by software

    Anyone know how to modify an IIS6 configuration from software? (vbscript/c#). I need to add and remove host headers on a site in code (nothing else!) I'm modifying my CMS engine to support subdomains as part of the site's content heirarchy.

  2. #2
    Join Date
    Feb 2004
    Posts
    4,903
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Quote Originally Posted by cswd
    Anyone know how to modify an IIS6 configuration from software? (vbscript/c#). I need to add and remove host headers on a site in code (nothing else!) I'm modifying my CMS engine to support subdomains as part of the site's content heirarchy.
    To add host headers:

    Code:
    Dim oIIS, NewBindings, NewBinding, Bindings
    Set oIIS = GetObject("IIS://LOCALHOST/W3SVC/1/ROOT")
    
    ' Construct the new Server Bindings
    NewBindings = Array("")
    NewBinding = "IPADDRESS:PORT:HEADERNAME"
    
    ' Create an array of the current Server Bindings
    Bindings = oIIS.ServerBindings
    
    ' Populate NewBindings and remove the new Server Binding if it already exists
    For i = LBound(Bindings) To UBound(Bindings)
        If Bindings(i) <> NewBinding Then
            NewBindings(UBound(NewBindings)) = Bindings(i)
            ReDim Preserve NewBindings(UBound(NewBindings) + 1)
        End If
    Next i
    
    ' Add the new Server Binding to NewBindings
    NewBindings(UBound(NewBindings)) = NewBinding
    
    ' Update IIS
    oIIS.ServerBindings = Bindings
    oIIS.SetInfo
    
    Set oIIS = Nothing
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    Oct 2005
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Fantastic! Thank you very very very much

    I'll try it later after I've got my dose of McGrease.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trust level modification proposal
    By cswd in forum ASP.NET
    Replies: 2
    Last Post: 18th March 2006, 09:07 AM
  2. Add Domain 2 IIS
    By askjim in forum General Technical Support
    Replies: 7
    Last Post: 11th March 2006, 03:56 PM
  3. mod_rewrite but for IIS?
    By Reactivate in forum Sales and Service Feature Enquiries
    Replies: 10
    Last Post: 30th January 2006, 09:54 AM
  4. Global.asa and restarting IIS
    By terraqueotenaz in forum ASP (VBScript)
    Replies: 1
    Last Post: 8th August 2005, 05:58 AM
  5. php 5 + mysql 4.1 + IIS
    By terraqueotenaz in forum General Technical Support
    Replies: 3
    Last Post: 1st August 2005, 04:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •