Re: WMI Access Denied WIN32_UserAccount Class

From: Mike (bibbymv_at_hotmail.com)
Date: 04/08/04


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
>>
>
>
>.
>



Relevant Pages

  • Re: WMI Access Denied WIN32_UserAccount Class
    ... for ConnectionOptions object to remote machine, ... > I am attempting to access a remote machine on another> domain to pull all users/SIDs for that domain. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: WMI Access Denied WIN32_UserAccount Class
    ... other non-WMI remote operations to confirm. ... > I added in the additional ConnectionOptions, ... > but rather the WMI security setup on the other machine - I ... >>> domain, String machine, String username, String ...
    (microsoft.public.win32.programmer.wmi)
  • WMI Access Denied WIN32_UserAccount Class
    ... domain and has admin priveleges on the remote machine. ... domain, String machine, String username, String password) ... ConnectionOptions opt = new ConnectionOptions; ...
    (microsoft.public.win32.programmer.wmi)
  • Re: LSA vs LSP GUI on Vista/2008?
    ... I mentioned WMI because Joe had suggested it in this thread, I will instead post to WMI group about it. ... I was assuming you could remote a call to any class that's part of the base .NET Framework on the remote machine. ... the app that uses the COM object does not need the Admin privileges. ... you need the admin privileges only during the installation. ...
    (microsoft.public.platformsdk.security)
  • RE: Newbie: Edit only files with a certain extension in a given folder?
    ... you can use either FileSystemObject or WMI to enumerate all the files with a certain extension in a given folder. ... I would prefer the WMI method as it gives you great control on what you are searching for. ... 'Get the current string and the replacement string from the user... ...
    (microsoft.public.scripting.wsh)

Quantcast