2011-03-07 85 views
11

我有一個運行Server 2008 R2的Web服務器工作組,我試圖管理一個檢查所有這些磁盤空間的腳本。幾個月前,我在設置服務器時設置了這一點,我相信它工作正常。現在我去檢查,它給出了一個錯誤,說「RPC服務器不可用」。該腳本是一個C#ASP.NET頁面,雖然我嘗試過在PowerShell中進行類似的調用,但它給出了相同的錯誤。該腳本正常工作以訪問本地計算機的信息,但無法訪問遠程服務器信息。「RPC服務器不可用」使用WMI查詢

我已經花了最後幾個小時挖掘我能找到的所有東西,但沒有任何工作。我爲WMI(遠程&本地),DCOM(遠程&本地)以及我正在訪問的計算機的整個驅動器設置了權限。我使用了計算機名稱,IP地址,完整的計算機名稱(xxx.echomountain.com),並在ConnectionOptions對象上嘗試了大量的模擬和身份驗證設置。

我知道用戶名/密碼,我使用的是正確的,因爲我可以從別的什麼其他

任何想法訪問一個的碎片目錄,我可以檢查可能導致這個錯誤?

ConnectionOptions oConn = new ConnectionOptions(); 
    oConn.Impersonation = ImpersonationLevel.Impersonate; 
    oConn.EnablePrivileges = true; 
    oConn.Username = username; 
    oConn.Password = password; 
    //oConn.Authentication = AuthenticationLevel.PacketPrivacy; 
    string strNameSpace = @"\\"; 

    if (srvname != "") 
     strNameSpace += srvname + ".echomountain.com"; 
    else 
     strNameSpace += "."; 

    strNameSpace += @"\root\cimv2"; 

    ManagementScope oMs = new ManagementScope(strNameSpace, oConn); 

    //get Fixed disk state 
    ObjectQuery oQuery = new ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3"); 

    //Execute the query 
    ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery); 

    //Get the results 
    ManagementObjectCollection oReturnCollection = oSearcher.Get(); 

    //loop through found drives and write out info 
    double D_Freespace = 0; 
    double D_Totalspace = 0; 
    foreach (ManagementObject oReturn in oReturnCollection) 
    { 
     // Disk name 
     //MessageBox.Show("Name : " + oReturn["Name"].ToString()); 
     // Free Space in bytes 
     string strFreespace = oReturn["FreeSpace"].ToString(); 
     D_Freespace = D_Freespace + System.Convert.ToDouble(strFreespace); 
     // Size in bytes 
     string strTotalspace = oReturn["Size"].ToString(); 
     D_Totalspace = D_Totalspace + System.Convert.ToDouble(strTotalspace); 
     boxSize = (D_Totalspace/GB).ToString("##.00"); 
     boxFree = (D_Freespace/GB).ToString("##.00"); 
     Response.Write(srvname + ":" + boxSize + ":" + boxFree); 
    } 

Server Error in '/' Application.

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

Source Error:

Line 64: Line 65: //Get the results Line 66: ManagementObjectCollection oReturnCollection = oSearcher.Get(); Line 67: Line 68: //loop through found drives and write out info

Source File: c:\Web\medelaimages.com\iis\tool\boxinfoagent.aspx Line: 66

Stack Trace:

[COMException (0x800706ba): The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)] System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0 System.Management.ManagementScope.InitializeGuts(Object o) +674 System.Management.ManagementScope.Initialize() +347 System.Management.ManagementObjectSearcher.Initialize() +189 System.Management.ManagementObjectSearcher.Get() +54 ASP.tool_boxinfoagent_aspx.Page_Load(Object sender, EventArgs e) in c:\Web\medelaimages.com\iis\tool\boxinfoagent.aspx:66 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25 System.Web.UI.Control.LoadRecursive() +71 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

+0

我得到相同的錯誤,但它是非常隨機的,我的意思是有時我得到這個錯誤,有時我沒有。它看起來取決於我使用的登錄類型。你如何登錄?域帳戶? – raz3r 2012-03-23 16:00:25

+0

我的登錄在每臺服務器上單獨設置,但它們共享相同的憑據。我真的放棄瞭解決這個問題。如果你有工作,即使是間歇性的,我也會對你如何做這件事感興趣。 – jwynveen 2012-03-23 19:43:41

+0

假設您的腳本在域計算機上運行,​​您應該沒有任何問題,而如果您在域外運行,請嘗試使用DOMAIN \\用戶名作爲用戶名。如果我使用DOMAIN \\用戶名作爲登錄,我不會收到錯誤(大部分時間)。 – raz3r 2012-03-24 09:57:22

回答

3

錯誤信息是告訴你,RPC被阻塞,這是通過政策上的Windows 7和2008年無論是打開它默認的策略設置,或使用WMI來連接和管理主機。在內部的可信網絡上,通常啓用RPC。美國政府的計算機安全政策委員會,如創建FDCC和USGCB的政府委員會,有沒有推薦設置爲RPC,因此可以啓用它。通過WMI管理實時系統是非常難,因爲您無法查看遠程主機的註冊表,計劃任務,文件夾和文件。但是,您可以通過WMI輕鬆管理服務。

3

如果

  • 入站RPC被阻擋在目標機器上/ WMI連接可能是由於防火牆的限制

  • 只是因爲您輸入不正確的主機名/ IP錯誤The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)目標機器的地址。

錯誤發生之前任何認證和/或授權的動作,所以處理權限在該步驟不是必需的。事實上,如果用戶帳戶缺少對特定命名空間的必要權限,您將得到另一個錯誤和錯誤代碼:access denied. (0x80041003)

MSDN文章介紹瞭如何爲遠程WMI訪問添加防火牆例外:"Connecting to WMI Remotely"

0

只需轉到IIS管理器。在應用程序池中啓動您的網站服務。 它適用於我

0

另外,您需要在遠程計算機上的Windows防火牆中啓用Windows Management Instrumentation(WMI)規則。

1] Open Windows Firewall.
2] Click on Allow app or feature through windows firewall.
3] Enable Privilege for Windows Management Instrumentation(WMI).

-1

我面臨同樣的問題。早些時候,我在使用服務器IP時出現此錯誤,但在使用服務器FQDN名稱後能夠連接。排除故障後,我發現我的DNS PTR記錄不正確。修復後,我可以連接WMI和IP地址。我使用了wbemtest WMI測試工具。

相關問題