Solved

c# WMI authentication problem

Posted on 2008-06-16
7
946 Views
Last Modified: 2013-12-17
Hi,
I am attempting a software and hardware inventory over our network, Novell sitting on top of AD (that's about all I know about the network setup). I am using a Windows application with C# and WMI services (.NET 2.0). I can list the services of the local machine with no problems, but I get the following error when trying to authenticate on a remote coomputer with the user as the local Administrator and the matching password. I have tried placing the name of the computer before the username (machinename\Administrator), but get the same error.

Could not connect to server! Cannot open SCardSvr service on computer 'computername'
0
Comment
Question by:brentself
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Are you using a ManagementScope instance, with connect options for the user name and password?
0
 

Author Comment

by:brentself
Comment Utility
Yep, here's the code

I think I have discovered that the user used for authentication must have domain admin privileges, where I was using a user that is the Administrator on the local box I was attempting to profile. I don't have these privileges and am looking for a way to just read the data without getting a new user with domain admin rights created for me (corporate red tape). I don't need to install software or get services, just want to inventory the software and hardware, serials, licenses, etc.

Thanks
address = "\\\\" + address + "\\root\\cimv2";
 

                ManagementScope oMs;

                if (tbUser.Text != "" && tbPass.Text != "")

                {

                    ConnectionOptions oConn = new ConnectionOptions();
 

                    oConn.Username = tbUser.Text;

                    oConn.Password = tbPass.Text;
 

                    oMs = new ManagementScope(address, oConn);

                }

                else

                {

                    oMs = new ManagementScope(address);

                }
 

                ObjectQuery oQuery = new ObjectQuery("select * from Win32_Product");
 

                ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
 

                //Get the results

                ManagementObjectCollection oReturnCollection = oSearcher.Get();

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Can you run other queries, or do they all fail with the same error?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:brentself
Comment Utility
I can run other (any) queries on my local machine, just not on other machines on the network. I tried to query services (actually not through WMI), disk usage, processor and installed software. All get the same error.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
Comment Utility
That is not an error that you can get around without having user credentials that are allowed access to the remote machine.
0
 

Author Comment

by:brentself
Comment Utility
Thanks for confirming
0
 

Author Closing Comment

by:brentself
Comment Utility
took to long, i found the answer myself while waiting
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now