简体   繁体   中英

Connecting to remote machine without username/password

I get access denied error when I'm trying to connect to a remote cluster using the below code. I wanted to establish connection without supplying username/password in the code. I stored them in Windows Credential Manager. This works when I provide username and password in the code. How should I make it to read from the credentials manager?

ConnectionOptions Options = new ConnectionOptions(); 
//String Domain = "mydomain"; 
String Domain = ""; 
//Options.Username = "administrator"; 
//Options.Password = "mypassword";

Options.Authority = "ntlmdomain:" + Domain;
Options.Authentication = AuthenticationLevel.PacketPrivacy;

ManagementScope Scope = new ManagementScope(@"\\win2012cluster\root\cimv2", Options); 
Scope.Connect();

You have to use interop to use the Credential Management API in .NET: http://www.microsoft.com/indonesia/msdn/credmgmt.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM