0
로컬 컴퓨터와 다른 도메인에있는 IIS 서버의 가상 디렉터리를 나열하는 간단한 프로그램을 작성하려고합니다. 루트하여 DirectoryEntry 개체를 만들 때,이 같은 도메인 규정과 자격 증명을 전달하려고 :System.DirectoryServices를 사용하여 다른 도메인의 웹 서버에 액세스하는 방법
DirectoryEntry entry = new DirectoryEntry("IIS://myremoteserver/W3SVC/1/Root", "mydomain\\myusername", "mypassword");
내가 그러나, "액세스가 거부되었습니다"예외를 얻을. 이것을하는 것이 올바른 방법일까요? 내가 찾은 모든 코드 예제는 로컬 웹 서버에만 액세스합니다. WinXP SP3을 로컬에서 실행 중이고 IIS 버전 6.0을 실행하는 Win2003 R2 (64 비트) 서버에 연결하려고합니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
namespace MyProgram
{
class Program
{
static void Main(string[] args)
{
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.PacketPrivacy;
options.Username = "somedomain\\username";
options.Password = "password";
ManagementPath path = new ManagementPath();
path.Server = "someserver";
path.NamespacePath = "root/MicrosoftIISv2";
ManagementScope scope = new ManagementScope(path, options);
string Query = "select * from IIsWebVirtualDirSetting";
using (ManagementObjectSearcher search = new ManagementObjectSearcher(scope, new ObjectQuery(Query)))
{
ManagementObjectCollection results = search.Get();
foreach (ManagementObject obj in results)
{
Console.WriteLine(obj.Properties["Name"].Value);
}
}
Console.ReadLine();
}
}
}
: