Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

869 lines
21 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: postjob.cpp
  6. //
  7. // Contents: Post various job to job manager
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include "pch.cpp"
  13. #include "postjob.h"
  14. #include "tlsjob.h"
  15. #include "globals.h"
  16. ////////////////////////////////////////////////////////////////
  17. BOOL
  18. IsLicensePackRepl(
  19. IN TLSLICENSEPACK* pLicensePack
  20. )
  21. /*++
  22. Abstract:
  23. Determine if license pack is replicable.
  24. Parameter:
  25. pLicensePack - License Pack.
  26. Returns:
  27. TRUE if license pack can be replicated to other serve
  28. FALSE otherwise.
  29. Remark:
  30. Do not replicate FREE or special license pack.
  31. --*/
  32. {
  33. BOOL bYes = TRUE;
  34. if(
  35. (pLicensePack->ucAgreementType == LSKEYPACKTYPE_FREE) ||
  36. (pLicensePack->ucAgreementType & (LSKEYPACK_REMOTE_TYPE | LSKEYPACK_HIDDEN_TYPE | LSKEYPACK_LOCAL_TYPE)) ||
  37. (pLicensePack->ucKeyPackStatus & (LSKEYPACKSTATUS_HIDDEN | LSKEYPACKSTATUS_REMOTE | LSKEYPACKSTATUS_LOCAL))
  38. )
  39. {
  40. bYes = FALSE;
  41. }
  42. if( bYes == TRUE )
  43. {
  44. UCHAR ucKeyPackStatus = (pLicensePack->ucKeyPackStatus & ~LSKEYPACKSTATUS_RESERVED);
  45. // don't replicate temp. license pack.
  46. if( ucKeyPackStatus == LSKEYPACKSTATUS_TEMPORARY )
  47. {
  48. bYes = FALSE;
  49. }
  50. }
  51. return bYes;
  52. }
  53. ////////////////////////////////////////////////////////////////
  54. BOOL
  55. TLSCanForwardRequest(
  56. IN DWORD dwLocalServerVersion,
  57. IN DWORD dwTargetServerVersion
  58. )
  59. /*++
  60. Abstract:
  61. Determine if version of server is compatible.
  62. Parameter:
  63. dwLocalServerVersion : Local server version.
  64. dwTargetServerVersion : Targer server version.
  65. Returns:
  66. TRUE/FALSE.
  67. Remark:
  68. Rules
  69. 1) No forward to server version older than 5.1.
  70. 2) Enforce to enforce, non-enforce to non-enforce only.
  71. 3) Enterprise to enterprise only.
  72. 4) domain/workgroup server to enterprise no enterprise
  73. to domain/workgroup.
  74. --*/
  75. {
  76. BOOL bCanForward;
  77. BOOL bLocalEnforce;
  78. BOOL bRemoteEnforce;
  79. bCanForward = TLSIsServerCompatible(
  80. dwLocalServerVersion,
  81. dwTargetServerVersion
  82. );
  83. //bLocalEnforce = IS_ENFORCE_SERVER(dwLocalServerVersion);
  84. //bRemoteEnforce = IS_ENFORCE_SERVER(dwTargetServerVersion);
  85. //
  86. // No enforce to non-enforce replication
  87. //
  88. //if( bLocalEnforce != bRemoteEnforce )
  89. //{
  90. // bCanForward = FALSE;
  91. //}
  92. if(bCanForward == TRUE)
  93. {
  94. BOOL bEnterpriseLocal = IS_ENTERPRISE_SERVER(dwLocalServerVersion);
  95. BOOL bEnterpriseRemote = IS_ENTERPRISE_SERVER(dwTargetServerVersion);
  96. if( g_SrvRole & TLSERVER_ENTERPRISE_SERVER )
  97. {
  98. bEnterpriseLocal = TRUE;
  99. }
  100. if(bEnterpriseLocal == TRUE && bEnterpriseRemote == FALSE)
  101. {
  102. bCanForward = FALSE;
  103. }
  104. }
  105. return bCanForward;
  106. }
  107. ////////////////////////////////////////////////////////////////
  108. BOOL
  109. TLSIsServerCompatible(
  110. IN DWORD dwLocalServerVersion,
  111. IN DWORD dwTargetServerVersion
  112. )
  113. /*++
  114. Abstract:
  115. Determine if two server is compatible.
  116. Parameters:
  117. dwLocalServerVersion : Local server version.
  118. dwTargetServerVersion : Target server version.
  119. Return:
  120. TRUE/FALSE.
  121. Remark:
  122. 1) No server older than 5.1
  123. 2) Enforce to enforce and non-enforce to non-enforce only
  124. --*/
  125. {
  126. DWORD dwTargetMajor = GET_SERVER_MAJOR_VERSION(dwTargetServerVersion);
  127. DWORD dwTargetMinor = GET_SERVER_MINOR_VERSION(dwTargetServerVersion);
  128. //
  129. // This version of License Server is not compatible with anyother
  130. if(dwTargetMajor == 5 && dwTargetMinor == 0)
  131. {
  132. return FALSE;
  133. }
  134. return (IS_ENFORCE_SERVER(dwLocalServerVersion) == IS_ENFORCE_SERVER(dwTargetServerVersion));
  135. }
  136. ////////////////////////////////////////////////////////////////
  137. BOOL
  138. TLSCanPushReplicateData(
  139. IN DWORD dwLocalServerVersion,
  140. IN DWORD dwTargetServerVersion
  141. )
  142. /*++
  143. Abstract:
  144. Determine if local server can 'push' replicate
  145. data to remote server.
  146. Parameters:
  147. dwLocalServerVersion : Local server version.
  148. dwTargetServerVersion : Target server version.
  149. Returns:
  150. TRUE/FALSE.
  151. Remark:
  152. 1) See TLSIsServerCompatible().
  153. 2) only one-way from enterprise to
  154. domain/workgroup server.
  155. --*/
  156. {
  157. BOOL bCanReplicate;
  158. BOOL bLocalEnforce;
  159. BOOL bRemoteEnforce;
  160. bCanReplicate = TLSIsServerCompatible(
  161. dwLocalServerVersion,
  162. dwTargetServerVersion
  163. );
  164. bLocalEnforce = IS_ENFORCE_SERVER(dwLocalServerVersion);
  165. bRemoteEnforce = IS_ENFORCE_SERVER(dwTargetServerVersion);
  166. //
  167. // No enforce to non-enforce replication
  168. //
  169. if( bLocalEnforce != bRemoteEnforce )
  170. {
  171. bCanReplicate = FALSE;
  172. }
  173. if(bCanReplicate == TRUE)
  174. {
  175. BOOL bEnterpriseLocal = IS_ENTERPRISE_SERVER(dwLocalServerVersion);
  176. BOOL bEnterpriseRemote = IS_ENTERPRISE_SERVER(dwTargetServerVersion);
  177. if( g_SrvRole & TLSERVER_ENTERPRISE_SERVER )
  178. {
  179. bEnterpriseLocal = TRUE;
  180. }
  181. if(bEnterpriseLocal == FALSE && bEnterpriseRemote == TRUE)
  182. {
  183. bCanReplicate = FALSE;
  184. }
  185. }
  186. return bCanReplicate;
  187. }
  188. ////////////////////////////////////////////////////////////////
  189. DWORD
  190. PostSsyncLkpJob(
  191. IN PSSYNCLICENSEPACK syncLkp
  192. )
  193. /*++
  194. Abstract:
  195. Wrapper to post a sync. license pack job to work manager.
  196. Parameter:
  197. syncLkp : License pack and other info to be sync.
  198. Returns:
  199. ERROR_SUCCESS or error code.
  200. --*/
  201. {
  202. DWORD dwStatus = ERROR_SUCCESS;
  203. CSsyncLicensePack* pSyncLicensePack;
  204. pSyncLicensePack = new CSsyncLicensePack(
  205. TRUE,
  206. syncLkp,
  207. sizeof(SSYNCLICENSEPACK)
  208. );
  209. //
  210. // Set work default interval/retry times
  211. //
  212. TLSWorkManagerSetJobDefaults(pSyncLicensePack);
  213. dwStatus = TLSWorkManagerSchedule(0, pSyncLicensePack);
  214. if(dwStatus != ERROR_SUCCESS)
  215. {
  216. TLSLogEvent(
  217. EVENTLOG_ERROR_TYPE,
  218. TLS_E_WORKMANAGERGENERAL,
  219. TLS_E_WORKMANAGER_SCHEDULEJOB,
  220. dwStatus
  221. );
  222. delete pSyncLicensePack;
  223. }
  224. return dwStatus;
  225. }
  226. //--------------------------------------------------------------------
  227. DWORD
  228. TLSAnnounceLKPToAllRemoteServer(
  229. IN DWORD dwKeyPackId,
  230. IN DWORD dwDelayTime
  231. )
  232. /*++
  233. Abstract:
  234. Announce a license pack by its internal ID to all
  235. known server.
  236. Parameter:
  237. dwKeyPackId : License keypack's internal tracking Id.
  238. Returns:
  239. ERROR_SUCCESS or error code.
  240. --*/
  241. {
  242. PTLServerInfo pServerInfo = NULL;
  243. DWORD dwStatus = ERROR_SUCCESS;
  244. DWORD dwCount;
  245. DBGPrintf(
  246. DBG_INFORMATION,
  247. DBG_FACILITY_JOB,
  248. DBGLEVEL_FUNCTION_TRACE,
  249. _TEXT("Announce %d LKP to servers...\n"),
  250. dwKeyPackId
  251. );
  252. SSYNCLICENSEPACK SsyncLkp;
  253. memset(
  254. &SsyncLkp,
  255. 0,
  256. sizeof(SSYNCLICENSEPACK)
  257. );
  258. SsyncLkp.dwStructVersion = CURRENT_SSYNCLICENSEKEYPACK_STRUCT_VER;
  259. SsyncLkp.dwStructSize = sizeof(SSYNCLICENSEPACK);
  260. SsyncLkp.dwSyncType = SSYNC_ONE_LKP;
  261. SsyncLkp.dwKeyPackId = dwKeyPackId;
  262. SsyncLkp.dwNumServer = 0;
  263. SAFESTRCPY(SsyncLkp.m_szServerId, g_pszServerPid);
  264. SAFESTRCPY(SsyncLkp.m_szServerName, g_szComputerName);
  265. //
  266. // Lock known server list
  267. //
  268. TLSBeginEnumKnownServerList();
  269. while((pServerInfo = TLSGetNextKnownServer()) != NULL)
  270. {
  271. if(TLSCanPushReplicateData(
  272. TLS_CURRENT_VERSION,
  273. pServerInfo->GetServerVersion()
  274. ) == FALSE)
  275. {
  276. continue;
  277. }
  278. if(pServerInfo->IsServerSupportReplication() == FALSE)
  279. {
  280. continue;
  281. }
  282. if(SsyncLkp.dwNumServer >= SSYNCLKP_MAX_TARGET)
  283. {
  284. dwStatus = PostSsyncLkpJob(&SsyncLkp);
  285. if(dwStatus != ERROR_SUCCESS)
  286. {
  287. break;
  288. }
  289. SsyncLkp.dwNumServer = 0;
  290. }
  291. SAFESTRCPY(
  292. SsyncLkp.m_szTargetServer[SsyncLkp.dwNumServer],
  293. pServerInfo->GetServerName()
  294. );
  295. SsyncLkp.dwNumServer++;
  296. }
  297. TLSEndEnumKnownServerList();
  298. if(dwStatus == ERROR_SUCCESS && SsyncLkp.dwNumServer != 0)
  299. {
  300. dwStatus = PostSsyncLkpJob(&SsyncLkp);
  301. }
  302. return dwStatus;
  303. }
  304. /////////////////////////////////////////////////////////////////////////
  305. DWORD
  306. TLSPushSyncLocalLkpToServer(
  307. IN LPTSTR pszSetupId,
  308. IN LPTSTR pszDomainName,
  309. IN LPTSTR pszLserverName,
  310. IN FILETIME* pSyncTime
  311. )
  312. /*++
  313. Abstract:
  314. 'Push' sync registered license pack to other server.
  315. Parameters:
  316. pszSetupId : Remote server's setup ID.
  317. pszDomainName : Remote server's domain name.
  318. pszLserverName : Remote server name.
  319. pSyncTime : Pointer to FILETIME, sync. all license pack with the time stamp
  320. greater or equal to this time will be 'push' sync.
  321. Returns:
  322. ERROR_SUCCESS or error code.
  323. --*/
  324. {
  325. DWORD dwStatus = ERROR_SUCCESS;
  326. TLServerInfo ServerInfo;
  327. SSYNCLICENSEPACK SsyncLkp;
  328. //
  329. // resolve ServerId to server name
  330. //
  331. dwStatus = TLSLookupRegisteredServer(
  332. pszSetupId,
  333. pszDomainName,
  334. pszLserverName,
  335. &ServerInfo
  336. );
  337. if(dwStatus != ERROR_SUCCESS)
  338. {
  339. goto cleanup;
  340. }
  341. //
  342. // Make sure local server can push replicate
  343. // data to remote server.
  344. //
  345. if(TLSCanPushReplicateData(
  346. TLS_CURRENT_VERSION,
  347. ServerInfo.GetServerVersion()
  348. ) == FALSE)
  349. {
  350. goto cleanup;
  351. }
  352. //
  353. // Form a sync work object and post it to work manager.
  354. //
  355. memset(
  356. &SsyncLkp,
  357. 0,
  358. sizeof(SSYNCLICENSEPACK)
  359. );
  360. SsyncLkp.dwStructVersion = CURRENT_SSYNCLICENSEKEYPACK_STRUCT_VER;
  361. SsyncLkp.dwStructSize = sizeof(SSYNCLICENSEPACK);
  362. SAFESTRCPY(SsyncLkp.m_szServerId, g_pszServerPid);
  363. SAFESTRCPY(SsyncLkp.m_szServerName, g_szComputerName);
  364. SsyncLkp.dwSyncType = SSYNC_ALL_LKP;
  365. SsyncLkp.dwNumServer = 1;
  366. SAFESTRCPY(
  367. SsyncLkp.m_szTargetServer[0],
  368. ServerInfo.GetServerName()
  369. );
  370. SsyncLkp.m_ftStartSyncTime = *pSyncTime;
  371. dwStatus = PostSsyncLkpJob(&SsyncLkp);
  372. cleanup:
  373. return dwStatus;
  374. }
  375. ////////////////////////////////////////////////////////////////
  376. DWORD
  377. TLSStartAnnounceResponseJob(
  378. IN LPTSTR pszTargetServerId,
  379. IN LPTSTR pszTargetServerDomain,
  380. IN LPTSTR pszTargetServerName,
  381. IN FILETIME* pftTime
  382. )
  383. /*++
  384. Abstract:
  385. Create a License Server Announcement response work object and post it
  386. to work manager.
  387. Parameter:
  388. pszTargetServerId : Target server Id.
  389. pszTargetServerDomain : Target server's domain.
  390. pszTargetServerName : Target server name.
  391. pftTime : Pointer to FILE, local server's last shutdown time.
  392. Returns:
  393. ERROR_SUCCESS or error code.
  394. --*/
  395. {
  396. DWORD dwStatus = ERROR_SUCCESS;
  397. ANNOUNCERESPONSEWO response;
  398. TLServerInfo ServerInfo;
  399. CAnnounceResponse* pAnnounceResponse = NULL;
  400. //
  401. // Perform lookup on server to determine its eligibility
  402. //
  403. dwStatus = TLSLookupRegisteredServer(
  404. pszTargetServerId,
  405. pszTargetServerDomain,
  406. pszTargetServerName,
  407. &ServerInfo
  408. );
  409. if(dwStatus != ERROR_SUCCESS)
  410. {
  411. // can't find server, no response
  412. goto cleanup;
  413. }
  414. memset(&response, 0, sizeof(response));
  415. response.dwStructVersion = CURRENT_ANNOUNCERESPONSEWO_STRUCT_VER;
  416. response.dwStructSize = sizeof(response);
  417. response.bCompleted = FALSE;
  418. SAFESTRCPY(response.m_szTargetServerId, pszTargetServerId);
  419. SAFESTRCPY(response.m_szLocalServerId, g_pszServerPid);
  420. SAFESTRCPY(response.m_szLocalServerName, g_szComputerName);
  421. SAFESTRCPY(response.m_szLocalScope, g_szScope);
  422. response.m_ftLastShutdownTime = *pftTime;
  423. pAnnounceResponse = new CAnnounceResponse(
  424. TRUE,
  425. &response,
  426. sizeof(response)
  427. );
  428. //
  429. // Set work default interval/retry times
  430. //
  431. TLSWorkManagerSetJobDefaults(pAnnounceResponse);
  432. dwStatus = TLSWorkManagerSchedule(0, pAnnounceResponse);
  433. if(dwStatus != ERROR_SUCCESS)
  434. {
  435. TLSLogEvent(
  436. EVENTLOG_ERROR_TYPE,
  437. TLS_E_WORKMANAGERGENERAL,
  438. TLS_E_WORKMANAGER_SCHEDULEJOB,
  439. dwStatus
  440. );
  441. delete pAnnounceResponse;
  442. }
  443. cleanup:
  444. return dwStatus;
  445. }
  446. /////////////////////////////////////////////////////////////////////
  447. DWORD
  448. TLSStartAnnounceToEServerJob(
  449. IN LPCTSTR pszServerId,
  450. IN LPCTSTR pszServerDomain,
  451. IN LPCTSTR pszServerName,
  452. IN FILETIME* pftFileTime
  453. )
  454. /*++
  455. Abstract:
  456. Create a Enterprise server discovery job and post it to work
  457. manager.
  458. Parameters:
  459. pszServerId : Local server's ID.
  460. pszServerDomain : Local server's domain.
  461. pszServerName : Local server name.
  462. pftFileTime : Pointer to FILETIME, local server's last shutdown time.
  463. Returns:
  464. ERROR_SUCCESS or error code.
  465. --*/
  466. {
  467. DWORD dwStatus = ERROR_SUCCESS;
  468. ANNOUNCETOESERVERWO AnnounceToES;
  469. memset(&AnnounceToES, 0, sizeof(AnnounceToES));
  470. AnnounceToES.dwStructVersion = CURRENT_ANNOUNCETOESERVEWO_STRUCT_VER;
  471. AnnounceToES.dwStructSize = sizeof(ANNOUNCETOESERVERWO);
  472. AnnounceToES.bCompleted = FALSE;
  473. SAFESTRCPY(AnnounceToES.m_szServerId, pszServerId);
  474. SAFESTRCPY(AnnounceToES.m_szServerName, pszServerName);
  475. SAFESTRCPY(AnnounceToES.m_szScope, pszServerDomain);
  476. AnnounceToES.m_ftLastShutdownTime = *pftFileTime;
  477. CAnnounceToEServer* pAnnounceESWO = NULL;
  478. pAnnounceESWO = new CAnnounceToEServer(
  479. TRUE,
  480. &AnnounceToES,
  481. sizeof(ANNOUNCETOESERVERWO)
  482. );
  483. //
  484. // Set work default interval/retry times
  485. //
  486. TLSWorkManagerSetJobDefaults(pAnnounceESWO);
  487. dwStatus = TLSWorkManagerSchedule(0, pAnnounceESWO);
  488. if(dwStatus != ERROR_SUCCESS)
  489. {
  490. TLSLogEvent(
  491. EVENTLOG_ERROR_TYPE,
  492. TLS_E_WORKMANAGERGENERAL,
  493. TLS_E_WORKMANAGER_SCHEDULEJOB,
  494. dwStatus
  495. );
  496. delete pAnnounceESWO;
  497. }
  498. return dwStatus;
  499. }
  500. /////////////////////////////////////////////////////////////////////////
  501. DWORD
  502. TLSStartAnnounceLicenseServerJob(
  503. IN LPCTSTR pszServerId,
  504. IN LPCTSTR pszServerDomain,
  505. IN LPCTSTR pszServerName,
  506. IN FILETIME* pftFileTime
  507. )
  508. /*++
  509. Abstract:
  510. Create a license server announcement job and post it to work
  511. manager.
  512. Parameters:
  513. pszServerId : Local server's ID.
  514. pszServerDomain : Local server domain.
  515. pszServerName : Local server name.
  516. pftFileTime : Pointer to FILETIME, local server's last shutdown time.
  517. Returns:
  518. ERROR_SUCCESS or error code.
  519. --*/
  520. {
  521. DWORD dwStatus = ERROR_SUCCESS;
  522. //
  523. // Create a CAnnounce Server work.
  524. //
  525. ANNOUNCESERVERWO AnnounceLs;
  526. memset(&AnnounceLs, 0, sizeof(AnnounceLs));
  527. AnnounceLs.dwStructVersion = CURRENT_ANNOUNCETOESERVEWO_STRUCT_VER;
  528. AnnounceLs.dwStructSize = sizeof(ANNOUNCETOESERVERWO);
  529. AnnounceLs.dwRetryTimes = 0;
  530. SAFESTRCPY(AnnounceLs.m_szServerId, pszServerId);
  531. SAFESTRCPY(AnnounceLs.m_szServerName, pszServerName);
  532. SAFESTRCPY(AnnounceLs.m_szScope, pszServerDomain);
  533. AnnounceLs.m_ftLastShutdownTime = *pftFileTime;
  534. CAnnounceLserver* pAnnounceWO = NULL;
  535. pAnnounceWO = new CAnnounceLserver(
  536. TRUE,
  537. &AnnounceLs,
  538. sizeof(ANNOUNCETOESERVERWO)
  539. );
  540. //
  541. // Set work default interval/retry times
  542. //
  543. // Don't take other parameter for Announce Server
  544. // TLSWorkManagerSetJobDefaults(pAnnounceWO);
  545. dwStatus = TLSWorkManagerSchedule(0, pAnnounceWO);
  546. if(dwStatus != ERROR_SUCCESS)
  547. {
  548. TLSLogEvent(
  549. EVENTLOG_ERROR_TYPE,
  550. TLS_E_WORKMANAGERGENERAL,
  551. TLS_E_WORKMANAGER_SCHEDULEJOB,
  552. dwStatus
  553. );
  554. delete pAnnounceWO;
  555. }
  556. return dwStatus;
  557. }
  558. ////////////////////////////////////////////////////////////////
  559. DWORD
  560. TLSPostReturnClientLicenseJob(
  561. IN PLICENSEDPRODUCT pLicProduct
  562. )
  563. /*++
  564. Abstract:
  565. Create a return license work object and post it to work manager.
  566. Parameters:
  567. pLicProduct : Licensed product to be return/revoke...
  568. Returns:
  569. ERROR_SUCCESS or error success.
  570. Remark:
  571. Return license is a persistent job.
  572. --*/
  573. {
  574. DWORD dwStatus = ERROR_SUCCESS;
  575. RETURNLICENSEWO retlic;
  576. CReturnLicense* pReturnLicenseWO = NULL;
  577. //---------------------------------------------------------------
  578. if( pLicProduct == NULL || pLicProduct->pLicensedVersion == NULL ||
  579. pLicProduct->LicensedProduct.cbEncryptedHwid >= sizeof(retlic.pbEncryptedHwid) )
  580. {
  581. TLSASSERT(FALSE);
  582. SetLastError(dwStatus = ERROR_INVALID_DATA);
  583. goto cleanup;
  584. }
  585. memset(&retlic, 0, sizeof(retlic));
  586. retlic.dwStructVersion = CURRENT_RETURNLICENSEWO_STRUCT_VER;
  587. retlic.dwStructSize = sizeof(retlic);
  588. retlic.dwNumRetry = 0;
  589. SAFESTRCPY(retlic.szTargetServerId, pLicProduct->szIssuerId);
  590. SAFESTRCPY(retlic.szTargetServerName, pLicProduct->szIssuer);
  591. retlic.dwQuantity = pLicProduct->dwQuantity;
  592. retlic.dwKeyPackId = pLicProduct->ulSerialNumber.HighPart;
  593. retlic.dwLicenseId = pLicProduct->ulSerialNumber.LowPart;
  594. retlic.dwReturnReason = LICENSERETURN_UPGRADE;
  595. retlic.dwPlatformId = pLicProduct->LicensedProduct.dwPlatformID;
  596. retlic.cbEncryptedHwid = pLicProduct->LicensedProduct.cbEncryptedHwid;
  597. memcpy(
  598. retlic.pbEncryptedHwid,
  599. pLicProduct->LicensedProduct.pbEncryptedHwid,
  600. pLicProduct->LicensedProduct.cbEncryptedHwid
  601. );
  602. retlic.dwProductVersion = MAKELONG(
  603. pLicProduct->pLicensedVersion->wMinorVersion,
  604. pLicProduct->pLicensedVersion->wMajorVersion
  605. );
  606. memcpy(
  607. retlic.szOrgProductID,
  608. pLicProduct->pbOrgProductID,
  609. min(sizeof(retlic.szOrgProductID) - sizeof(TCHAR), pLicProduct->cbOrgProductID)
  610. );
  611. memcpy(
  612. retlic.szCompanyName,
  613. pLicProduct->LicensedProduct.pProductInfo->pbCompanyName,
  614. min(sizeof(retlic.szCompanyName)-sizeof(TCHAR), pLicProduct->LicensedProduct.pProductInfo->cbCompanyName)
  615. );
  616. memcpy(
  617. retlic.szProductId,
  618. pLicProduct->LicensedProduct.pProductInfo->pbProductID,
  619. min(sizeof(retlic.szProductId)-sizeof(TCHAR), pLicProduct->LicensedProduct.pProductInfo->cbProductID)
  620. );
  621. lstrcpy(
  622. retlic.szUserName,
  623. pLicProduct->szLicensedUser
  624. );
  625. lstrcpy(
  626. retlic.szMachineName,
  627. pLicProduct->szLicensedClient
  628. );
  629. pReturnLicenseWO = new CReturnLicense(
  630. TRUE,
  631. &retlic,
  632. sizeof(retlic)
  633. );
  634. //
  635. // Set work default interval/retry times
  636. //
  637. // Don't take other parameter for Announce Server
  638. // TLSWorkManagerSetJobDefaults(pAnnounceWO);
  639. dwStatus = TLSWorkManagerSchedule(0, pReturnLicenseWO);
  640. if(dwStatus != ERROR_SUCCESS)
  641. {
  642. TLSLogEvent(
  643. EVENTLOG_ERROR_TYPE,
  644. TLS_E_WORKMANAGERGENERAL,
  645. TLS_E_WORKMANAGER_SCHEDULEJOB,
  646. dwStatus
  647. );
  648. }
  649. //
  650. // Work storage will make a copy of this job so we need
  651. // to delete it.
  652. //
  653. delete pReturnLicenseWO;
  654. cleanup:
  655. return dwStatus;
  656. }