ネット上のサンプルでは「{impersonationLevel=impersonate}」と書いてあるものを多く見かけます。しかしそれが何であるかの説明をしてあるところが無く(なかなか見つからず)気になったので調べてみました。
MSDNのWbemImpersonationLevelEnumに関する説明です。これをgoogle翻訳にかけました(一部自分でも修正しました)。
wbemImpersonationLevel
Constant | value | Description | Google翻訳
| Anonymous | 1 | Hides the credentials of the caller. Calls to WMI may fail with this impersonation level. | 呼び出し元の資格情報を非表示にします。 WMIへの呼び出しは、この偽装レベルで失敗することがあります。
| Identify | 2 | Allows objects to query the credentials of the caller. Calls to WMI may fail with this impersonation level. | オブジェクトが呼び出し元の資格情報を照会することができます。 WMIへの呼び出しは、この偽装レベルで失敗することがあります。
| Impersonate | 3 | Allows objects to use the credentials of the caller. This is the recommended impersonation level for Scripting API for WMI calls. | オブジェクトが呼び出し元の資格情報を使用することができます。これはWMI呼び出しのためのスクリプティングAPIの<b>推奨偽装レベル</b>です。
| Delegate | 4 | Windows 2000 and later: Allows objects to permit other objects to use the credentials of the caller. This impersonation will work with Scripting API for WMI calls but may constitute an unnecessary security risk. | Windows 2000およびそれ以降:オブジェクトが他のオブジェクトが呼び出し元の資格情報を使用することを許可することができます。この偽装は、WMI呼び出しのためのスクリプティングAPIで動作しますが、不要なセキュリティリスクを構成するかもしれません。
|
以下の2つの記述は等価です。
var WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2");
var WMI = GetObject("winmgmts:\\\\.\\root\\cimv2");
WMI.Security_.ImpersonationLevel = 3;
また、無指定時は「Impersonate(3)」が適用されるようなので、結局以下でも等価です。
var WMI = GetObject("winmgmts:\\\\.\\root\\cimv2");
Windows 2000向けの記述ですが、より詳しく書かれていたので、参考の為にリンクだけメモしておきます。
|