掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
WMIでのリモート接続 (ID:89889)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
WMIでリモート端末の情報を取得したいのですが、以下の接続方法だと7割位の 端末でしか接続できず、残り3割は UnauthorizedAccessException:アクセスが拒否されました。 というエラーによりアクセスが拒否されてしまいます。 拒否されるのはワークグループ環境でもAD環境でも同様のエラーで、 何が原因なのか解らずに途方にくれている状態です。 現状のソースを修正すれば回避できるのか、もしくは別の接続方法が あるのか、どなたかご教示ください。 Public Function WMI_CONFIG(ByVal strHost As String, ByVal strUser As String, _ ByVal strPass As String, ByRef strErrMsg As String) As Boolean ReDim WMI_ItemsList(17) Dim bRet As Boolean = True 'ローカルPCのホスト名取得 Dim strLcHost As String = Dns.GetHostName() Dim objScope As ManagementScope 'リモートPCへの接続情報設定 Dim conOptions As New ConnectionOptions With conOptions .Username = strUser .Password = strPass .Authentication = AuthenticationLevel.Default .Impersonation = ImpersonationLevel.Impersonate End With Dim strWMIPath As String = "\\" & strHost & "\root\cimv2" 'ローカル端末かリモート端末かを判別 If String.Compare(strLcHost, 0, strHost, 0, Len(strLcHost)) <> 0 Then 'リモート用の処理 objScope = New ManagementScope(strWMIPath, conOptions) Else 'ローカル用の処理 objScope = New ManagementScope(strWMIPath) End If Try '端末に接続 objScope.Connect() Catch ane As ArgumentNullException strErrMsg = "エラー ArgumentNullException:" & ane.Message bRet = False Catch se As Runtime.InteropServices.COMException strErrMsg = "エラー COMException:" & se.Message bRet = False Catch ue As UnauthorizedAccessException strErrMsg = "エラー UnauthorizedAccessException:" & ue.Message bRet = False Catch ex As Exception strErrMsg = "エラー Exception:" & ex.Message bRet = False Finally objScope = Nothing conOptions = Nothing End Try
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.