?
Solved

c# WMI authentication problem

Posted on 2008-06-16
7
Medium Priority
?
967 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
[X]
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
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

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

Author Comment

by:brentself
ID: 21805706
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
ID: 21811996
Can you run other queries, or do they all fail with the same error?
0
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 

Author Comment

by:brentself
ID: 21814886
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 1500 total points
ID: 21815494
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
ID: 21818469
Thanks for confirming
0
 

Author Closing Comment

by:brentself
ID: 31467685
took to long, i found the answer myself while waiting
0

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 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