WbemImpersonationLevelEnum enumeration (wbemdisp.h)

The WbemImpersonationLevelEnum constants define the security impersonation levels. These constants are used with SWbemSecurity.

The WMI scripting type library, wbemdisp.tlb, defines these constants. Visual Basic applications can access this library.

Script languages must use one of the following:

  • The short name. For example, for wbemImpersonationLevelImpersonate use "Impersonate".

    The following VBScript code example uses the short name.

    Set objWMIService = GetObject("winmgmts:" _ 
        & "{impersonationLevel=Impersonate}!\\" _
        & strComputer & "\root\cimv2")
    
  • Windows Script Host (WSH) XML file format in the script. For example, this means that the script can use the wbemImpersonationLevelImpersonate constant directly.

    The following WSH script sets the impersonation level. To run the script, save the text in a file with a .wsf extension.

    <?xml version="1.0" encoding="US-ASCII"?>
    <job>
    <reference object="WbemScripting.SWbemLocator"/>
    <script language="VBScript">
        set service = GetObject("winmgmts:")
        ' Following line uses a symbolic 
        ' constant from the WMI type library
        service.Security_.impersonationLevel = _
            wbemImpersonationLevelDelegate
    </script>
    </job>
    

    For more information, see Using the WMI Scripting Type Library.

Syntax

typedef enum WbemImpersonationLevelEnum {
  wbemImpersonationLevelAnonymous = 1,
  wbemImpersonationLevelIdentify = 2,
  wbemImpersonationLevelImpersonate = 3,
  wbemImpersonationLevelDelegate = 4
} ;

Constants

 
wbemImpersonationLevelAnonymous
Value: 1
Short name: Anonymous

Hides the credentials of the caller. Calls to WMI may fail with this impersonation level.
wbemImpersonationLevelIdentify
Value: 2
Short name: Identify

Allows objects to query the credentials of the caller. Calls to WMI may fail with this impersonation level.
wbemImpersonationLevelImpersonate
Value: 3
Short name: Impersonate

Allows objects to use the credentials of the caller. This is the recommended impersonation level for Scripting API for WMI calls.
wbemImpersonationLevelDelegate
Value: 4
Short name: Delegate

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.

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Header wbemdisp.h

See also

SWbemSecurity

Scripting API Constants

Setting Client_Application_Process Security