当我尝试使用以下代码连接到远程群集时,我收到访问被拒绝错误。我想建立连接而不在代码中提供用户名/密码。我将它们存储在Windows Credential 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();
答案 0 :(得分:1)
您必须使用interop在.NET中使用Credential Management API: http://www.microsoft.com/indonesia/msdn/credmgmt.aspx