Discussion:
WMI connect server error 'Access denied'
(too old to reply)
Ivan Abramov
2009-09-29 15:24:02 UTC
Permalink
Hello.

I have the VB6 code:

Dim objSWbemLocator As Object, objSWbemServices As Object,
colNetworkAdapters As Object
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(sComputer, , sUser,
sPassword)

While execution I get the 'Access denied' error in the last line.
Everything is working well only in local computer.
As soon as I try to connect to remote computer, the error appears.
Computer name, user name and his password is correct.
Computers are not in a domain but in LAN.
What is incoorect?
I need to read computers config info.

Many thanks in advance.
Richard Mueller [MVP]
2009-09-29 15:45:23 UTC
Permalink
Post by Ivan Abramov
Hello.
Dim objSWbemLocator As Object, objSWbemServices As Object,
colNetworkAdapters As Object
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(sComputer, , sUser,
sPassword)
While execution I get the 'Access denied' error in the last line.
Everything is working well only in local computer.
As soon as I try to connect to remote computer, the error appears.
Computer name, user name and his password is correct.
Computers are not in a domain but in LAN.
What is incoorect?
I need to read computers config info.
Many thanks in advance.
The user name should be in the form <ComputerName>\<UserName>, where
<ComputerName> is the NetBIOS name of the computer and <UserName> is the
name of the local user. The user should be a member of the local
Administrators group (on the target computer).

Also, shouldn't you specify the namespace, such as:

Set objWMIService = objSWbemLocator.ConnectServer(sComputer, "root\cimv2" ,
sUser, sPassword)
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Ivan Abramov
2009-09-30 11:39:01 UTC
Permalink
I changed the last line to:

Set objWMIService = objSWbemLocator.ConnectServer(sComputer, "root\cimv2",
sComputer & "\" & sUser, sPassword)

and tried with many remote computers. It's ok with Win2003Server only.
But with WinXP the result is the same: 'Access denied' error or 'The RPC
srver is unavailable' error (on two different comps).
I tried to turn on many services (concerned with WMI and not), but didn't
succeed.
What's wrong with WinXP?
I've been with this unsolved problem for half a year. Help, plz.
jford
2009-09-30 13:40:01 UTC
Permalink
What WMI property are you querying, and does the local account you are
specifying have the permissions to perform the query?
Post by Ivan Abramov
Set objWMIService = objSWbemLocator.ConnectServer(sComputer, "root\cimv2",
sComputer & "\" & sUser, sPassword)
and tried with many remote computers. It's ok with Win2003Server only.
But with WinXP the result is the same: 'Access denied' error or 'The RPC
srver is unavailable' error (on two different comps).
I tried to turn on many services (concerned with WMI and not), but didn't
succeed.
What's wrong with WinXP?
I've been with this unsolved problem for half a year. Help, plz.
Ivan Abramov
2009-09-30 14:39:03 UTC
Permalink
I'm using many of the WMI properties (conserning the computer's config) but
further.
Now I cannot accomplish the ConnectServer method (to use the WMI properties).
I tried both the adminstrator's account and remote user account (which is
also a member of the administrators group).
Ivan Abramov
2009-11-09 17:43:01 UTC
Permalink
What is wrong with WindowsXP indeed?

Loading...