当前位置: 代码迷 >> ASP.NET >> 访问IIS的有关问题, 报"User credentials cannot be used for local connections" 100分回报
  详细解决方案

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

热度:5366   发布时间:2013-02-25 00:00:00.0
访问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!
  相关解决方案