2017-01-21 3 views
0

私を助けてください!エラーCreateServerバインディングfor WMI Createウェブサイト(C#)

私は約100のソースページを見直しました。

私はそれをできませんでした。

私は2日間働きます。

私の最後のポイントはバインディングを作成しています。

「アクセスが拒否されました」というエラーが表示されます。

[TR] Yaklaşık100 kaynak sayfa inceledim。

Birtürlüyapamadım。

2gündüruğraşıyorum。

ソンゲルジムノックタバインディングオムスクルーマ。

「アクセスが拒否されました」という趣旨です。

エラー。

enter image description here

public void Creator() 
{ 

    string hostName = "BuBirSitedir"; 
    string domainName = "www.bubirsitedir.com"; 

    ConnectionOptions options = new ConnectionOptions(); 
    options.Impersonation = System.Management.ImpersonationLevel.Impersonate; 
    options.Authentication = AuthenticationLevel.Connect; 
    options.EnablePrivileges = true; 
    options.Impersonation = ImpersonationLevel.Default; 

    ManagementClass classInstance = new ManagementClass("root\\WebAdministration", "Site", null); 

    ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\MicrosoftIISV2", "DESKTOP-MGA1F3C"), options); 
    scope.Connect(); 

    ManagementBaseObject[] serverBindings = new ManagementBaseObject[3]; 
    serverBindings[0] = CreateServerBinding(scope, string.Format("{0}", hostName, domainName), "127.0.0.1", 40804); 
    serverBindings[1] = CreateServerBinding(scope, string.Format("30603", hostName, domainName), "127.0.0.1", 30603); 
    serverBindings[2] = CreateServerBinding(scope, string.Format("127.0.0.1", hostName, domainName), "127.0.0.1", 20402); 
} 

private static ManagementObject CreateServerBinding(ManagementScope scope, string hostName, string ip, int port) 
{ 
    ManagementClass mc = new ManagementClass(scope, new ManagementPath("ServerBinding"), null); 
    ManagementObject mco = mc.CreateInstance(); 
    mco.Properties["Hostname"].Value = hostName; 
    mco.Properties["IP"].Value = ip; 
    mco.Properties["Port"].Value = port; 
    mco.Put(); 
    return mco; 
} 

答えて

0

私は問題を解決しました。

マイコンピュータ(右クリック)>管理>コンピュータ管理(ローカル)>サービスとアプリケーション> WMIコントロール(右クリック)>セキュリティ(タブ)>アイテムのリストを選択してセキュリティボタン>ユーザーの選択>すべて許可>

ユーザーをリストしていません。 [詳細設定]ボタンをクリックします。 「誰も」と書いて入力します。

enter image description here