How to monitor and manage remote server

G

Guest

Hello,

I have to monitor a remote server for functions such as CPU
Utilization etc. I am using System.Management namespace for the same.

But when I try to execute the following code, it gives
System.UnauthorizedAccessException though the user which I have provided is a
valid domain user having administratice rights on that computer.


Code:

//Build an options object for the connection
ConnectionOptions options = new ConnectionOptions();
options.Username = "User1";
options.Password = "MyPassword";

//Make a connection to a remote computer using these options
ManagementScope scope = new ManagementScope("\\\\Server1\\root\\cimv2",
options);
scope.Connect();


Can any one help me out for this?


Thanks,

Sushi
 
W

Willy Denoyette [MVP]

sushi said:
Hello,

I have to monitor a remote server for functions such as CPU
Utilization etc. I am using System.Management namespace for the same.

But when I try to execute the following code, it gives
System.UnauthorizedAccessException though the user which I have provided
is a
valid domain user having administratice rights on that computer.


Code:

//Build an options object for the connection
ConnectionOptions options = new ConnectionOptions();
options.Username = "User1";
options.Password = "MyPassword";

//Make a connection to a remote computer using these options
ManagementScope scope = new ManagementScope("\\\\Server1\\root\\cimv2",
options);
scope.Connect();


Can any one help me out for this?


Thanks,

Sushi

How did you spell this Username?
options.Username = "User1";
It should be of the form domain\user for downlevel domains or,
user@domain

Willy.
PS. System.Management and WMI questions are better answered in:
microsoft.public.dotnet.framework.wmi
 
G

Guest

Ya, i had given domain\username itself.

Sushi

Willy Denoyette said:
How did you spell this Username?
options.Username = "User1";
It should be of the form domain\user for downlevel domains or,
user@domain

Willy.
PS. System.Management and WMI questions are better answered in:
microsoft.public.dotnet.framework.wmi
 
W

Willy Denoyette [MVP]

sushi said:
Ya, i had given domain\username itself.

Sushi

Try with "machinename\administrator" where machinename is the name of the
server you want to connect with.

If this works, you need to make sure your domain user has appropriate rights
(remote enable)to access the WMI namespace, use wmimgmt.msc and check the
security settings.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top