concept impersonation in category .net

appears as: Impersonation
IronPython in Action

This is an excerpt from Manning's book IronPython in Action.

Listing 10.11 shows how to make the same connection using impersonation.

Listing 10.11. A WMI connection with impersonation
from System.Management import ( AuthenticationLevel, ImpersonationLevel, ManagementScope, ConnectionOptions ) options = ConnectionOptions() options.EnablePrivileges = True options.Impersonation = ImpersonationLevel.Impersonate options.Authentication = AuthenticationLevel.Default network_scope = r"\\FullComputerName\root\cimv2" scope = ManagementScope(network_scope, options)

Whether you should use authentication or impersonation depends on the details of the network you’re working with. If the computers you’re connecting to are configured to allow remote connections from any user with the correct privileges, then impersonation is easier. If the computer limits connections to a specific user, or set of users, then you’ll need to use authentication.