.NET and the Virtual Server 2005 COM API

3. August 2006 09:00 by Jaguilar in General  //  Tags:   //   Comments (0)

Accessing Virtual Server’s COM objects from .NET is not as direct as just including the references to the COM classes. In order to instantiate to the Virtual Server object, you need to have the proper COM permissions. For Virtual Server, the required impersonation level must be Impersonation or higher.

There are two ways to achieve this:

  1. The first one is to use Component Services to change the Default Impersonation Level to Impersonate. To do this in the Component Service console, go to Computers->My Computer->Properties, and the setting is in the Default Properties tab. This has obvious security implications, though.
  2. The second method is to do it programatically. This can be a bit painful if you’re not familiar with COM and COM Security. You have basically two options:
    • Use the method described in the Virtual Server Programming Guide, that you can find here: .
    • You can also use an alternative method, described by Virtual PC Guy in his blog as a solution to connect to Virtual Server from Powershell. You can check the link to review the code, which consists in using the CoSetProxyBlanket function, that according to the documentation “Sets the authentication information that will be used to make calls on the specified proxy.” Implementing a class similar to the one described on the linked page should work and is much simpler than the recommended approach descrbied in the Programming Guide.

Categories