访问IIS的有关问题, 报"User credentials cannot be used for local connections"

访问IIS的问题, 报User credentials cannot be used for local connections100分回报!想通过DirectoryEn

访问IIS的问题, 报"User credentials cannot be used for local connections" 100分回报!
想通过DirectoryEntry和ManagementScope 来对IIS进行操作。
代码如下
 public bool Connect()
  {
  if (_serverName == null)
  return false;
  try
  {
  _iisServer = new DirectoryEntry("IIS://" + _serverName + "/W3SVC/1");
  _target = _serverName;
  _connection = new ConnectionOptions();
  _connection.Username = @"myname";
  _connection.Password = "mypassword";
  _scope = new ManagementScope(new ManagementPath(@"\\" + _serverName + @"\root\MicrosoftIISv2"), _connection);
  _scope.Connect();
  }
  catch(Exception ex)
  {
  string msg = ex.Message;
  return false;
  }
  return IsConnected();
  }

结果报如上错误。User credentials cannot be used for local connections
请指教!!多谢

[解决办法]
sf
[解决办法]
关注
[解决办法]
帮顶~
[解决办法]
帮你顶
[解决办法]
ding!