I am trying to write some code to read the application pools from a remote machine and then eventually I will want to recycle one of the pools. I am trying to use the following code to retrieve the application pools, however I am getting an Access Denied error on the For Each line. There is no inner exception, so that is all I have to work with.
The account I am trying with right now is the box administrator account.Code:Dim connection As New ConnectionOptions connection.Username = "administrator" connection.Password = "password" Dim scope As New ManagementScope( _ "\\SOMEMACHINE\root\MicrosoftIISv2", connection) scope.Connect() Dim query As New ObjectQuery( _ "SELECT * FROM IIsApplicationPool") Dim searcher As New ManagementObjectSearcher(scope, query) For Each queryObj As ManagementObject In searcher.Get() MessageBox.Show(String.Format("Name: {0}", queryObj("Name"))) Next
The machine is not part of a domain and it is windows 2003 server with the firewall off.
I know the username and password are correct, because if they are not I get an error on the Scope.Connect() line.
I have tried the suggestion at the bottom of this page, but it did not help:
http://www.eggheadcafe.com/articles/20010614a.asp
I even rebooted after that change, just to be sure, but still no luck.
Any one have any other ideas? I know it is probably some silly security setting, I just don't know where else to look.




Reply With Quote