100分求问 访问IIS 报错"User credentials cannot be used for local connections"
idda 2007-12-29 12:52:49 public bool Connect()
{
if (_serverName == null)
return false;
try
{
_iisServer = new DirectoryEntry("IIS://" + _serverName + "/W3SVC/1");
_target = _serverName;
_connection = new ConnectionOptions();
_connection.Username = @"gangchen@ethos.com.cn";
_connection.Password = "archer";
//_connection.Impersonation = ImpersonationLevel.Default;
//_connection.Authentication = AuthenticationLevel.PacketPrivacy;
//_connection.EnablePrivileges = true;
//_connection.Authority = "ntlmdomain:ethos.com.cn";
//_scope = new ManagementScope(@"\\" + _serverName + @"\root\MicrosoftIISv2", _connection);
_scope = new ManagementScope(new ManagementPath(@"\\" + _serverName + @"\root\MicrosoftIISv2"), _connection);
_scope.Connect();
}
catch(Exception ex)
{
string msg = ex.Message;
return false;
}
return IsConnected();
}