Setting Authentication in WMI

When making calls outside of the calling process or to a remote WMI service, WMI uses the distributed version of the Component Object Model (DCOM). Out-of-process and remote calls are made through proxies, which require authentication of the credentials of the calling process.

You set the authentication level when connecting to a computer and WMI namespace. To connect to WMI, call IWbemLocator::ConnectServer in C++. In scripting or Visual Basic, you connect to WMI using SWbemLocator.ConnectServer or through the moniker string. DCOM security and WMI both require certain authentication levels when connecting between computers. The required level differs according to which operating system you are connecting. For more information, see Connecting to WMI on a Remote Computer.

WMI normally runs in a shared service host and shares the same authentication as other processes in the host. To run the WMI process with a different level of authentication, run WMI with the winmgmt command with the /standalonehost switch and set the authentication level for WMI generally. For more information, see Maintaining WMI Security.

For more information and code examples of how to set authentication for WMI connections, see Setting the Authentication Service using VBScript and Setting Authentication Using C++. These topics also contain tables that list the authentication constants for C++ and scripting.

Using Proxies in WMI

To set authentication for a proxy, call the CoSetProxyBlanket function. For more information and a code example, see Setting the Security on IWbemServices and Other Proxies.

The following COM API for WMI objects use proxies directly in C++ or C# to call out of process or to a remote WMI service:

The scripting objects, such as SWbemObject, SWbemServices, and SWbemRefresher do not use proxies directly. Instead, the scripting objects represent a wrapper or layer that calls into the COM API for WMI objects listed above. For more information and a code example of setting authentication in scripting, see Setting the Default Process Security Level Using VBScript.