I have an IIS 7.5 web site running "classic" ASP code (not ASP.NET) where the site is running under the normal service context, and only "Windows Authentication" is enabled. Users and navigate the site without any problem, regardless of having implicit admin rights on the IIS host or not (most do not). However, when I try to execute a common Win32_PingStatus request within the ASP code, it fails unless the user has admin rights on the IIS host. Here's my code...
On Error Resume Next
asset = "Computer123"
pingtest = False
query = "Select StatusCode, Address FROM Win32_PingStatus " & _
"WHERE Address=" & Chr(34) & asset & Chr(34)
Set colPingStatus = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}//./root/cimv2").ExecQuery(query)
If err.Number <> 0 Then
Response.Write "Access Denied (error: " & err.Number & " / " & err.Description & ")"
Response.End
End If
For Each objItem In colPingStatus
If objItem.StatusCode = 0 Then
pingtest = True
End If
Next
If pingtest = False Then
Response.Write asset & " is OFFLINE"
Else
Response.Write asset & " is ONLINE"
End If
I've been trying to get my head around SWBEM and WMI impersonation capabilities, but I'm still confused as to whether it's even possible (supported or unsupported) to do this regardless of the user/browser session context. Every user is a Domain account, no anonymous users are able to access the site, so it seems (and I could be wrong) to be related to their group memberships and permissions on the IIS host.