IIS Information Retrieval Via IIsWebVirtualDirSettng


We can dig still further, but with a different class, as shown in the following program.A yet another waay to dig into the IIS informaticas.



Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim dt As DataTable = getStruct()
Dim dr As DataRow
Dim searcher As New ManagementObjectSearcher("root\MicrosoftIISv2", "SELECT * FROM IIsWebVirtualDirSetting")
For Each queryObj As ManagementObject In searcher.Get()
dr = dt.NewRow
dr("AppPoolId") = queryObj("AppPoolId")
dr("Name") = queryObj("Name")
dr("Path") = queryObj("Path")
dr("EnableDirBrowsing") = queryObj("EnableDirBrowsing")
dt.Rows.Add(dr)
Next
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
Catch err As ManagementException
Response.Write(err.Message)
End Try
End Sub


To get further in-depth information about the virtual directories, we need to work with the class “IIsWebVirtualDirSettng.” It also has a lot of properties. I selected only the most important ones. I am using another routine to form a structure, to store that property information. The routine is as follows.

Private Function getStruct() As DataTable
Dim dt As New DataTable
dt.Columns.Add(New DataColumn("Name"))
dt.Columns.Add(New DataColumn("Path"))
dt.Columns.Add(New DataColumn("AppPoolId"))
dt.Columns.Add(New DataColumn("EnableDirBrowsing"))
Return dt
End Function

All the columns are indirectly nothing but the properties and the rest is the same as I explained in the first section.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.