Reputation: 59
In VB.Net, I'm trying to connect to WMI on my local computer with different credentials (the user won't have admin rights) and I get this exception :
« User credentials cannot be used for local connections »
Here's the code :
Dim path As ManagementPath = Nothing
Dim options As ConnectionOptions = Nothing
Dim scope As ManagementScope = Nothing
path = New ManagementPath("\\" & vServerName & "\root\CIMV2")
options = New ConnectionOptions
options.Username = vUsername
options.Password = vPassword
Scope = New ManagementScope(path, options)
Scope.Connect()
Upvotes: 2
Views: 20132
Reputation: 1
enter the wmic prompt by typing wmic and then enter. Then type:
/user:""
This will null the user it's trying to run the commands as. You might have to do something similar with password, I dunno.
Upvotes: 0
Reputation: 1726
I know this question is old, but I tried the above steps and it didn't work. What I found to work was this:
80041064 - User credentials cannot be used for local connections
Cause
This error is encountered when you specify the Username and password for monitoring the machine where OpManager is running.
Solution
Do not specify Username and password for the localhost. To resolve the issue, remove the configured user name and password from "Passwords" link in the device snapshot page.
Upvotes: 5
Reputation: 17125
You don't have access to some wmi instances when a user without administrator privileges is currently logged in. (This is only applied to Local WMI connections)
It's pretty lame! But if you can run your application as a user which is a member of administrators group, then you're problem should be solved.
Added note:
If you write a windows service with **local system** user, then you'll have full access to all wmi classes.
note: I've tried to grant my limited user the proper permissions to access desired wmi actions, but it seems it doesn't work that way. In this case, you'll have to set the permissions in these 3 places:
Start->Run->dcmoncnfg->Component Services->Computers->My Computer->Properties->COM security tab
Start->Run->dcmoncnfg->Component Services->Computers->My Computer->DCOM Config->Windows Management and Instrumention->Properties->Security tab
Start->Run->wmimgmt.msc->WMI Control(Local)->Properties->Root(just highlight)->Security tab
Upvotes: 4