• 0

[C#] User credentials error for local connections


Question

Can anyone tell me why my program thinks I am trying to make a local connection when I set the machine name value to a remote host (i.e. not localhost)

private void cmdGo_Click(object sender, System.EventArgs e)	{

	treeControl.Nodes.Clear();
	String machineName = txtMachineName.Text;

	if (machineName.CompareTo("localhost") == 0) {
 ?// do nothing with connection options as this is a local connection
	} else {
 ?objectConnection.Username = txtUsername.Text;
 ?objectConnection.Password = txtPassword.Text;
	}

	objectManagementScope = new ManagementScope("\\\\" + machineName, objectConnection);

	try {
 ?objectManagementScope.Connect();
	} 
	catch (System.Exception ex) {
 ?MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
	}
etc...

When the code reaches the ".Connect();" part I get this error message:

"User credentials cannot be used for local connections"

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************

System.Management.ManagementException: User credentials cannot be used for local connections

at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)

at System.Management.ManagementScope.InitializeGuts()

at System.Management.ManagementScope.Initialize()

at System.Management.ManagementObjectSearcher.Initialize()

at System.Management.ManagementObjectSearcher.Get()

at WMI_Windows_App.frmMain.getDiskInfo() in c:\documents and settings\mark\my documents\visual studio projects\behind the minority report\main.cs:line 318

at WMI_Windows_App.frmMain.cmdGo_Click(Object sender, EventArgs e) in c:\documents and settings\mark\my documents\visual studio projects\behind the minority report\main.cs:line 269

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.PerformClick()

at System.Windows.Forms.Button.ProcessMnemonic(Char charCode)

at System.Windows.Forms.Control._ProcessMnemonic(Char charCode)

at System.Windows.Forms.ContainerControl.ProcessMnemonic(Char charCode)

at System.Windows.Forms.ContainerControl.ProcessDialogChar(Char charCode)

at System.Windows.Forms.Control.ProcessDialogChar(Char charCode)

at System.Windows.Forms.Control.ProcessDialogChar(Char charCode)

at System.Windows.Forms.Control.PreProcessMessage(Message& msg)

at System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Until EVs get solid state batteries that can last 800miles+ on a single charge in Canada's -50°C weather, all while functioning 100% offline, they're still just at a guineapig testing stage IMO, and simply not worth purchasing...
    • I would question if Neowin really needs science research studies/stories than.
    • Microsoft reveals Mu, an on-device small language model built into Windows 11 by Pradeep Viswanathan Last year, Microsoft revealed Copilot+ PCs featuring a dedicated Neural Processing Unit (NPU) capable of over 40 TOPS or more. These Copilot+ PCs came with Phi-Silica, an on-device SLM to bring language intelligence capabilities to Microsoft's own first-party apps and apps from other 3rd-party developers. Today, Microsoft revealed Mu, a new on-device small language model built into Windows 11. Microsoft's goal was to create an AI-powered agent within the Settings app that can understand a user's natural language queries and integrate it into the existing search box for a smooth user experience. Hence, Microsoft is using the new Mu model to power the new agent feature in the Settings app, which was made available to Windows Insiders recently in the Dev Channel with Copilot+ PCs. Like Phi-Silica, Mu is designed to operate efficiently on NPUs, delivering over 100 tokens per second while running locally. In the official blog post, Microsoft explained how they designed and trained the Mu language model. Here's an overview of the Mu language model: Mu is a 330M encoder-decoder language model. The encoder-decoder approach achieved about 47% lower first-token latency and 4.7× higher decoding speed compared to a decoder-only model of similar size. Mu uses weight sharing in certain components to reduce the total parameter count. Microsoft trained Mu using NVIDIA A100 GPUs on Azure Machine Learning. Mu is nearly comparable in performance to a similarly fine-tuned Phi-3.5-mini, despite being one-tenth of the size. The model is better suited for multi-word queries. So for short or partial-word inputs, the Settings app will continue to surface lexical and semantic search results in the search box. Interested users can download Windows 11 Build 26120.3964 (KB5058496) or higher to check out this new AI-powered agent in the Windows Settings app.
    • I work at a company that sends Samsung stuff to Best Buy, Costco, Amazon, and others, we are about to killed after this event.
    • only using AI for science research studies/stories like this which are somewhat separate from our main tech/IT-focused articles, it is like a separate column, sort of like the software stories. Also I believe plenty of other sites use AI in some form of other, but we are also honest enough to disclose it. Btw no that headline was completely me.
  • Recent Achievements

    • Dedicated
      tesla maxwell earned a badge
      Dedicated
    • Dedicated
      Camlann earned a badge
      Dedicated
    • Week One Done
      fredss earned a badge
      Week One Done
    • Dedicated
      fabioc earned a badge
      Dedicated
    • Week One Done
      GoForma earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      633
    2. 2
      Michael Scrip
      224
    3. 3
      ATLien_0
      219
    4. 4
      +FloatingFatMan
      142
    5. 5
      Xenon
      135
  • Tell a friend

    Love Neowin? Tell a friend!