Access denied! Get info from terminal server using wmi.

Using WMI I can access other servers and pc's execpt our Windows 2003 terminal server. Basic code is as follows. Any help is appreciated. C# code is welcome.

 
Public Sub getInfo(byval Server as string)
        Dim options As New ConnectionOptions
        options.Impersonation = ImpersonationLevel.Impersonate
        options.Username = "Administrator"
        options.Password = "AdminPassword"
        options.EnablePrivileges = True
        options.Authentication = AuthenticationLevel.Packet
        options.Authentication = AuthenticationLevel.Connect
 
        Dim path As New ManagementPath("\\" & Server & "\root\CIMV2:Win32_Process")
        Dim ms As New ManagementScope(path, options)
        Dim op As New System.Management.ObjectGetOptions
 
        Dim wmi As New ManagementClass(ms, path, New ObjectGetOptions())
        Dim objs As ManagementObjectCollection
        Dim obj As ManagementObject
 
        objs = wmi.GetInstances()
 
        For Each obj In objs
'Retrieves process names on remote server
            Console.WriteLine(obj("Name"))
        Next
 
    End Sub

Open in new window

sqlguy29Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

p_davisCommented:
do you get an error? where is the problem?
0
sqlguy29Author Commented:

Public Sub getInfo(byval Server as string)
        Dim options As New ConnectionOptions
        options.Impersonation = ImpersonationLevel.Impersonate
        options.Username = "Administrator"
        options.Password = "AdminPassword"
        options.EnablePrivileges = True
        options.Authentication = AuthenticationLevel.Packet
        options.Authentication = AuthenticationLevel.Connect
 
        Dim path As New ManagementPath("\\" & Server & "\root\CIMV2:Win32_Process")
        Dim ms As New ManagementScope(path, options)
        Dim op As New System.Management.ObjectGetOptions
 
        Dim wmi As New ManagementClass(ms, path, New ObjectGetOptions())
        Dim objs As ManagementObjectCollection
        Dim obj As ManagementObject
 
        objs = wmi.GetInstances()   <----------ERROR OCCURS ------Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
 
        For Each obj In objs
'Retrieves process names on remote server
            Console.WriteLine(obj("Name"))
        Next
 
    End Sub

Open in new window

0
p_davisCommented:
are you able to modify permissions on that server?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

sqlguy29Author Commented:
Yes, I have full admin permissions. I have modified and added permissions to the wmi control.
0
p_davisCommented:
sorry, about that last post
0
p_davisCommented:
in the dcomcnfg did you enable distributed COM on this computer and reboot?
0
sqlguy29Author Commented:
No, Where do I go to do that
0
ShazbotOKCommented:
1st can you remotly control that server with the Computer Management MSC from your PC?  If no then the 2003 firewall / restrictions are to tight.  (2003 by default is locked down tight)...

You should be able to utilize WMI within the MSC remotely if it is not being blocked.
0
p_davisCommented:
run dcomcnfg from the run line

click on the my computer icon in the toolbar--> i believe it is under default properties
0
sqlguy29Author Commented:
OK. tried to connect. Error Win32: Access is denied. Would you please walk me through loosening the restrictions?
0
sqlguy29Author Commented:
running dcomcnfg and configuring the default properties does not work. I set it just like the other servers.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.