WMI & RPC Protocol Sequence Not Supported

  • Thread starter Thread starter PaulB____
  • Start date Start date
P

PaulB____

Guest
Im struggling with a WMI problem relating to service management on remote systems. Both systems are on the same domain. The local system is Win 7 x64 and the remote is Win 7 x86. None of the machines has an active firewall.

I actually wrote the code at home on a system not on the domain and using it over a VPN it worked just fine. But locally on the two domain machines I cant get it to connect.

If I change the username/password to something incorrect then it will fail with the appropriate unauthorized error. So I know it must be at least establishing a connection. It seems to then be failing after that.

So I grabbed the MS example code and ran that, with the same results. This is the code Im using and seeing a failure as it does a scope.connect()

Any pointers would be gratefully received as Im pulling my hair out. I cant find anything of use related to this at all.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;

namespace wmiTest {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}

private void log(string message) {
lstOutput.Items.Add(message);
lstOutput.SelectedIndex = lstOutput.Items.Count - 1;
}

private void button1_Click(object sender, EventArgs e) {
try {
ConnectionOptions connection = new ConnectionOptions();
connection.Username = "xxxxxx";
connection.Password = "xxxxxx";
connection.Authority = "ntlmdomain:xxxxxx";
connection.Impersonation = ImpersonationLevel.Impersonate;

ManagementScope scope = new ManagementScope(
"\\\\172.20.52.1\\root\\CIMV2", connection);
scope.Connect();

ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_Service");

ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get()) {
log(String.Format("Win32_Service instance"));
log(String.Format("Caption: {0}", queryObj["Caption"]));
log(String.Format("Description: {0}", queryObj["Description"]));
log(String.Format("Name: {0}", queryObj["Name"]));
log(String.Format("PathName: {0}", queryObj["PathName"]));
log(String.Format("State: {0}", queryObj["State"]));
log(String.Format("Status: {0}", queryObj["Status"]));
}

//Close();
} catch (ManagementException err) {
MessageBox.Show("An error occured while querying for WMI data: "
+ err.Message);
} catch (System.UnauthorizedAccessException unauthorizedErr) {
MessageBox.Show("Connection error " +
"(user name or password might be incorrect): " +
unauthorizedErr.Message);
} catch (System.Runtime.InteropServices.COMException cex) {
log(cex.Message);
}
}
}
}




System.Runtime.InteropServices.COMException was unhandled
Message=The RPC protocol sequence is not supported. (Exception from HRESULT: 0x800706A7)
Source=System.Management
ErrorCode=-2147023193
StackTrace:
at System.Management.ThreadDispatch.Start()
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementScope.Connect()
at wmiTest.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at wmiTest.Program.Main()
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Continue reading...
 

Similar threads

Back
Top