windows_snapshot/operating_system/software_license_provider.rs
1//! The Windows Management Instrumentation (WMI) Software Licensing provider retrieves software licensing data. The classes are defined in SppWmi.mof and are located in the "root\cimv2" namespace.
2//!
3//! | Classes | Description |
4//! | ------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
5//! | [**SoftwareLicensingProduct**](https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/sppwmi/softwarelicensingproduct) | Exposes the product-specific properties and methods of the Software Licensing service. |
6//! | [**SoftwareLicensingService**](https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/sppwmi/softwarelicensingservice) | Exposes the product-independent properties and methods of the Software Licensing service. |
7//! | [**SoftwareLicensingTokenActivationLicense**](https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/sppwmi/softwarelicensingtokenactivationlicense) | Exposes the properties of installed token-based activation licenses. |
8
9use crate::update;
10use serde::{Deserialize, Serialize};
11use std::time::SystemTime;
12use wmi::{COMLibrary, WMIConnection, WMIDateTime};
13
14/// Represents the state of Windows SoftwareLicensingProducts
15#[derive(Deserialize, Serialize, Debug, Clone)]
16pub struct SoftwareLicensingProducts {
17 /// Represents data stored in a Windows SoftwareLicensingProducts
18 pub software_licensing_products: Vec<SoftwareLicensingProduct>,
19 /// When was the record last updated
20 pub last_updated: SystemTime,
21}
22
23update!(SoftwareLicensingProducts, software_licensing_products);
24
25/// Represents the state of Windows SoftwareLicensingServices
26#[derive(Deserialize, Serialize, Debug, Clone)]
27pub struct SoftwareLicensingServices {
28 /// Represents data stored in a Windows SoftwareLicensingServices
29 pub software_licensing_services: Vec<SoftwareLicensingService>,
30 /// When was the record last updated
31 pub last_updated: SystemTime,
32}
33
34update!(SoftwareLicensingServices, software_licensing_services);
35
36/// Represents the state of Windows SoftwareLicensingTokenActivationLicenses
37#[derive(Deserialize, Serialize, Debug, Clone)]
38pub struct SoftwareLicensingTokenActivationLicenses {
39 /// Represents data stored in a Windows SoftwareLicensingTokenActivationLicenses
40 pub software_licensing_token_activation_licenses: Vec<SoftwareLicensingTokenActivationLicense>,
41 /// When was the record last updated
42 pub last_updated: SystemTime,
43}
44
45update!(SoftwareLicensingTokenActivationLicenses, software_licensing_token_activation_licenses);
46
47/// This class exposes the product-specific properties and methods of the Software Licensing service.
48///
49/// <https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/sppwmi/softwarelicensingproduct>
50#[derive(Default, Deserialize, Serialize, Debug, Clone)]
51#[allow(non_snake_case)]
52#[allow(non_camel_case_types)]
53pub struct SoftwareLicensingProduct {
54 /// Specifies the product identifier.
55 pub ID: Option<String>,
56 /// Specifies the product name.
57 pub Name: Option<String>,
58 /// Specifies the product description.
59 pub Description: Option<String>,
60 /// Specifies the ID of current product application.
61 pub ApplicationID: Option<String>,
62 /// Specifies the software licensing server URL for the process certificate.
63 pub ProcessorURL: Option<String>,
64 /// Specifies the software licensing server URL for the binding certificate.
65 pub MachineURL: Option<String>,
66 /// Specifies the software licensing server URL for the product certificate.
67 pub ProductKeyURL: Option<String>,
68 /// Specifies the software licensing server URL for the user license.
69 pub UseLicenseURL: Option<String>,
70 /// Specifies the license status of this product application. The following values are possible.
71 ///
72 /// Value: Description
73 /// - 0: Unlicensed
74 /// - 1: Licensed
75 /// - 2: OOBGrace
76 /// - 3: OOTGrace
77 /// - 4: NonGenuineGrace
78 /// - 5: Notification
79 /// - 6: ExtendedGrace
80 pub LicenseStatus: Option<u32>,
81 /// Specifies the license status. Provides additional information about why a computer is in a
82 /// specific licensing state.
83 pub LicenseStatusReason: Option<u32>,
84 /// Specifies the remaining time, in minutes, before the parent application goes into notification
85 /// mode. For volume clients, this is the remaining time before reactivation is required.
86 pub GracePeriodRemaining: Option<u32>,
87 /// Specifies the expiration date of this product application. After this date, the `LicenseStatus`
88 /// property is set to Unlicensed and cannot be activated.
89 pub EvaluationEndDate: Option<WMIDateTime>,
90 /// Specifies the offline installation identifier of this product application. Used for offline
91 /// activation. Returns a `null` value if a product key is not installed.
92 pub OfflineInstallationId: Option<String>,
93 /// Specifies the last five characters of the product key. Returns a `null` value if a product key
94 /// is not installed.
95 pub PartialProductKey: Option<String>,
96 /// Specifies the product key ID. Returns a `null` value if a product key is not installed.
97 pub ProductKeyID: Option<String>,
98 /// Specifies the group identifier for the SKU used to determine license relationships for add-ons.
99 pub LicenseFamily: Option<String>,
100 /// Specifies the dependency identifier for the set of SKUs used to determine license relationships
101 /// for add-ons.
102 pub LicenseDependsOn: Option<String>,
103 /// Indicates `TRUE` if the product is identified as an add-on license.
104 pub LicenseIsAddon: Option<bool>,
105 /// Specifies the frequency, in minutes, of how often a client will contact the KMS host before the
106 /// product is licensed.
107 pub VLActivationInterval: Option<u32>,
108 /// Specifies the frequency, in minutes, of how often a client will contact the KMS host after the
109 /// product is licensed.
110 pub VLRenewalInterval: Option<u32>,
111 /// Specifies the KMS product key ID. Returns `null` if it is not applicable.
112 pub KeyManagementServiceProductKeyID: Option<String>,
113 /// Specifies the name of the KMS host. Returns null if `SetKeyManagementServiceMachine`
114 /// has not been called.
115 pub KeyManagementServiceMachine: Option<String>,
116 /// Specifies the TCP port that is used by clients to send KMS-activation requests.
117 /// Returns 0 if `SetKeyManagementServicePort` has not been called.
118 pub KeyManagementServicePort: Option<u32>,
119 /// Specifies the last discovered KMS host name through DNS.
120 pub DiscoveredKeyManagementServiceMachineName: Option<String>,
121 /// Specifies the last discovered KMS host port through DNS.
122 pub DiscoveredKeyManagementServiceMachinePort: Option<u32>,
123 /// Indicates whether KMS is enabled on the computer. The following values are possible.
124 ///
125 /// Value: Description
126 /// - 0: False
127 /// - 1: True
128 pub IsKeyManagementServiceMachine: Option<u32>,
129 /// Specifies the count of currently active KMS clients on the KMS host. A value of -1
130 /// indicates the host is not enabled as a KMS or that it has not received any
131 /// client-licensing requests.
132 pub KeyManagementServiceCurrentCount: Option<u32>,
133 /// Specifies the minimum number of clients that are required to connect to a KMS host to
134 /// enable volume licensing.
135 pub RequiredClientCount: Option<u32>,
136 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 0 (Unlicensed).
137 pub KeyManagementServiceUnlicensedRequests: Option<u32>,
138 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 1 (Licensed).
139 pub KeyManagementServiceLicensedRequests: Option<u32>,
140 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 2 (OOBGrace).
141 pub KeyManagementServiceOOBGraceRequests: Option<u32>,
142 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 3 (OOTGrace).
143 pub KeyManagementServiceOOTGraceRequests: Option<u32>,
144 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 4
145 /// (NonGenuineGrace).
146 pub KeyManagementServiceNonGenuineGraceRequests: Option<u32>,
147 /// Specifies the count of valid KMS requests.
148 pub KeyManagementServiceTotalRequests: Option<u32>,
149 /// Specifies the count of failed KMS requests.
150 pub KeyManagementServiceFailedRequests: Option<u32>,
151 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 5
152 /// (Notification).
153 pub KeyManagementServiceNotificationRequests: Option<u32>,
154 /// Specifies the genuine status for the product application.
155 pub GenuineStatus: Option<u32>,
156 /// Specifies the extended grace time, in minutes, before the parent application goes into
157 /// notification mode.
158 pub ExtendedGrace: Option<u32>,
159 /// Specifies the ID of the token-based activation license that activated the product.
160 pub TokenActivationILID: Option<String>,
161 /// Specifies the version of the token-based activation license that activated the product.
162 pub TokenActivationILVID: Option<u32>,
163 /// Specifies the grant number in the token-based activation license that activated the product.
164 pub TokenActivationGrantNumber: Option<u32>,
165 /// Specifies the thumbprint of the certificate that activated the product.
166 pub TokenActivationCertificateThumbprint: Option<String>,
167 /// Specifies additional information for token-based activation.
168 pub TokenActivationAdditionalInfo: Option<String>,
169 /// Specifies the trusted time for the product.
170 pub TrustedTime: Option<WMIDateTime>,
171}
172
173/// This class exposes the product-independent properties and methods of the Software Licensing service.
174///
175/// <https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/sppwmi/softwarelicensingservice>
176#[derive(Default, Deserialize, Serialize, Debug, Clone)]
177#[allow(non_snake_case)]
178#[allow(non_camel_case_types)]
179pub struct SoftwareLicensingService {
180 /// Specifies the version of the Software Licensing service.
181 pub Version: Option<String>,
182 /// Specifies the registered key management service machine name. Returns null if
183 /// `SetKeyManagementServiceMachine` has not been called.
184 pub KeyManagementServiceMachine: Option<String>,
185 /// Indicates whether the machine has a key management service (KMS) enabled. The following values
186 /// are possible.
187 ///
188 /// Value: Description
189 /// - 0: False
190 /// - 1: True
191 pub IsKeyManagementServiceMachine: Option<u32>,
192 /// Specifies the frequency, in minutes, of how often a client should contact the KMS machine before
193 /// the client is licensed.
194 pub VLActivationInterval: Option<u32>,
195 /// Specifies the frequency, in minutes, of how often the current machine should contact the KMS machine
196 /// after the client is licensed.
197 pub VLRenewalInterval: Option<u32>,
198 /// Specifies the count of currently active volume clients. A value of -1 indicates that the machine
199 /// is not enabled as a KMS or that it has not received any client licensing-requests.
200 pub KeyManagementServiceCurrentCount: Option<u32>,
201 /// Specifies the minimum number of clients required to connect to a KMS machine to enable volume
202 /// licensing.
203 pub RequiredClientCount: Option<u32>,
204 /// Specifies the KMS product key ID. Returns null if not applicable.
205 pub KeyManagementServiceProductKeyID: Option<String>,
206 /// Specifies the last discovered KMS host name through DNS.
207 pub DiscoveredKeyManagementServiceMachineName: Option<String>,
208 /// Specifies the last discovered KMS host port through DNS.
209 pub DiscoveredKeyManagementServiceMachinePort: Option<u32>,
210 /// Indicates whether the licensing policy cache needs to be updated. The following values are possible.
211 ///
212 /// Value: Description
213 /// - 0: Refresh not required.
214 /// - 1: Refresh required.
215 pub PolicyCacheRefreshRequired: Option<u32>,
216 /// Specifies the unique identifier for this volume client machine. The client includes this CMID
217 /// in requests it sends to the KMS.
218 pub ClientMachineID: Option<String>,
219 /// Specifies the remaining number of times that the client can be successfully rearmed.
220 pub RemainingWindowsReArmCount: Option<u32>,
221 /// Specifies the TCP port on which the KMS host listens for activation requests.
222 pub KeyManagementServiceListeningPort: Option<u32>,
223 /// Indicates the DNS publishing status of a KMS host. The following values are possible.
224 ///
225 /// Value: Description
226 /// - 0: Disabled
227 /// - 1: Auto-publish enabled (default)
228 pub KeyManagementServiceDnsPublishing: Option<bool>,
229 /// Indicates the thread priority status of the KMS. The following values are possible.
230 ///
231 /// Value: Description
232 /// - 0: Normal priority (default)
233 /// - 1: Low priority
234 pub KeyManagementServiceLowPriority: Option<bool>,
235 /// Indicates the caching status of the KMS host name and port. The following values are possible.
236 ///
237 /// Value: Description
238 /// - 0: Caching disabled
239 /// - 1: Caching enabled (default)
240 pub KeyManagementServiceHostCaching: Option<bool>,
241 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 0 (Unlicensed).
242 pub KeyManagementServiceUnlicensedRequests: Option<u32>,
243 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 1 (Licensed).
244 pub KeyManagementServiceLicensedRequests: Option<u32>,
245 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 2 (OOBGrace).
246 pub KeyManagementServiceOOBGraceRequests: Option<u32>,
247 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 3 (OOTGrace).
248 pub KeyManagementServiceOOTGraceRequests: Option<u32>,
249 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 4 (NonGenuineGrace).
250 pub KeyManagementServiceNonGenuineGraceRequests: Option<u32>,
251 /// Specifies the total count of valid KMS requests.
252 pub KeyManagementServiceTotalRequests: Option<u32>,
253 /// Specifies the total count of failed KMS requests.
254 pub KeyManagementServiceFailedRequests: Option<u32>,
255 /// Specifies the count of KMS requests from clients with `LicenseStatus` set to 5 (Notification).
256 pub KeyManagementServiceNotificationRequests: Option<u32>,
257 /// Specifies the ID of the token-based activation license that activated the computer.
258 pub TokenActivationILID: Option<String>,
259 /// Specifies the version of the token-based activation license that activated the computer.
260 pub TokenActivationILVID: Option<u32>,
261 /// Specifies the grant number in the token-based activation license that activated the computer.
262 pub TokenActivationGrantNumber: Option<u32>,
263 /// Specifies the thumbprint of the certificate that activated the computer.
264 pub TokenActivationCertificateThumbprint: Option<String>,
265 /// Specifies additional information for token-based activation.
266 pub TokenActivationAdditionalInfo: Option<String>,
267 // /// Indicates whether the volume activation through key management service is disabled.
268 // pub KeyManagementServiceActivationDisabled: Option<bool>,
269}
270
271/// This class exposes properties of installed token-based activation licenses.
272///
273/// <https://learn.microsoft.com/en-gb/previous-versions/windows/desktop/sppwmi/softwarelicensingtokenactivationlicense>
274#[derive(Default, Deserialize, Serialize, Debug, Clone)]
275#[allow(non_snake_case)]
276#[allow(non_camel_case_types)]
277pub struct SoftwareLicensingTokenActivationLicense {
278 /// Specifies a GUID that is used by the Software Licensing service to uniquely identify an XRML
279 /// license.
280 pub ID: Option<String>,
281 /// Specifies a GUID that is used to identify the IL to the customer. The ILID is not unique, unless
282 /// combined with the ILVID.
283 pub ILID: Option<String>,
284 /// Specifies a version number that is used along with the ILID to allow customers to version their
285 /// licenses.
286 pub ILVID: Option<u32>,
287 /// Specifies an HRESULT returned from the issuance license (IL) authorization.
288 pub AuthorizationStatus: Option<u32>,
289 /// Specifies a UTC datetime after which the IL cannot be used for token activation.
290 pub ExpirationDate: Option<WMIDateTime>,
291 /// Specifies optional text provided by the customer and included in the IL.
292 pub Description: Option<String>,
293 /// Specifies optional text to provide additional metadata.
294 pub AdditionalInfo: Option<String>,
295}