Connect to a machine that is not in a domain

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dave Coate (coateds_at_comcast.net)
Date: 02/25/05


Date: Thu, 24 Feb 2005 22:01:31 -0800

I am trying to connect to a server that is not in a domain from a
workstation that is in a domain and I can not seem to get it to work. Here
is my (vb.net) code:

Dim ComputerName As String = txtInput.Text
Dim UserName As String = txtUserName.Text
Dim Password As String = txtPassword.Text
Dim co As New ConnectionOptions
Dim scope As ManagementScope
Dim strScope As String = "\\" & ComputerName & "\root\cimv2"

With co
    .Username = UserName
    .Password = Password
    .Impersonation = ImpersonationLevel.Impersonate
End With

scope = New ManagementScope(strScope)

'Test Connection
Try
    scope.Connect()
    txtOutput.Text = "Connected"
Catch ex As Exception
    'There was an error connecting to WMI
    txtOutput.Text = ex.Message
End Try

I am using the format machinename\username for UserName. I can use this code
to provide alternate credentials when connecting to a computer in within the
domain in which my workstation is a member, but I can not connect to a
computer that is not in that domain. The Exception message I get back is
Access is Denied. The account I am trying to connect with is the
administrator account. I am able to use this account to connect via the WMI
CIM Studio. So WMI seems to be fine and the credentials have the required
access.

Is there another ConnectionOption I should be using?
What am I doing wrong?



Relevant Pages

  • Re: Usernametoken cant beused inweb services that are invoked bywebcl
    ... you still use the built-in username token manager which can only handle windows accounts - you have to register your own in web.config ... Dim aa As String Dim bb As String ... SoapException("Missing security token", SoapException.ClientFaultCode) ... apEnvelope envelope) at ...
    (microsoft.public.dotnet.security)
  • Re: WSE 3.O Web Service with ASP.Net Client using VB.Net
    ... <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"</a>;> ... ''' Constructs an instance of this security token manager. ... Dim principal As GenericPrincipal = New ... There is a logon page which takes a Username and Password, ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Return Value?
    ... Public Class UserDetails ... Public FirstName As String ... Public Function Login(ByVal UserName As String, ... Dim sqlCmd As SqlCommand ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Modifying AD User attribute
    ... Would you haapened to have a script to do the following: ... username in AD with username in the spreadsheet, ... Dim objRootDSE, strDNSDomain, strNetBIOSDomain ... ' Determine DNS domain name from RootDSE object. ...
    (microsoft.public.windows.server.scripting)
  • Re: Creating Outlook Appointment
    ... Dim username As String ... Dim olApp As Outlook.Application ... Set olApp = CreateObject ... Set Appt = olApp.CreateItem ...
    (microsoft.public.excel.programming)