none
Retrive IIS Information from Remote Server and Display Data using ASP.NET or Desktop Application in Dotnet-1.1 RRS feed

  • Question

  • Hi,

     

    I want to retrieve the details of the sites running in the server

    and display their status, for that i used wmi and adsi concept,

    I used the code mentioned below to retrieve the details,

    I'm getting invalid namespace error in the line

    " Dim searcher As New ManagementObjectSearcher("root\MicrosoftIISv2", "SELECT * FROM IIsWebService")"

    For Each queryObj As ManagementObject In searcher.Get()

     

    I think root\MicrosoftIISv2 this path may be the cause for this problem, Any one please help

    how to give that path to retrieve datas from the "IIS local host" and "remote server".

    (OR)

    If any one have a code to retrieve the iis information from the remote server by connecting it with user id and password

    and display the details using ASP.Net or Desktop application using Visual Studio 1.1 (C# or VB.Net)

     

    Configuarations Using:

    IIS Version 5.1

    VS-1.1

      

    Code Used:

     

    Imports System

    Imports System.Management

    Imports System.Data

     

        Private Function getPropertyStruct() As DataTable

            Dim dt As New DataTable

            dt.Columns.Add(New DataColumn("Name"))

            dt.Columns.Add(New DataColumn("Value"))

            Return dt

        End Function

     

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            '   Try

            Dim dt As DataTable = getPropertyStruct()

            Dim dr As DataRow

            Dim searcher As New ManagementObjectSearcher("root\MicrosoftIISv2", "SELECT * FROM IIsWebService")

            For Each queryObj As ManagementObject In searcher.Get()

     

                dr = dt.NewRow

                dr("Name") = "Name"

                dr("value") = queryObj("Name")

                dt.Rows.Add(dr)

     

                dr = dt.NewRow

                dr("Name") = "DisplayName"

                dr("value") = queryObj("DisplayName")

                dt.Rows.Add(dr)

     

                dr = dt.NewRow

                dr("Name") = "PathName"

                dr("value") = queryObj("PathName")

                dt.Rows.Add(dr)

     

                dr = dt.NewRow

                dr("Name") = "Started"

                dr("value") = queryObj("Started")

                dt.Rows.Add(dr)

     

     

                dr = dt.NewRow

                dr("Name") = "State"

                dr("value") = queryObj("State")

                dt.Rows.Add(dr)

     

                dr = dt.NewRow

                dr("Name") = "Status"

                dr("value") = queryObj("Status")

                dt.Rows.Add(dr)

     

                dr = dt.NewRow

                dr("Name") = "SystemName"

                dr("value") = queryObj("SystemName")

                dt.Rows.Add(dr)

     

            Next

            Me.DataGrid1.DataSource = dt

            Me.DataGrid1.DataBind()

            ' Catch err As ManagementException

            '      Response.Write(err.Message)

            '  End Try

        End Sub

    End Class

     

     

    Thanks in Advance

    Jay

    Friday, October 12, 2007 2:00 PM

All replies