[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Access denied! Get info from terminal server using wmi.

Posted on 2008-01-25
12
Medium Priority
?
1,381 Views
Last Modified: 2013-12-17
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

0
Comment
Question by:sqlguy29
  • 6
  • 5
12 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 20743150
do you get an error? where is the problem?
0
 

Author Comment

by:sqlguy29
ID: 20743193

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
 
LVL 22

Expert Comment

by:p_davis
ID: 20743340
are you able to modify permissions on that server?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:sqlguy29
ID: 20743536
Yes, I have full admin permissions. I have modified and added permissions to the wmi control.
0
 
LVL 22

Expert Comment

by:p_davis
ID: 20743549
0
 
LVL 22

Expert Comment

by:p_davis
ID: 20743573
sorry, about that last post
0
 
LVL 22

Expert Comment

by:p_davis
ID: 20743593
in the dcomcnfg did you enable distributed COM on this computer and reboot?
0
 

Author Comment

by:sqlguy29
ID: 20743667
No, Where do I go to do that
0
 
LVL 12

Expert Comment

by:ShazbotOK
ID: 20743732
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
 
LVL 22

Expert Comment

by:p_davis
ID: 20743757
run dcomcnfg from the run line

click on the my computer icon in the toolbar--> i believe it is under default properties
0
 

Author Comment

by:sqlguy29
ID: 20743808
OK. tried to connect. Error Win32: Access is denied. Would you please walk me through loosening the restrictions?
0
 

Accepted Solution

by:
sqlguy29 earned 0 total points
ID: 20744226
running dcomcnfg and configuring the default properties does not work. I set it just like the other servers.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The PowerShell Core 6.0 of .NET release is just the beginning. The upcoming PowerShell Core 6.1 would have artificial intelligence and internet of things capabilities. So many things to look forward to in the upcoming release.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question