Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access Denied Problem in WMI for Windows XP only

Posted on 2011-03-07
10
1,386 Views
Last Modified: 2012-05-11
Hi All

I have been writing an application to get the details of remote machine like OS Name, Logon User Name etc using WMI Classes.

In our network we have machines with Windows XP, Windows Vista Windows 7.

I am able to get the informations for all windows 7 and windows vista machines.

But the problem here is i am not able to get the informations for windows XP machines.
Every time i am getting the following exception
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I have gone through the net but no help. I have done all the steps mentioned in the following link
http://support.microsoft.com/kb/875605.
But no luck still i am not able to solve the problem.
I have domain username with administrator privilages.
Below is the code that i have used. (C#)
private void GetRemoteComputerInfo(string compName)
        {
            ObjectGetOptions oc = new ObjectGetOptions();
            try {
                ConnectionOptions connOptions = new ConnectionOptions();
                connOptions.Username = "domain\\domainUserName";
                connOptions.Password = "domainUserPass";
                connOptions.Authority = "kerberos:domain\\" + compName;
                connOptions.Impersonation = ImpersonationLevel.Impersonate;
                connOptions.EnablePrivileges = true;
                ManagementScope msc;
                if (compName == Environment.MachineName)
                    msc = new ManagementScope("\\\\" + compName + "\\root\\cimv2");
                else
                    msc = new ManagementScope("\\\\" + compName + "\\root\\cimv2", connOptions);
                msc.Connect();
                ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
                mc.Scope = msc;
                //collection to store all management objects
                ManagementObjectCollection moc = mc.GetInstances();
                if (moc.Count != 0) {
                    foreach (ManagementObject mo in mc.GetInstances()) {
                        Console.WriteLine(string.Format("\nMachine Make: {0}\nMachine Model: {1}  System Type: {2}  Host Name: {3}  Logon User Name: {4}{5}",
                                          mo["Manufacturer"].ToString(),
                                          mo["Model"].ToString(),
                                          mo["SystemType"].ToString(),
                                          mo["DNSHostName"].ToString(),
                                          mo["UserName"].ToString(),
                                          Environment.NewLine));
                    }
                }
            }
            catch (Exception e) {
                Console.WriteLine("{0}: {1}", e.GetType().Name, e.Message);
            }
        }

Open in new window


Please help me to solve the problem.
0
Comment
Question by:sathish_raos
10 Comments
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 35066160
Hi, you have to give rights to all the the user for using sql server.
0
 

Author Comment

by:sathish_raos
ID: 35066169
@samirbhogayta:  I am not using sql server.
I want to get the details of a remote computer using WMI.
I have admin provilages.
0
 
LVL 7

Expert Comment

by:Gene_Cyp
ID: 35067002
Hi Sathish: since you have admin rights already on that PC, have a look at this page:

http://social.msdn.microsoft.com/Forums/eu/vsreportcontrols/thread/26accc30-9cfb-4d86-9c27-780f51929ecb



Also:




 1) go to dev box (web server) and run: "sc sdshow msdtc"output could be similar to this:
 
D:(A;;CCLCSWRPLOCRRC;;;S-1-2-0)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)(A;;CCLCSWRPRC;;;WD)(A;;CCLCSWRPLORC;;;NS)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)  2) go to prod box (web server) and run the same  "sc sdshow msdtc"outout could be similar to this:
 
D:(A;;CCLCSWRPLOCRRC;;;S-1-2-0)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CR;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)(A;;CCLCSWRPLORC;;;NS)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD) As you can see - highlighted strings are different - that's where my issue was.  
3) I changed it but running the following:

sc sdset msdtc D:(A;;CCLCSWRPLOCRRC;;;S-1-2-0)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPRC;;;WD)(A;;CCLCSWRPWPDTLOCRRC;;;PU)(A;;CCLCSWRPLORC;;;NS)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)  
 

** Note - I only changed that one string, the rest stayed the same as they were on prod environment. This could be caused either by the invalid install or permissions set during the install or because of some sort of the "hot fix" or the update. If your transactions suddenly stop working you should look into these settings and see if they are identical. Also don't forget to back up your server before making any changes or put it into undoable mode!!!   Here are the posts I used: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2915944&SiteID=1  and http://msdn2.microsoft.com/en-us/library/aa374928.aspx   Good Luck!

Source: http://forums.asp.net/t/1225290.aspx/1?Access+is+denied+Exception+from+HRESULT+0x80070005+E_ACCESSDENIED+
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Accepted Solution

by:
Gene_Cyp earned 500 total points
ID: 35067006
* Run dcomcnfg to bring up Component Services window.
* Expand Component Services > Computers > My Computer > DCOM
Config
* Scroll down list, right click Windows Management and
Instrumentation, and select properties.  A 5 tabbed window  named
Windows Management and Instrumentation Properties should be displayed.
* Select the Security tab, then select radio buttons which
activate the Edit... buttons.
* Select the appropriate location and add the ASPNET account.
* Reboot.
0
 
LVL 1

Expert Comment

by:lalitgada
ID: 35067260
disable the windows firewall some times it block .

disable the firewall in server and client.
0
 

Author Comment

by:sathish_raos
ID: 35067935
both client and server firewalls are disabled still not getting.
0
 
LVL 7

Expert Comment

by:Gene_Cyp
ID: 35067961
Sathish: did u go through the recommendations of actions I've listed?
0
 

Author Comment

by:sathish_raos
ID: 35068134
@Gene_Cyp: I have done all the steps you have told.
But still i am not able to get the solution.
0
 

Author Comment

by:sathish_raos
ID: 35069383
I have checked the WMI logs (wbemprox.log) on the Windows XP machine i found following erros listed in that.

(Tue Mar 08 17:15:46 2011.13254671) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x800706ba
(Tue Mar 08 17:16:34 2011.13303437) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x800706ba
(Tue Mar 08 17:16:35 2011.13304562) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x800706ba
(Tue Mar 08 17:16:51 2011.13320125) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x800706ba
(Tue Mar 08 17:16:52 2011.13321156) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x800706ba
(Tue Mar 08 17:22:10 2011.13639062) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x80070005
(Tue Mar 08 17:22:17 2011.13646437) : ConnectViaDCOM, CoCreateInstanceEx resulted in hr = 0x80070005

I am still not able to solve the problem.
0
 

Author Comment

by:sathish_raos
ID: 35078931
Hi
I found one solution by adding NETWORK SERVICE to local administrator group in xp machines and restarting the machine.

Since i have many computers running XP os in LAN i cannot do it for all the systems. Is there an alternative way to do this?
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

789 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