Link to home
Start Free TrialLog in
Avatar of brentself
brentself

asked on

c# WMI authentication problem

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'
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Are you using a ManagementScope instance, with connect options for the user name and password?
Avatar of brentself
brentself

ASKER

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

Can you run other queries, or do they all fail with the same error?
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.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for confirming
took to long, i found the answer myself while waiting