Machine Certificate Code Example
[The AD RMS SDK leveraging functionality exposed by the client in Msdrm.dll is available for use in Windows Server 2008, Windows Vista, Windows Server 2008 R2, Windows 7, Windows Server 2012, and Windows 8. It may be altered or unavailable in subsequent versions. Instead, use Active Directory Rights Management Services SDK 2.0, which leverages functionality exposed by the client in Msipc.dll.]
The following topics together make up a sample that shows how to activate a computer for a logged-on user. Activation creates a machine certificate and saves it in the certificate store. The sample shows how to perform activation locally rather than by using an activation service on an AD RMS server. For a more complete example that shows how to locate an activation service, refer to the MachineActivation sample included with the Microsoft Windows Software Development Kit (SDK).
Note also that the following sample checks whether the computer has already been activated before proceeding. Reactivating an already activated computer overwrites the machine certificate which in turn will require a new rights account certificate. You should always check whether a computer has been activated before attempting to activate it.