Re: WMI Access Denied WIN32_UserAccount Class
From: Mike (bibbymv_at_hotmail.com)
Date: 04/08/04
- Next message: Kevin C: "Re: Accessing basic system information using WMI"
- Previous message: Alex: "Re: ExecQuery fails with 0x80041008 (WBEM_E_INVALID_PARAMETER) on W2K"
- In reply to: Jiachuan Wang [MSFT]: "Re: WMI Access Denied WIN32_UserAccount Class"
- Next in thread: Philip Nunn [MSFT]: "Re: WMI Access Denied WIN32_UserAccount Class"
- Reply: Philip Nunn [MSFT]: "Re: WMI Access Denied WIN32_UserAccount Class"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Apr 2004 05:46:41 -0700
I added in the additional ConnectionOptions, but it still
did not work. I don't think it is related to the code,
but rather the WMI security setup on the other machine - I
cannot even use the MMC WMI snap in to connect to the
remote machine's WMI service.
>-----Original Message-----
>for ConnectionOptions object to remote machine, also set
the following
>properties to see whether it works
>
>opt.Impersonation = ImpersonationLevel.Impersonate;
>opt.EnablePrivileges = true;
>
>
>--
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>
>
>"Mike" <bibbymv@hotmail.com> wrote in message
>news:16dde01c41ce9$15840db0$a601280a@phx.gbl...
>> I am attempting to access a remote machine on another
>> domain to pull all users/SIDs for that domain. The
user I
>> am using to authenticate is a valid domain user for that
>> domain and has admin priveleges on the remote machine.
>> The code works on remote machines when the remote
machine
>> is on the same domain as the machine running the
>> executable. The error I receieve is "Access is denied"
>> from the mscorlib.dll. The stack trace looks like this:
>>
>>
>> at
>>
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR
>> (Int32 errorCode, IntPtr errorInfo)
>> at System.Management.ManagementScope.InitializeGuts
>> (Object o)
>> at System.Management.ManagementScope.Initialize()
>> at
System.Management.ManagementObjectSearcher.Initialize
>> ()
>> at System.Management.ManagementObjectSearcher.Get()
>> at TrackItUserUpdate.UserUpdate.ShowUsers(String
>> domain, String machine, String username, String
password)
>>
>> The code I am using is (C#):
>>
>> static void ShowUsers(string domain, string machine,
>> string username, string password)
>> {
>> ConnectionOptions opt = new ConnectionOptions();
>> opt.Username = username;
>> opt.Password = password;
>> try
>> {
>> ManagementPath p = new ManagementPath
>> ("\\\\"+machine+"\\root\\cimv2");
>> ManagementScope msc = new ManagementScope(p, opt);
>> string queryString = "SELECT * FROM
Win32_UserAccount
>> WHERE Domain=\"" + domain + "\"";
>> SelectQuery q = new SelectQuery(queryString);
>> query = new ManagementObjectSearcher(msc, q);
>> queryCollection = query.Get(); //Fails Here!
>> }
>> catch(ManagementException e)
>> {
>> Console.WriteLine(e.Message);
>> Console.WriteLine(e.ErrorInformation);
>> Console.WriteLine(e.ErrorCode);
>> Console.WriteLine(e.Source);
>> Console.WriteLine(e.StackTrace);
>> Console.WriteLine(e.TargetSite);
>> Console.WriteLine(e.HelpLink);
>> Environment.Exit(1);
>> }
>> catch(System.UnauthorizedAccessException e)
>> {
>> Console.WriteLine(e.Message);
>> Console.WriteLine(e.Source);
>> Console.WriteLine(e.StackTrace);
>> Console.WriteLine(e.TargetSite);
>> Console.WriteLine(e.HelpLink);
>> Environment.Exit(1);
>> }
>> }
>>
>> Both machines are running win2k. Additionally, I found
>> this error in the wbemprox.log:
>>
>> ConnectViaDCOM, CoCreateInstanceEx resulted in hr =
>> 0x80070005(Wed Apr 07 13:31:11 2004) :
>> Error loading module {F7CE2E13-8C90-11D1-9E7B-
>> 00C04FC324A8}, return code is 0x80070005
>>
>> Finally, one last piece of info, I attempted to use the
>> MMC WMI snap in and connect to the remote machine,
however
>> that failed with a similar error:
>>
>> Failed to connect to \\10.8.1.101
>> because "Win32: Access is denied."
>>
>> Any advice would be greatly appreciated.
>>
>> Regards,
>> Mike
>>
>
>
>.
>
- Next message: Kevin C: "Re: Accessing basic system information using WMI"
- Previous message: Alex: "Re: ExecQuery fails with 0x80041008 (WBEM_E_INVALID_PARAMETER) on W2K"
- In reply to: Jiachuan Wang [MSFT]: "Re: WMI Access Denied WIN32_UserAccount Class"
- Next in thread: Philip Nunn [MSFT]: "Re: WMI Access Denied WIN32_UserAccount Class"
- Reply: Philip Nunn [MSFT]: "Re: WMI Access Denied WIN32_UserAccount Class"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|