10 Replies Latest reply on Jan 17, 2014 9:16 AM by WiWildcat

    How to consume Microsoft.Web.Administration?

    RLS Level 1

      I have been managing websites in IIS6, but I understand that things have changed radically in IIS7 and that "all I need to do" is consume the services available in Microsoft.Web.Administration's servermanager and Microsoft.Web.Management and I'll have all the services and methods I need to replicate what I was doing in IIS6.


      Well and good if you're savvy on that whole "consume services" thing, which I suck at.


      I am told I can find this in c:\windows\system32\inetsrv\Microsoft.Web.Administration.dll and, indeed, it is there.


      Try as I might, I cannot figure out how to pull this into an object so I can consume it.  I've tried:


      <cfobject type="COM" action="CREATE" class="Microsoft.Web.Administration" name="objMicrosoftWeb">

      <cfobject action="create" class='Microsoft.Web' name="objMicrosoftWeb" type="com">


      set myServerManager = CreateObject('.NET', 'ServerManager', 'c:\windows\system32\inetsrv\Microsoft.Web.Administration.dll');




      component="c:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" />


      all to no avail.  I am obviously not a COM genius.


      Can anyone clue me in?  I think even if I could figure out how to get a list of classes and methods I might be able to reign this in, but, alas, I am clueless in this arena.



        • 1. Re: How to consume Microsoft.Web.Administration?
          Dan Bracuk Level 5

          You can get a list of classes by googling Microsoft.Web.Administration and selecting an offering from msdn.microsoft.com    

          • 2. Re: How to consume Microsoft.Web.Administration?
            RLS Level 1

            Thank you, but that does not list the service as it appears on my computer / server nor does it help me to figure out how to code the createobject capture that I need.  I've been staring at that damn msdn article / series and a million other articles about Microsoft.Web.Administration but none of them give me the answer and I've tried but I cannot figure it out myself. Thanks, but I need hand holding this time...

            • 3. Re: How to consume Microsoft.Web.Administration?
              Dan Bracuk Level 5

              You could always take another approach.  What did you used to be able to do with IIS 6 that you can't do with IIS 7?

              • 4. Re: How to consume Microsoft.Web.Administration?
                RLS Level 1

                In IIS6 I was using the metabase with a variety of exe and vbs files.


                In IIS7 I want to take advantage of the XML structure. I could probably use AppCMD but that seems so old school. I'd prefer to use the API and, in my mind, do it correctly and likely much more efficiently.


                I just don't know how to list the services that are outside of Cold Fusion. ColdFusion Builder doesn't show them to me and I can't find a copy of OLEVIEWER to download, so I'm having trouble peeking under the hood.


                I've tried so many variations on trying to make an object out of Microsoft.Web.Administration.dll that my fingers are numb and my eyes are bleeding. I don't know why I can't find any specific instance on the web of someone doing this with ColdFusion; it's weird, frankly.


                To me, it's a simple question that SOMEONE out there must have answered by now. Knowing the name of an object on your computer, how do you create a CFObject out of it so you can use the services?  But that's probably just me not knowing some reason why that won't work.


                This is what I want to get, first. Once I have that, I think I can figure the rest out: http://msdn.microsoft.com/en-us/library/ms614834(v=vs.90).aspx



                • 5. Re: How to consume Microsoft.Web.Administration?
                  RLS Level 1

                  I guess the trick is all in how you phrase your question when searching for the answer.


                  Out of desperation, I searched for the error message I was receiving, and this (http://forums.adobe.com/message/4227246) provided me the answer, right from here within the CF Forums, something I had already searched.


                  I was using:

                  <cfobject type="dotnet" name="Mtable" class="ApplicationDomain"



                  and getting an error stating that the class was not found in the assembly list (Class ApplicationDomain not found in the specified assembly list. The assembly that contains the class must be provided to the assembly attribute).


                  By simply giving it the COMPLETE class name, as such:


                  <cfobject type="dotnet" name="Mtable" class="Microsoft.Web.Administration.ApplicationDomain"



                  I attained success.


                  This question is resolved. Hope this helps someone else looking for this solution.



                  • 6. Re: How to consume Microsoft.Web.Administration?
                    BKBK Adobe Community Professional & MVP

                    A solution that will certainly help someone else in future - thanks for sharing it!

                    • 7. Re: How to consume Microsoft.Web.Administration?
                      RLS Level 1

                      Alas, the "correct" answer was not the end of this story, not the solution I needed ("how to add a web site dynamically using ColdFusion").


                      Microsoft, in their infinite wisdom, has provided pretty clear (?) examples on how to manage web sites dynamically using these tools in C#, VB, Javascript, and so on, but for some reason they just don't work well in ColdFusion. (if you are a crossover programmer and can tell us all how to do this, please chime in! I'd love to use the object services instead of below).


                      While I was able to consume the object, I could not get their methods to work for me in ColdFusion 8. I am not well trained on using C# and objects and all that (old school programmer; emphasis on the "old" - started programming in 1980 and CF since 1996) and I had to get this working, so I returned to what I knew, and that was command line executables.




                      http://www.iis.net/learn/get-started/getting-started-with-iis/getting-started-with-appcmde xe helped immensely.


                      For example, to simply add a web site, try this (and, yes, I know that the arguments can be an array, but cfexecute does not like "add site" as an argument, yes you can make it all in the string instead of the array, and yes, the double-quotes are significant); make sure you change the names and bindings to suit your situation, such as having internal IP addresses instead of external:





                                                    TestArguments = ArrayNew(1);

                                                    TestArguments[1] = '/name:"My Test Site"';

                                                    TestArguments[2] = '/physicalPath:"d:\websites\testSite\www"';

                                                    TestArguments[3] = '/bindings:"http/,http/"';

                                                    TestArguments[4] = '/state:Started';


                                          <CFEXECUTE name="C:\Windows\System32\inetsrv\appcmd.exe" variable="resultVariable" timeout="15"

                      arguments='add site #TestArguments[1]# #TestArguments[2]# #TestArguments[3]# #TestArguments[4]#'  />

                                          <cfdump var="#resultVariable#" label="resultVariable" >

                                          <CFCATCH TYPE="ANY">

                                              <cfdump var="#cfcatch#" label="#cfcatch#">





                      NOTE: CFEXECUTE does not like using %systemroot% in place of "C:\Windows" (or whereever it is for you).

                      NOTE: This does not do the DNS entries for you.


                      Have fun!


                      1 person found this helpful
                      • 9. Re: How to consume Microsoft.Web.Administration?
                        Creayt Level 1

                        This whole post was extremely helpful RLS, thanks!!

                        • 10. Re: How to consume Microsoft.Web.Administration?
                          WiWildcat Level 1

                          Thanks, Mr. McGuigan.


                          Looking at that code example - I'm betting cfdump will balk at label="#cfcatch#" !!  Better to not use a structure in a label!


                          Guess it never errored for me or I'd have found that out....