Source code of Windows XP (NT5)
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.

2371 lines
56 KiB

  1. /*
  2. File: rasaaaa.h
  3. The 'remoteaccess aaaa' sub context
  4. 3/2/99
  5. */
  6. #include "precomp.h"
  7. #include "rasaaaa.h"
  8. #include <winsock2.h>
  9. #include <ntlsa.h>
  10. #include <nt.h>
  11. #include <ntrtl.h>
  12. #include <nturtl.h>
  13. // The guid for this context
  14. //
  15. GUID g_RasAaaaGuid = RASAAAA_GUID;
  16. static PWCHAR g_pszServer = NULL;
  17. static DWORD g_dwBuild = 0;
  18. // Stolen from snapin code
  19. //
  20. #define CCHRADIUSSERVER 13
  21. #define PSZRADIUSSERVER L"RADIUSServer."
  22. // The commands supported in this context
  23. //
  24. CMD_ENTRY g_RasAaaaAddCmdTable[] =
  25. {
  26. CREATE_CMD_ENTRY(RASAAAA_ADD_AUTHSERV, RasAaaaHandleAddAuthServ),
  27. CREATE_CMD_ENTRY(RASAAAA_ADD_ACCTSERV, RasAaaaHandleAddAcctServ),
  28. };
  29. CMD_ENTRY g_RasAaaaDelCmdTable[] =
  30. {
  31. CREATE_CMD_ENTRY(RASAAAA_DEL_AUTHSERV, RasAaaaHandleDelAuthServ),
  32. CREATE_CMD_ENTRY(RASAAAA_DEL_ACCTSERV, RasAaaaHandleDelAcctServ),
  33. };
  34. CMD_ENTRY g_RasAaaaSetCmdTable[] =
  35. {
  36. CREATE_CMD_ENTRY(RASAAAA_SET_AUTH, RasAaaaHandleSetAuth),
  37. CREATE_CMD_ENTRY(RASAAAA_SET_ACCT, RasAaaaHandleSetAcct),
  38. CREATE_CMD_ENTRY(RASAAAA_SET_AUTHSERV, RasAaaaHandleSetAuthServ),
  39. CREATE_CMD_ENTRY(RASAAAA_SET_ACCTSERV, RasAaaaHandleSetAcctServ),
  40. };
  41. CMD_ENTRY g_RasAaaaShowCmdTable[] =
  42. {
  43. CREATE_CMD_ENTRY(RASAAAA_SHOW_AUTH, RasAaaaHandleShowAuth),
  44. CREATE_CMD_ENTRY(RASAAAA_SHOW_ACCT, RasAaaaHandleShowAcct),
  45. CREATE_CMD_ENTRY(RASAAAA_SHOW_AUTHSERV, RasAaaaHandleShowAuthServ),
  46. CREATE_CMD_ENTRY(RASAAAA_SHOW_ACCTSERV, RasAaaaHandleShowAcctServ),
  47. };
  48. CMD_GROUP_ENTRY g_RasAaaaCmdGroups[] =
  49. {
  50. CREATE_CMD_GROUP_ENTRY(GROUP_SET, g_RasAaaaSetCmdTable),
  51. CREATE_CMD_GROUP_ENTRY(GROUP_SHOW, g_RasAaaaShowCmdTable),
  52. CREATE_CMD_GROUP_ENTRY(GROUP_ADD, g_RasAaaaAddCmdTable),
  53. CREATE_CMD_GROUP_ENTRY(GROUP_DEL, g_RasAaaaDelCmdTable),
  54. };
  55. ULONG g_ulRasAaaaNumGroups = sizeof(g_RasAaaaCmdGroups)/sizeof(CMD_GROUP_ENTRY);
  56. //
  57. // Registry strings
  58. //
  59. WCHAR pszRegKeyAuth[] =
  60. L"SYSTEM\\CurrentControlSet\\Services\\RemoteAccess\\Authentication\\Providers";
  61. WCHAR pszRegKeyAcct[] =
  62. L"SYSTEM\\CurrentControlSet\\Services\\RemoteAccess\\Accounting\\Providers";
  63. WCHAR pszGuidWinAuth[] = L"{1AA7F841-C7F5-11D0-A376-00C04FC9DA04}";
  64. WCHAR pszGuidRadAuth[] = L"{1AA7F83F-C7F5-11D0-A376-00C04FC9DA04}";
  65. WCHAR pszGuidWinAcct[] = L"{1AA7F846-C7F5-11D0-A376-00C04FC9DA04}";
  66. WCHAR pszGuidRadAcct[] = L"{1AA7F840-C7F5-11D0-A376-00C04FC9DA04}";
  67. WCHAR pszRegValActiveProvider[] = L"ActiveProvider";
  68. WCHAR pszRegKeyServers[] = L"Servers";
  69. WCHAR pszRegValAuthPort[] = L"AuthPort";
  70. WCHAR pszRegValAcctPort[] = L"AcctPort";
  71. WCHAR pszRegValMessage[] = L"EnableAccountingOnOff";
  72. WCHAR pszRegValScore[] = L"Score";
  73. WCHAR pszRegValTimeout[] = L"Timeout";
  74. WCHAR pszRegValSignature[] = L"SendSignature";
  75. //
  76. // Local definitions
  77. //
  78. #define RASAAAA_Auth 0x1
  79. #define RASAAAA_Acct 0x2
  80. #define RASAAAA_Windows 0x10
  81. #define RASAAAA_Radius 0x20
  82. #define RASAAAA_None 0x40
  83. #define RASAAAA_F_Provider 0x1
  84. #define RASAAAA_F_Create 0x2
  85. //
  86. // Structures representing auth/acct servers
  87. //
  88. typedef struct _AAAA_AUTH_SERVER
  89. {
  90. PWCHAR pszName;
  91. PWCHAR pszSecret;
  92. DWORD dwScore;
  93. DWORD dwPort;
  94. DWORD dwTimeout;
  95. DWORD dwSignature;
  96. } RASAAAA_AUTH_SERVER;
  97. typedef struct _AAAA_ACCT_SERVER
  98. {
  99. PWCHAR pszName;
  100. PWCHAR pszSecret;
  101. DWORD dwScore;
  102. DWORD dwPort;
  103. DWORD dwTimeout;
  104. DWORD dwMessages;
  105. } RASAAAA_ACCT_SERVER;
  106. typedef
  107. DWORD
  108. (* RASAAAA_SERVER_ENUM_CB)(
  109. IN PVOID pvServer,
  110. IN HANDLE hData);
  111. typedef struct _AAAA_ENUM_DATA
  112. {
  113. DWORD dwType;
  114. HANDLE hData;
  115. RASAAAA_SERVER_ENUM_CB pEnum;
  116. } RASAAAA_ENUM_DATA;
  117. TOKEN_VALUE g_rgEnumEnableDisable[] =
  118. {
  119. {TOKEN_ENABLED, 1},
  120. {TOKEN_DISABLED, 0}
  121. };
  122. RASMON_CMD_ARG g_pArgsAuth[] =
  123. {
  124. {
  125. RASMONTR_CMD_TYPE_STRING,
  126. {TOKEN_NAME, TRUE, FALSE},
  127. NULL,
  128. 0,
  129. NULL
  130. },
  131. {
  132. RASMONTR_CMD_TYPE_STRING,
  133. {TOKEN_SECRET, FALSE, FALSE},
  134. NULL,
  135. 0,
  136. NULL
  137. },
  138. {
  139. RASMONTR_CMD_TYPE_DWORD,
  140. {TOKEN_INITSCORE, FALSE, FALSE},
  141. NULL,
  142. 0,
  143. NULL
  144. },
  145. {
  146. RASMONTR_CMD_TYPE_DWORD,
  147. {TOKEN_PORT, FALSE, FALSE},
  148. NULL,
  149. 0,
  150. NULL
  151. },
  152. {
  153. RASMONTR_CMD_TYPE_DWORD,
  154. {TOKEN_TIMEOUT, FALSE, FALSE},
  155. NULL,
  156. 0,
  157. NULL
  158. },
  159. {
  160. RASMONTR_CMD_TYPE_ENUM,
  161. {TOKEN_SIGNATURE, FALSE, FALSE},
  162. g_rgEnumEnableDisable,
  163. sizeof(g_rgEnumEnableDisable)/sizeof(*g_rgEnumEnableDisable),
  164. NULL
  165. }
  166. };
  167. RASMON_CMD_ARG g_pArgsAcct[] =
  168. {
  169. {
  170. RASMONTR_CMD_TYPE_STRING,
  171. {TOKEN_NAME, TRUE, FALSE},
  172. NULL,
  173. 0,
  174. NULL
  175. },
  176. {
  177. RASMONTR_CMD_TYPE_STRING,
  178. {TOKEN_SECRET, FALSE, FALSE},
  179. NULL,
  180. 0,
  181. NULL
  182. },
  183. {
  184. RASMONTR_CMD_TYPE_DWORD,
  185. {TOKEN_INITSCORE, FALSE, FALSE},
  186. NULL,
  187. 0,
  188. NULL
  189. },
  190. {
  191. RASMONTR_CMD_TYPE_DWORD,
  192. {TOKEN_PORT, FALSE, FALSE},
  193. NULL,
  194. 0,
  195. NULL
  196. },
  197. {
  198. RASMONTR_CMD_TYPE_DWORD,
  199. {TOKEN_TIMEOUT, FALSE, FALSE},
  200. NULL,
  201. 0,
  202. NULL
  203. },
  204. {
  205. RASMONTR_CMD_TYPE_ENUM,
  206. {TOKEN_MESSAGES, FALSE, FALSE},
  207. g_rgEnumEnableDisable,
  208. sizeof(g_rgEnumEnableDisable)/sizeof(*g_rgEnumEnableDisable),
  209. NULL
  210. }
  211. };
  212. #define g_dwArgsAuthCount (sizeof(g_pArgsAuth) / sizeof(*g_pArgsAuth))
  213. #define g_dwArgsAcctCount (sizeof(g_pArgsAcct) / sizeof(*g_pArgsAcct))
  214. //
  215. // Local prototypes
  216. //
  217. DWORD
  218. RasAaaaServerInit(
  219. IN DWORD dwType,
  220. OUT LPVOID lpvServer);
  221. DWORD
  222. RasAaaaServerCleanup(
  223. IN DWORD dwType,
  224. IN PVOID pvServer);
  225. DWORD
  226. RasAaaaServerAdd(
  227. IN DWORD dwType,
  228. IN PVOID pvServer);
  229. DWORD
  230. RasAaaaServerDelete(
  231. IN DWORD dwType,
  232. IN PVOID pvServer);
  233. DWORD
  234. RasAaaaServerRead(
  235. IN DWORD dwType,
  236. IN PVOID pvServer,
  237. IN HKEY hkServer OPTIONAL);
  238. DWORD
  239. RasAaaaServerWrite(
  240. IN DWORD dwType,
  241. IN PVOID pvServer,
  242. IN HKEY hkServer OPTIONAL,
  243. IN BOOL bInitSecret);
  244. DWORD
  245. RasAaaaServerEnum(
  246. IN DWORD dwType,
  247. IN RASAAAA_SERVER_ENUM_CB pEnum,
  248. IN HANDLE hData);
  249. DWORD
  250. RasAaaaServerKeyOpen(
  251. IN DWORD dwType,
  252. IN DWORD dwFlags,
  253. OUT PHKEY phKey);
  254. DWORD
  255. RasAaaaServerSecretWrite(
  256. IN LPCWSTR pszServer,
  257. IN LPCWSTR pszSecret);
  258. //
  259. // Discovers the current provider
  260. //
  261. DWORD
  262. RasAaaaProviderRead(
  263. IN DWORD dwType,
  264. OUT LPDWORD lpdwProvider)
  265. {
  266. DWORD dwErr = NO_ERROR;
  267. HKEY hkProviders = NULL;
  268. PWCHAR pszGuid = NULL;
  269. do
  270. {
  271. // Show the authentication provider
  272. //
  273. dwErr = RasAaaaServerKeyOpen(
  274. dwType,
  275. RASAAAA_F_Provider,
  276. &hkProviders);
  277. BREAK_ON_DWERR(dwErr);
  278. dwErr = RutlRegReadString(
  279. hkProviders,
  280. pszRegValActiveProvider,
  281. &pszGuid);
  282. BREAK_ON_DWERR(dwErr);
  283. if (pszGuid == NULL)
  284. {
  285. dwErr = ERROR_CAN_NOT_COMPLETE;
  286. break;
  287. }
  288. if (dwType == RASAAAA_Auth)
  289. {
  290. if (lstrcmpi(pszGuid, pszGuidRadAuth) == 0)
  291. {
  292. *lpdwProvider = RASAAAA_Radius;
  293. }
  294. else
  295. {
  296. *lpdwProvider = RASAAAA_Windows;
  297. }
  298. }
  299. else
  300. {
  301. if (lstrcmpi(pszGuid, pszGuidRadAcct) == 0)
  302. {
  303. *lpdwProvider = RASAAAA_Radius;
  304. }
  305. else if (lstrcmpi(pszGuid, pszGuidWinAcct) == 0)
  306. {
  307. *lpdwProvider = RASAAAA_Windows;
  308. }
  309. else
  310. {
  311. *lpdwProvider = RASAAAA_None;
  312. }
  313. }
  314. } while (FALSE);
  315. // Cleanup
  316. //
  317. {
  318. if (hkProviders)
  319. {
  320. RegCloseKey(hkProviders);
  321. }
  322. RutlFree(pszGuid);
  323. }
  324. return dwErr;
  325. }
  326. //
  327. // Looks up the address of a server
  328. //
  329. DWORD
  330. RasAaaaServerLookupAddress(
  331. IN LPCWSTR pszServer,
  332. OUT LPWSTR* ppszAddress)
  333. {
  334. DWORD dwErr = NO_ERROR, dwCount = 0, dwAddr;
  335. struct hostent* pHost;
  336. CHAR pszNameA[512];
  337. WCHAR pszName[512];
  338. do
  339. {
  340. // Convert the host name to ansi
  341. //
  342. dwCount = WideCharToMultiByte(
  343. GetConsoleOutputCP(),
  344. 0,
  345. pszServer,
  346. -1,
  347. pszNameA,
  348. sizeof(pszNameA),
  349. NULL,
  350. NULL);
  351. if (dwCount == 0)
  352. {
  353. dwErr = GetLastError();
  354. break;
  355. }
  356. // Lookup the host
  357. //
  358. pHost = gethostbyname(pszNameA);
  359. if (pHost == NULL)
  360. {
  361. *ppszAddress = RutlStrDup(pszServer);
  362. if (*ppszAddress == NULL)
  363. {
  364. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  365. }
  366. break;
  367. }
  368. // Convert the discovered address to unicode
  369. //
  370. dwAddr = *(PDWORD)(pHost->h_addr_list[0]);
  371. dwCount = MultiByteToWideChar(
  372. GetConsoleOutputCP(),
  373. 0,
  374. inet_ntoa(*(PIN_ADDR)&dwAddr),
  375. -1,
  376. pszName,
  377. sizeof(pszName) / sizeof(WCHAR));
  378. if (dwCount == 0)
  379. {
  380. dwErr = GetLastError();
  381. break;
  382. }
  383. *ppszAddress = RutlStrDup(pszName);
  384. if (*ppszAddress == NULL)
  385. {
  386. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  387. }
  388. } while (FALSE);
  389. // Cleanup
  390. {
  391. }
  392. return dwErr;
  393. }
  394. //
  395. // Populates a server cb with defaults
  396. //
  397. DWORD
  398. RasAaaaServerInit(
  399. IN DWORD dwType,
  400. OUT PVOID pvServer)
  401. {
  402. if (dwType == RASAAAA_Auth)
  403. {
  404. RASAAAA_AUTH_SERVER* pInfo = (RASAAAA_AUTH_SERVER*)pvServer;
  405. pInfo->pszName = NULL;
  406. pInfo->pszSecret = NULL;
  407. pInfo->dwScore = 30;
  408. pInfo->dwPort = 1812;
  409. pInfo->dwTimeout = 5;
  410. pInfo->dwSignature = 0;
  411. }
  412. else
  413. {
  414. RASAAAA_ACCT_SERVER* pInfo = (RASAAAA_ACCT_SERVER*)pvServer;
  415. pInfo->pszName = NULL;
  416. pInfo->pszSecret = NULL;
  417. pInfo->dwScore = 30;
  418. pInfo->dwPort = 1813;
  419. pInfo->dwTimeout = 5;
  420. pInfo->dwMessages = 0;
  421. }
  422. return NO_ERROR;
  423. }
  424. //
  425. // Cleans up a server cb
  426. //
  427. DWORD
  428. RasAaaaServerCleanup(
  429. IN DWORD dwType,
  430. IN PVOID pvServer)
  431. {
  432. if (dwType == RASAAAA_Auth)
  433. {
  434. RASAAAA_AUTH_SERVER* pInfo = (RASAAAA_AUTH_SERVER*)pvServer;
  435. RutlFree(pInfo->pszName);
  436. RutlFree(pInfo->pszSecret);
  437. }
  438. else
  439. {
  440. RASAAAA_ACCT_SERVER* pInfo = (RASAAAA_ACCT_SERVER*)pvServer;
  441. RutlFree(pInfo->pszName);
  442. RutlFree(pInfo->pszSecret);
  443. }
  444. return NO_ERROR;
  445. }
  446. //
  447. // Adds a server
  448. //
  449. DWORD
  450. RasAaaaServerAdd(
  451. IN DWORD dwType,
  452. IN PVOID pvServer)
  453. {
  454. DWORD dwErr = NO_ERROR, dwDisposition;
  455. HKEY hkServers = NULL, hkKey = NULL;
  456. do
  457. {
  458. dwErr = RasAaaaServerKeyOpen(
  459. dwType,
  460. RASAAAA_F_Create,
  461. &hkServers);
  462. BREAK_ON_DWERR(dwErr);
  463. // Create the new key
  464. //
  465. dwErr = RegCreateKeyExW(
  466. hkServers,
  467. *((PWCHAR*)pvServer),
  468. 0,
  469. NULL,
  470. 0,
  471. KEY_ALL_ACCESS,
  472. NULL,
  473. &hkKey,
  474. &dwDisposition);
  475. BREAK_ON_DWERR(dwErr);
  476. if (dwDisposition == REG_OPENED_EXISTING_KEY)
  477. {
  478. dwErr = ERROR_ALREADY_EXISTS;
  479. break;
  480. }
  481. dwErr = RasAaaaServerWrite(dwType, pvServer, hkKey, TRUE);
  482. BREAK_ON_DWERR(dwErr);
  483. } while (FALSE);
  484. // Cleanup
  485. //
  486. {
  487. if (hkServers)
  488. {
  489. RegCloseKey(hkServers);
  490. }
  491. if (hkKey)
  492. {
  493. RegCloseKey(hkKey);
  494. }
  495. }
  496. return dwErr;
  497. }
  498. DWORD
  499. RasAaaaServerDelete(
  500. IN DWORD dwType,
  501. IN PVOID pvServer)
  502. {
  503. DWORD dwErr = NO_ERROR;
  504. HKEY hkServers = NULL;
  505. do
  506. {
  507. dwErr = RasAaaaServerKeyOpen(
  508. dwType,
  509. 0,
  510. &hkServers);
  511. BREAK_ON_DWERR(dwErr);
  512. dwErr = RegDeleteKey(hkServers, *(PWCHAR*)pvServer);
  513. BREAK_ON_DWERR(dwErr);
  514. // Cleanup the shared secret
  515. //
  516. RasAaaaServerSecretWrite(*(PWCHAR*)pvServer, NULL);
  517. } while (FALSE);
  518. // Cleanup
  519. {
  520. if (hkServers)
  521. {
  522. RegCloseKey(hkServers);
  523. }
  524. }
  525. return dwErr;
  526. }
  527. //
  528. // Callback to an enumeration function that deletes the given
  529. // authentication server
  530. //
  531. DWORD
  532. RasAaaaServerDeleteAuthCb(
  533. IN PVOID pvServer,
  534. IN HANDLE hData)
  535. {
  536. return RasAaaaServerDelete(RASAAAA_Auth, pvServer);
  537. }
  538. //
  539. // Callback to an enumeration function that deletes the given
  540. // accounting server
  541. //
  542. DWORD
  543. RasAaaaServerDeleteAcctCb(
  544. IN PVOID pvServer,
  545. IN HANDLE hData)
  546. {
  547. return RasAaaaServerDelete(RASAAAA_Acct, pvServer);
  548. }
  549. //
  550. // Read server info
  551. //
  552. DWORD
  553. RasAaaaServerRead(
  554. IN DWORD dwType,
  555. IN PVOID pvServer,
  556. IN HKEY hkServer OPTIONAL)
  557. {
  558. DWORD dwErr = NO_ERROR;
  559. HKEY hkServers = NULL, hkKey = NULL;
  560. do
  561. {
  562. if (hkServer == NULL)
  563. {
  564. dwErr = RasAaaaServerKeyOpen(
  565. dwType,
  566. 0,
  567. &hkServers);
  568. BREAK_ON_DWERR(dwErr);
  569. dwErr = RegOpenKeyEx(
  570. hkServers,
  571. *(PWCHAR*)pvServer,
  572. 0,
  573. KEY_ALL_ACCESS,
  574. &hkKey);
  575. BREAK_ON_DWERR(dwErr);
  576. }
  577. else
  578. {
  579. hkKey = hkServer;
  580. }
  581. if (dwType == RASAAAA_Auth)
  582. {
  583. RASAAAA_AUTH_SERVER* pInfo = (RASAAAA_AUTH_SERVER*)pvServer;
  584. dwErr = RutlRegReadDword(
  585. hkKey,
  586. pszRegValScore,
  587. &pInfo->dwScore);
  588. BREAK_ON_DWERR(dwErr);
  589. dwErr = RutlRegReadDword(
  590. hkKey,
  591. pszRegValAuthPort,
  592. &pInfo->dwPort);
  593. BREAK_ON_DWERR(dwErr);
  594. dwErr = RutlRegReadDword(
  595. hkKey,
  596. pszRegValTimeout,
  597. &pInfo->dwTimeout);
  598. BREAK_ON_DWERR(dwErr);
  599. dwErr = RutlRegReadDword(
  600. hkKey,
  601. pszRegValSignature,
  602. &pInfo->dwSignature);
  603. BREAK_ON_DWERR(dwErr);
  604. }
  605. else
  606. {
  607. RASAAAA_ACCT_SERVER* pInfo = (RASAAAA_ACCT_SERVER*)pvServer;
  608. dwErr = RutlRegReadDword(
  609. hkKey,
  610. pszRegValScore,
  611. &pInfo->dwScore);
  612. BREAK_ON_DWERR(dwErr);
  613. dwErr = RutlRegReadDword(
  614. hkKey,
  615. pszRegValAcctPort,
  616. &pInfo->dwPort);
  617. BREAK_ON_DWERR(dwErr);
  618. dwErr = RutlRegReadDword(
  619. hkKey,
  620. pszRegValTimeout,
  621. &pInfo->dwTimeout);
  622. BREAK_ON_DWERR(dwErr);
  623. dwErr = RutlRegReadDword(
  624. hkKey,
  625. pszRegValMessage,
  626. &pInfo->dwMessages);
  627. BREAK_ON_DWERR(dwErr);
  628. }
  629. } while (FALSE);
  630. // Cleanup
  631. //
  632. {
  633. if (hkServers)
  634. {
  635. RegCloseKey(hkServers);
  636. }
  637. if (hkKey && hkServer == NULL)
  638. {
  639. RegCloseKey(hkKey);
  640. }
  641. }
  642. return dwErr;
  643. }
  644. //
  645. // Write server info
  646. //
  647. DWORD
  648. RasAaaaServerWrite(
  649. IN DWORD dwType,
  650. IN PVOID pvServer,
  651. IN HKEY hkServer, OPTIONAL
  652. IN BOOL bInitSecret)
  653. {
  654. DWORD dwErr = NO_ERROR;
  655. HKEY hkServers = NULL, hkKey = NULL;
  656. do
  657. {
  658. if (hkServer == NULL)
  659. {
  660. dwErr = RasAaaaServerKeyOpen(
  661. dwType,
  662. 0,
  663. &hkServers);
  664. BREAK_ON_DWERR(dwErr);
  665. dwErr = RegOpenKeyEx(
  666. hkServers,
  667. *(PWCHAR*)pvServer,
  668. 0,
  669. KEY_ALL_ACCESS,
  670. &hkKey);
  671. BREAK_ON_DWERR(dwErr);
  672. }
  673. else
  674. {
  675. hkKey = hkServer;
  676. }
  677. if (dwType == RASAAAA_Auth)
  678. {
  679. RASAAAA_AUTH_SERVER* pInfo = (RASAAAA_AUTH_SERVER*)pvServer;
  680. dwErr = RutlRegWriteDword(
  681. hkKey,
  682. pszRegValScore,
  683. pInfo->dwScore);
  684. BREAK_ON_DWERR(dwErr);
  685. dwErr = RutlRegWriteDword(
  686. hkKey,
  687. pszRegValAuthPort,
  688. pInfo->dwPort);
  689. BREAK_ON_DWERR(dwErr);
  690. dwErr = RutlRegWriteDword(
  691. hkKey,
  692. pszRegValTimeout,
  693. pInfo->dwTimeout);
  694. BREAK_ON_DWERR(dwErr);
  695. dwErr = RutlRegWriteDword(
  696. hkKey,
  697. pszRegValSignature,
  698. pInfo->dwSignature);
  699. BREAK_ON_DWERR(dwErr);
  700. if (pInfo->pszSecret)
  701. {
  702. dwErr = RasAaaaServerSecretWrite(
  703. pInfo->pszName,
  704. pInfo->pszSecret);
  705. BREAK_ON_DWERR(dwErr);
  706. }
  707. else if (bInitSecret)
  708. {
  709. dwErr = RasAaaaServerSecretWrite(
  710. pInfo->pszName,
  711. L"");
  712. BREAK_ON_DWERR(dwErr);
  713. }
  714. }
  715. else
  716. {
  717. RASAAAA_ACCT_SERVER* pInfo = (RASAAAA_ACCT_SERVER*)pvServer;
  718. dwErr = RutlRegWriteDword(
  719. hkKey,
  720. pszRegValScore,
  721. pInfo->dwScore);
  722. BREAK_ON_DWERR(dwErr);
  723. dwErr = RutlRegWriteDword(
  724. hkKey,
  725. pszRegValAcctPort,
  726. pInfo->dwPort);
  727. BREAK_ON_DWERR(dwErr);
  728. dwErr = RutlRegWriteDword(
  729. hkKey,
  730. pszRegValTimeout,
  731. pInfo->dwTimeout);
  732. BREAK_ON_DWERR(dwErr);
  733. dwErr = RutlRegWriteDword(
  734. hkKey,
  735. pszRegValMessage,
  736. pInfo->dwMessages);
  737. BREAK_ON_DWERR(dwErr);
  738. if (pInfo->pszSecret)
  739. {
  740. dwErr = RasAaaaServerSecretWrite(
  741. pInfo->pszName,
  742. pInfo->pszSecret);
  743. BREAK_ON_DWERR(dwErr);
  744. }
  745. else if (bInitSecret)
  746. {
  747. dwErr = RasAaaaServerSecretWrite(
  748. pInfo->pszName,
  749. L"");
  750. BREAK_ON_DWERR(dwErr);
  751. }
  752. }
  753. } while (FALSE);
  754. // Cleanup
  755. {
  756. if (hkServers)
  757. {
  758. RegCloseKey(hkServers);
  759. }
  760. if (hkKey && hkServer == NULL)
  761. {
  762. RegCloseKey(hkKey);
  763. }
  764. }
  765. return dwErr;
  766. }
  767. //
  768. // Callback function for registry enumerator
  769. //
  770. DWORD
  771. RasAaaaServerEnumCb(
  772. IN LPCWSTR pszName,
  773. IN HKEY hKey,
  774. IN HANDLE hData)
  775. {
  776. RASAAAA_ENUM_DATA* pData = (RASAAAA_ENUM_DATA*)hData;
  777. RASAAAA_AUTH_SERVER AuthServer;
  778. RASAAAA_ACCT_SERVER AcctServer;
  779. DWORD dwErr = NO_ERROR;
  780. ZeroMemory(&AuthServer, sizeof(AuthServer));
  781. ZeroMemory(&AcctServer, sizeof(AcctServer));
  782. do
  783. {
  784. if (pData->dwType == RASAAAA_Auth)
  785. {
  786. AuthServer.pszName = RutlStrDup(pszName);
  787. dwErr = RasAaaaServerRead(
  788. pData->dwType,
  789. (PVOID)&AuthServer,
  790. hKey);
  791. BREAK_ON_DWERR(dwErr);
  792. dwErr = pData->pEnum((PVOID)&AuthServer, pData->hData);
  793. BREAK_ON_DWERR(dwErr);
  794. }
  795. else
  796. {
  797. AcctServer.pszName = RutlStrDup(pszName);
  798. dwErr = RasAaaaServerRead(
  799. pData->dwType,
  800. (PVOID)&AcctServer,
  801. hKey);
  802. BREAK_ON_DWERR(dwErr);
  803. dwErr = pData->pEnum((PVOID)&AcctServer, pData->hData);
  804. BREAK_ON_DWERR(dwErr);
  805. }
  806. } while (FALSE);
  807. // Cleanup
  808. //
  809. {
  810. RasAaaaServerCleanup(
  811. pData->dwType,
  812. (pData->dwType == RASAAAA_Auth) ?
  813. (PVOID)&AuthServer :
  814. (PVOID)&AcctServer);
  815. }
  816. return dwErr;
  817. }
  818. //
  819. // Enumerates the servers
  820. //
  821. DWORD
  822. RasAaaaServerEnum(
  823. IN DWORD dwType,
  824. IN RASAAAA_SERVER_ENUM_CB pEnum,
  825. IN HANDLE hData)
  826. {
  827. DWORD dwErr = NO_ERROR;
  828. HKEY hkServers = NULL;
  829. RASAAAA_ENUM_DATA EnumData;
  830. do
  831. {
  832. ZeroMemory(&EnumData, sizeof(EnumData));
  833. dwErr = RasAaaaServerKeyOpen(
  834. dwType,
  835. 0,
  836. &hkServers);
  837. if (dwErr == ERROR_FILE_NOT_FOUND)
  838. {
  839. dwErr = NO_ERROR;
  840. break;
  841. }
  842. BREAK_ON_DWERR(dwErr);
  843. EnumData.dwType = dwType;
  844. EnumData.pEnum = pEnum;
  845. EnumData.hData = hData;
  846. dwErr = RutlRegEnumKeys(
  847. hkServers,
  848. RasAaaaServerEnumCb,
  849. (HANDLE)&EnumData);
  850. BREAK_ON_DWERR(dwErr);
  851. } while (FALSE);
  852. // Cleanup
  853. //
  854. {
  855. if (hkServers)
  856. {
  857. RegCloseKey(hkServers);
  858. }
  859. }
  860. return dwErr;
  861. }
  862. //
  863. // Opens the appropriate registry key
  864. //
  865. DWORD
  866. RasAaaaServerKeyOpen(
  867. IN DWORD dwType,
  868. IN DWORD dwFlags,
  869. OUT PHKEY phKey)
  870. {
  871. HKEY hkRoot = NULL, hkProvider = NULL;
  872. DWORD dwErr = NO_ERROR;
  873. do
  874. {
  875. dwErr = RegOpenKeyEx(
  876. g_pServerInfo->hkMachine,
  877. (dwType == RASAAAA_Auth) ? pszRegKeyAuth : pszRegKeyAcct,
  878. 0,
  879. KEY_ALL_ACCESS,
  880. &hkRoot);
  881. BREAK_ON_DWERR(dwErr);
  882. if (dwFlags & RASAAAA_F_Provider)
  883. {
  884. *phKey = hkRoot;
  885. break;
  886. }
  887. dwErr = RegOpenKeyEx(
  888. hkRoot,
  889. (dwType == RASAAAA_Auth) ? pszGuidRadAuth : pszGuidRadAcct,
  890. 0,
  891. KEY_ALL_ACCESS,
  892. &hkProvider);
  893. BREAK_ON_DWERR(dwErr);
  894. if (dwFlags & RASAAAA_F_Create)
  895. {
  896. DWORD dwDisposition;
  897. dwErr = RegCreateKeyExW(
  898. hkProvider,
  899. pszRegKeyServers,
  900. 0,
  901. NULL,
  902. REG_OPTION_NON_VOLATILE,
  903. KEY_ALL_ACCESS,
  904. NULL,
  905. phKey,
  906. &dwDisposition);
  907. BREAK_ON_DWERR(dwErr);
  908. }
  909. else
  910. {
  911. dwErr = RegOpenKeyExW(
  912. hkProvider,
  913. pszRegKeyServers,
  914. 0,
  915. KEY_ALL_ACCESS,
  916. phKey);
  917. BREAK_ON_DWERR(dwErr);
  918. }
  919. } while (FALSE);
  920. // Cleanup
  921. {
  922. if (hkRoot && !(dwFlags & RASAAAA_F_Provider))
  923. {
  924. RegCloseKey(hkRoot);
  925. }
  926. if (hkProvider)
  927. {
  928. RegCloseKey(hkProvider);
  929. }
  930. if (dwErr != NO_ERROR)
  931. {
  932. if (*phKey)
  933. {
  934. RegCloseKey(*phKey);
  935. }
  936. *phKey = NULL;
  937. }
  938. }
  939. return dwErr;
  940. }
  941. //
  942. // Saves a shared secret
  943. //
  944. DWORD
  945. RasAaaaServerSecretWrite(
  946. IN LPCWSTR pszRadiusServerName,
  947. IN LPCWSTR pszSecret)
  948. {
  949. LSA_HANDLE hLSA = NULL;
  950. NTSTATUS ntStatus;
  951. LSA_OBJECT_ATTRIBUTES objectAttributes;
  952. LSA_UNICODE_STRING LSAPrivData, LSAPrivDataDesc;
  953. TCHAR tszPrivData[MAX_PATH+1],
  954. tszPrivDataDesc[MAX_PATH+CCHRADIUSSERVER+1];
  955. TCHAR * ptszTemp;
  956. PUNICODE_STRING pSystem;
  957. UNICODE_STRING uszSystemName;
  958. pSystem = NULL;
  959. InitializeObjectAttributes(&objectAttributes, NULL, 0, NULL, NULL);
  960. ntStatus = LsaOpenPolicy(
  961. pSystem,
  962. &objectAttributes,
  963. POLICY_ALL_ACCESS,
  964. &hLSA);
  965. if ( !NT_SUCCESS( ntStatus) )
  966. {
  967. return( RtlNtStatusToDosError( ntStatus ) );
  968. }
  969. ZeroMemory(tszPrivDataDesc, sizeof(tszPrivDataDesc));
  970. lstrcpy(tszPrivDataDesc, PSZRADIUSSERVER);
  971. lstrcpyn(tszPrivDataDesc + CCHRADIUSSERVER, pszRadiusServerName, MAX_PATH);
  972. LSAPrivDataDesc.Length = (USHORT)((lstrlen(tszPrivDataDesc) + 1) * sizeof(TCHAR));
  973. LSAPrivDataDesc.MaximumLength = sizeof(tszPrivDataDesc);
  974. LSAPrivDataDesc.Buffer = tszPrivDataDesc;
  975. ZeroMemory(tszPrivData, sizeof(tszPrivData));
  976. if (pszSecret)
  977. {
  978. lstrcpyn(tszPrivData, pszSecret, MAX_PATH);
  979. LSAPrivData.Length = (USHORT)(lstrlen(tszPrivData) * sizeof(TCHAR));
  980. LSAPrivData.MaximumLength = sizeof(tszPrivData);
  981. LSAPrivData.Buffer = tszPrivData;
  982. }
  983. else
  984. {
  985. LSAPrivData.Length = 0;
  986. LSAPrivData.MaximumLength = 0;
  987. LSAPrivData.Buffer = NULL;
  988. }
  989. ntStatus = LsaStorePrivateData(hLSA, &LSAPrivDataDesc, &LSAPrivData);
  990. ZeroMemory( tszPrivData, sizeof( tszPrivData ) );
  991. LsaClose(hLSA);
  992. return( RtlNtStatusToDosError( ntStatus ) );
  993. }
  994. //
  995. // Displays the given server
  996. //
  997. DWORD
  998. RasAaaaServerAuthShow(
  999. IN PVOID pvServer,
  1000. IN HANDLE hData)
  1001. {
  1002. DWORD dwErr = NO_ERROR;
  1003. RASAAAA_AUTH_SERVER* pServer = (RASAAAA_AUTH_SERVER*)pvServer;
  1004. PWCHAR pszAddress = NULL;
  1005. BOOL* pDumpFmt = (BOOL*)hData;
  1006. PWCHAR pszPort = NULL, pszScore = NULL, pszTimeout = NULL,
  1007. pszName = NULL, pszSig = NULL;
  1008. do
  1009. {
  1010. if (!pDumpFmt || *pDumpFmt == FALSE)
  1011. {
  1012. // Lookup the address
  1013. //
  1014. dwErr = RasAaaaServerLookupAddress(pServer->pszName, &pszAddress);
  1015. BREAK_ON_DWERR(dwErr);
  1016. DisplayMessage(
  1017. g_hModule,
  1018. MSG_RASAAAA_SHOW_AUTHSERV,
  1019. pServer->pszName,
  1020. pszAddress,
  1021. pServer->dwPort,
  1022. pServer->dwScore,
  1023. pServer->dwTimeout,
  1024. (pServer->dwSignature) ? TOKEN_ENABLED : TOKEN_DISABLED);
  1025. }
  1026. else
  1027. {
  1028. // Make assignment strings
  1029. //
  1030. pszPort = RutlAssignmentFromTokenAndDword(
  1031. g_hModule,
  1032. TOKEN_PORT,
  1033. pServer->dwPort,
  1034. 10);
  1035. pszScore = RutlAssignmentFromTokenAndDword(
  1036. g_hModule,
  1037. TOKEN_INITSCORE,
  1038. pServer->dwScore,
  1039. 10);
  1040. pszTimeout = RutlAssignmentFromTokenAndDword(
  1041. g_hModule,
  1042. TOKEN_TIMEOUT,
  1043. pServer->dwTimeout,
  1044. 10);
  1045. pszName = RutlAssignmentFromTokens(
  1046. g_hModule,
  1047. TOKEN_NAME,
  1048. pServer->pszName);
  1049. pszSig = RutlAssignmentFromTokens(
  1050. g_hModule,
  1051. TOKEN_SIGNATURE,
  1052. (pServer->dwSignature) ?
  1053. TOKEN_ENABLED :
  1054. TOKEN_DISABLED);
  1055. if (!pszPort || !pszScore || !pszTimeout || !pszName || !pszSig)
  1056. {
  1057. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  1058. break;
  1059. }
  1060. // Display the command
  1061. //
  1062. DisplayMessage(
  1063. g_hModule,
  1064. MSG_RASAAAA_CMD5,
  1065. DMP_RASAAAA_ADD_AUTHSERV,
  1066. pszName,
  1067. pszPort,
  1068. pszScore,
  1069. pszTimeout,
  1070. pszSig);
  1071. }
  1072. } while (FALSE);
  1073. // Cleanup
  1074. {
  1075. RutlFree(pszAddress);
  1076. RutlFree(pszName);
  1077. RutlFree(pszPort);
  1078. RutlFree(pszScore);
  1079. RutlFree(pszTimeout);
  1080. RutlFree(pszSig);
  1081. }
  1082. return dwErr;
  1083. }
  1084. //
  1085. // Displays the given server
  1086. //
  1087. DWORD
  1088. RasAaaaServerAcctShow(
  1089. IN PVOID pvServer,
  1090. IN HANDLE hData)
  1091. {
  1092. DWORD dwErr = NO_ERROR;
  1093. RASAAAA_ACCT_SERVER* pServer = (RASAAAA_ACCT_SERVER*)pvServer;
  1094. PWCHAR pszAddress = NULL;
  1095. PWCHAR pszPort = NULL, pszScore = NULL, pszTimeout = NULL,
  1096. pszName = NULL, pszMsg = NULL;
  1097. BOOL* pDumpFmt = (BOOL*)hData;
  1098. do
  1099. {
  1100. if (!pDumpFmt || *pDumpFmt == FALSE)
  1101. {
  1102. // Lookup the address
  1103. //
  1104. dwErr = RasAaaaServerLookupAddress(pServer->pszName, &pszAddress);
  1105. BREAK_ON_DWERR(dwErr);
  1106. DisplayMessage(
  1107. g_hModule,
  1108. MSG_RASAAAA_SHOW_AUTHSERV,
  1109. pServer->pszName,
  1110. pszAddress,
  1111. pServer->dwPort,
  1112. pServer->dwScore,
  1113. pServer->dwTimeout,
  1114. (pServer->dwMessages) ? TOKEN_ENABLED : TOKEN_DISABLED);
  1115. }
  1116. else
  1117. {
  1118. // Make assignment strings
  1119. //
  1120. pszPort = RutlAssignmentFromTokenAndDword(
  1121. g_hModule,
  1122. TOKEN_PORT,
  1123. pServer->dwPort,
  1124. 10);
  1125. pszScore = RutlAssignmentFromTokenAndDword(
  1126. g_hModule,
  1127. TOKEN_INITSCORE,
  1128. pServer->dwScore,
  1129. 10);
  1130. pszTimeout = RutlAssignmentFromTokenAndDword(
  1131. g_hModule,
  1132. TOKEN_TIMEOUT,
  1133. pServer->dwTimeout,
  1134. 10);
  1135. pszName = RutlAssignmentFromTokens(
  1136. g_hModule,
  1137. TOKEN_NAME,
  1138. pServer->pszName);
  1139. pszMsg = RutlAssignmentFromTokens(
  1140. g_hModule,
  1141. TOKEN_MESSAGES,
  1142. (pServer->dwMessages) ?
  1143. TOKEN_ENABLED :
  1144. TOKEN_DISABLED);
  1145. if (!pszPort || !pszScore || !pszTimeout || !pszName || !pszMsg)
  1146. {
  1147. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  1148. break;
  1149. }
  1150. // Display the command
  1151. //
  1152. DisplayMessage(
  1153. g_hModule,
  1154. MSG_RASAAAA_CMD5,
  1155. DMP_RASAAAA_ADD_ACCTSERV,
  1156. pszName,
  1157. pszPort,
  1158. pszScore,
  1159. pszTimeout,
  1160. pszMsg);
  1161. }
  1162. } while (FALSE);
  1163. // Cleanup
  1164. {
  1165. RutlFree(pszAddress);
  1166. RutlFree(pszName);
  1167. RutlFree(pszPort);
  1168. RutlFree(pszScore);
  1169. RutlFree(pszTimeout);
  1170. RutlFree(pszMsg);
  1171. }
  1172. return dwErr;
  1173. }
  1174. //
  1175. // Entry called by rasmontr to register this context
  1176. //
  1177. DWORD
  1178. WINAPI
  1179. RasAaaaStartHelper(
  1180. IN CONST GUID *pguidParent,
  1181. IN DWORD dwVersion)
  1182. {
  1183. DWORD dwErr = NO_ERROR;
  1184. NS_CONTEXT_ATTRIBUTES attMyAttributes;
  1185. // Initialize
  1186. //
  1187. ZeroMemory(&attMyAttributes, sizeof(attMyAttributes));
  1188. attMyAttributes.pwszContext = L"aaaa";
  1189. attMyAttributes.guidHelper = g_RasAaaaGuid;
  1190. attMyAttributes.dwVersion = RASAAAA_VERSION;
  1191. attMyAttributes.dwFlags = 0;
  1192. attMyAttributes.ulNumTopCmds= 0;
  1193. attMyAttributes.pTopCmds = NULL;
  1194. attMyAttributes.ulNumGroups = g_ulRasAaaaNumGroups;
  1195. attMyAttributes.pCmdGroups = (CMD_GROUP_ENTRY (*)[])&g_RasAaaaCmdGroups;
  1196. attMyAttributes.pfnDumpFn = RasAaaaDump;
  1197. dwErr = RegisterContext( &attMyAttributes );
  1198. return dwErr;
  1199. }
  1200. DWORD
  1201. WINAPI
  1202. RasAaaaDump(
  1203. IN LPCWSTR pwszRouter,
  1204. IN OUT LPWSTR *ppwcArguments,
  1205. IN DWORD dwArgCount,
  1206. IN LPCVOID pvData
  1207. )
  1208. {
  1209. DWORD dwErr = NO_ERROR, dwProvider;
  1210. PWCHAR pszCmd = NULL, pszToken = NULL;
  1211. BOOL bDumpFmt;
  1212. // Dump the header
  1213. //
  1214. DisplayMessage(g_hModule, MSG_RASAAAA_SCRIPTHEADER);
  1215. DisplayMessageT(DMP_RASAAAA_PUSHD);
  1216. do
  1217. {
  1218. // Dump the commands to set the correct authentication and
  1219. // accounting providers
  1220. //
  1221. dwErr = RasAaaaProviderRead(RASAAAA_Auth, &dwProvider);
  1222. BREAK_ON_DWERR(dwErr);
  1223. pszCmd = RutlAssignmentFromTokens(
  1224. g_hModule,
  1225. TOKEN_PROVIDER,
  1226. (dwProvider == RASAAAA_Windows) ?
  1227. TOKEN_WINDOWS :
  1228. TOKEN_RADIUS);
  1229. if (pszCmd == NULL)
  1230. {
  1231. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  1232. break;
  1233. }
  1234. DisplayMessage(
  1235. g_hModule,
  1236. MSG_RASAAAA_CMD1,
  1237. DMP_RASAAAA_SET_AUTH,
  1238. pszCmd);
  1239. RutlFree(pszCmd);
  1240. dwErr = RasAaaaProviderRead(RASAAAA_Acct, &dwProvider);
  1241. BREAK_ON_DWERR(dwErr);
  1242. if (dwProvider == RASAAAA_Windows)
  1243. {
  1244. pszToken = (PWCHAR)TOKEN_WINDOWS;
  1245. }
  1246. else if (dwProvider == RASAAAA_Radius)
  1247. {
  1248. pszToken = (PWCHAR)TOKEN_RADIUS;
  1249. }
  1250. else
  1251. {
  1252. pszToken = (PWCHAR)TOKEN_NONE;
  1253. }
  1254. pszCmd = RutlAssignmentFromTokens(
  1255. g_hModule,
  1256. TOKEN_PROVIDER,
  1257. pszToken);
  1258. if (pszCmd == NULL)
  1259. {
  1260. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  1261. break;
  1262. }
  1263. DisplayMessage(
  1264. g_hModule,
  1265. MSG_RASAAAA_CMD1,
  1266. DMP_RASAAAA_SET_ACCT,
  1267. pszCmd);
  1268. RutlFree(pszCmd);
  1269. DisplayMessageT(MSG_NEWLINE);
  1270. // Dump the commands to delete all of the current servers
  1271. //
  1272. pszCmd = RutlAssignmentFromTokens(
  1273. g_hModule,
  1274. TOKEN_NAME,
  1275. TOKEN_RASAAAA_ALLSERVERS);
  1276. if (pszCmd == NULL)
  1277. {
  1278. dwErr = ERROR_NOT_ENOUGH_MEMORY;
  1279. break;
  1280. }
  1281. DisplayMessage(
  1282. g_hModule,
  1283. MSG_RASAAAA_CMD1,
  1284. DMP_RASAAAA_DEL_AUTHSERV,
  1285. pszCmd);
  1286. DisplayMessage(
  1287. g_hModule,
  1288. MSG_RASAAAA_CMD1,
  1289. DMP_RASAAAA_DEL_ACCTSERV,
  1290. pszCmd);
  1291. RutlFree(pszCmd);
  1292. DisplayMessageT(MSG_NEWLINE);
  1293. // Dump commands to add all of the current auth servers
  1294. //
  1295. bDumpFmt = TRUE;
  1296. dwErr = RasAaaaServerEnum(
  1297. RASAAAA_Auth,
  1298. RasAaaaServerAuthShow,
  1299. (HANDLE)&bDumpFmt);
  1300. BREAK_ON_DWERR(dwErr);
  1301. DisplayMessageT(MSG_NEWLINE);
  1302. // Dump commands to add all of the accouting servers
  1303. //
  1304. dwErr = RasAaaaServerEnum(
  1305. RASAAAA_Acct,
  1306. RasAaaaServerAcctShow,
  1307. (HANDLE)&bDumpFmt);
  1308. BREAK_ON_DWERR(dwErr);
  1309. } while (FALSE);
  1310. // Dump the footer
  1311. DisplayMessageT(DMP_RASAAAA_POPD);
  1312. DisplayMessage(g_hModule, MSG_RASAAAA_SCRIPTFOOTER);
  1313. // Cleanup
  1314. {
  1315. }
  1316. return dwErr;
  1317. }
  1318. DWORD
  1319. RasAaaaHandleAddAuthServ(
  1320. IN LPCWSTR pwszMachine,
  1321. IN OUT LPWSTR *ppwcArguments,
  1322. IN DWORD dwCurrentIndex,
  1323. IN DWORD dwArgCount,
  1324. IN DWORD dwFlags,
  1325. IN LPCVOID pvData,
  1326. OUT BOOL *pbDone
  1327. )
  1328. {
  1329. DWORD dwErr = NO_ERROR;
  1330. RASAAAA_AUTH_SERVER Server;
  1331. RASMON_CMD_ARG pArgs[g_dwArgsAuthCount];
  1332. // Initialize
  1333. CopyMemory(pArgs, g_pArgsAuth, sizeof(g_pArgsAuth));
  1334. do
  1335. {
  1336. dwErr = RasAaaaServerInit(RASAAAA_Auth, (PVOID)&Server);
  1337. BREAK_ON_DWERR(dwErr);
  1338. // Parse the command line
  1339. //
  1340. dwErr = RutlParse(
  1341. ppwcArguments,
  1342. dwCurrentIndex,
  1343. dwArgCount,
  1344. pbDone,
  1345. pArgs,
  1346. sizeof(pArgs)/sizeof(*pArgs));
  1347. BREAK_ON_DWERR( dwErr );
  1348. Server.pszName = RASMON_CMD_ARG_GetPsz(pArgs + 0);
  1349. Server.pszSecret = RASMON_CMD_ARG_GetPsz(pArgs + 1);
  1350. if (RASMON_CMD_ARG_Present(pArgs + 2))
  1351. {
  1352. Server.dwScore = RASMON_CMD_ARG_GetDword(pArgs + 2);
  1353. }
  1354. if (RASMON_CMD_ARG_Present(pArgs + 3))
  1355. {
  1356. Server.dwPort = RASMON_CMD_ARG_GetDword(pArgs + 3);
  1357. }
  1358. if (RASMON_CMD_ARG_Present(pArgs + 4))
  1359. {
  1360. Server.dwTimeout = RASMON_CMD_ARG_GetDword(pArgs + 4);
  1361. }
  1362. if (RASMON_CMD_ARG_Present(pArgs + 5))
  1363. {
  1364. Server.dwSignature = RASMON_CMD_ARG_GetDword(pArgs + 5);
  1365. }
  1366. dwErr = RasAaaaServerAdd(RASAAAA_Auth, (PVOID)&Server);
  1367. BREAK_ON_DWERR(dwErr);
  1368. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1369. } while (FALSE);
  1370. // Cleanup
  1371. //
  1372. {
  1373. RasAaaaServerCleanup(RASAAAA_Auth, (PVOID)&Server);
  1374. }
  1375. return dwErr;
  1376. }
  1377. DWORD
  1378. RasAaaaHandleAddAcctServ(
  1379. IN LPCWSTR pwszMachine,
  1380. IN OUT LPWSTR *ppwcArguments,
  1381. IN DWORD dwCurrentIndex,
  1382. IN DWORD dwArgCount,
  1383. IN DWORD dwFlags,
  1384. IN LPCVOID pvData,
  1385. OUT BOOL *pbDone
  1386. )
  1387. {
  1388. DWORD dwErr = NO_ERROR;
  1389. RASAAAA_ACCT_SERVER Server;
  1390. RASMON_CMD_ARG pArgs[g_dwArgsAcctCount];
  1391. // Initialize
  1392. CopyMemory(pArgs, g_pArgsAcct, sizeof(g_pArgsAcct));
  1393. do
  1394. {
  1395. dwErr = RasAaaaServerInit(RASAAAA_Acct, (PVOID)&Server);
  1396. BREAK_ON_DWERR(dwErr);
  1397. // Parse the command line
  1398. //
  1399. dwErr = RutlParse(
  1400. ppwcArguments,
  1401. dwCurrentIndex,
  1402. dwArgCount,
  1403. pbDone,
  1404. pArgs,
  1405. sizeof(pArgs)/sizeof(*pArgs));
  1406. BREAK_ON_DWERR( dwErr );
  1407. Server.pszName = RASMON_CMD_ARG_GetPsz(pArgs + 0);
  1408. Server.pszSecret = RASMON_CMD_ARG_GetPsz(pArgs + 1);
  1409. if (RASMON_CMD_ARG_Present(pArgs + 2))
  1410. {
  1411. Server.dwScore = RASMON_CMD_ARG_GetDword(pArgs + 2);
  1412. }
  1413. if (RASMON_CMD_ARG_Present(pArgs + 3))
  1414. {
  1415. Server.dwPort = RASMON_CMD_ARG_GetDword(pArgs + 3);
  1416. }
  1417. if (RASMON_CMD_ARG_Present(pArgs + 4))
  1418. {
  1419. Server.dwTimeout = RASMON_CMD_ARG_GetDword(pArgs + 4);
  1420. }
  1421. if (RASMON_CMD_ARG_Present(pArgs + 5))
  1422. {
  1423. Server.dwMessages = RASMON_CMD_ARG_GetDword(pArgs + 5);
  1424. }
  1425. dwErr = RasAaaaServerAdd(RASAAAA_Acct, (PVOID)&Server);
  1426. BREAK_ON_DWERR(dwErr);
  1427. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1428. } while (FALSE);
  1429. // Cleanup
  1430. //
  1431. {
  1432. RasAaaaServerCleanup(RASAAAA_Acct, (PVOID)&Server);
  1433. }
  1434. return dwErr;
  1435. }
  1436. DWORD
  1437. RasAaaaHandleDelAuthServ(
  1438. IN LPCWSTR pwszMachine,
  1439. IN OUT LPWSTR *ppwcArguments,
  1440. IN DWORD dwCurrentIndex,
  1441. IN DWORD dwArgCount,
  1442. IN DWORD dwFlags,
  1443. IN LPCVOID pvData,
  1444. OUT BOOL *pbDone
  1445. )
  1446. {
  1447. DWORD dwErr = NO_ERROR, dwType = RASAAAA_Auth;
  1448. RASAAAA_AUTH_SERVER Server;
  1449. PVOID pvServer = (PVOID)&Server;
  1450. RASMON_CMD_ARG pArgs[] =
  1451. {
  1452. {
  1453. RASMONTR_CMD_TYPE_STRING,
  1454. {TOKEN_NAME, TRUE, FALSE},
  1455. NULL,
  1456. 0,
  1457. NULL
  1458. }
  1459. };
  1460. ZeroMemory(&Server, sizeof(Server));
  1461. do
  1462. {
  1463. // Parse the command line
  1464. //
  1465. dwErr = RutlParse(
  1466. ppwcArguments,
  1467. dwCurrentIndex,
  1468. dwArgCount,
  1469. pbDone,
  1470. pArgs,
  1471. sizeof(pArgs)/sizeof(*pArgs));
  1472. BREAK_ON_DWERR( dwErr );
  1473. Server.pszName = RASMON_CMD_ARG_GetPsz(&pArgs[0]);
  1474. if (wcscmp(Server.pszName, TOKEN_RASAAAA_ALLSERVERS) == 0)
  1475. {
  1476. dwErr = RasAaaaServerEnum(
  1477. RASAAAA_Auth,
  1478. RasAaaaServerDeleteAuthCb,
  1479. NULL);
  1480. }
  1481. else
  1482. {
  1483. dwErr = RasAaaaServerDelete(dwType, pvServer);
  1484. }
  1485. BREAK_ON_DWERR( dwErr );
  1486. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1487. } while (FALSE);
  1488. // Cleanup
  1489. //
  1490. {
  1491. RasAaaaServerCleanup(dwType, pvServer);
  1492. }
  1493. return dwErr;
  1494. }
  1495. DWORD
  1496. RasAaaaHandleDelAcctServ(
  1497. IN LPCWSTR pwszMachine,
  1498. IN OUT LPWSTR *ppwcArguments,
  1499. IN DWORD dwCurrentIndex,
  1500. IN DWORD dwArgCount,
  1501. IN DWORD dwFlags,
  1502. IN LPCVOID pvData,
  1503. OUT BOOL *pbDone
  1504. )
  1505. {
  1506. DWORD dwErr = NO_ERROR, dwType = RASAAAA_Acct;
  1507. RASAAAA_ACCT_SERVER Server;
  1508. PVOID pvServer = (PVOID)&Server;
  1509. RASMON_CMD_ARG pArgs[] =
  1510. {
  1511. {
  1512. RASMONTR_CMD_TYPE_STRING,
  1513. {TOKEN_NAME, TRUE, FALSE},
  1514. NULL,
  1515. 0,
  1516. NULL
  1517. }
  1518. };
  1519. ZeroMemory(&Server, sizeof(Server));
  1520. do
  1521. {
  1522. // Parse the command line
  1523. //
  1524. dwErr = RutlParse(
  1525. ppwcArguments,
  1526. dwCurrentIndex,
  1527. dwArgCount,
  1528. pbDone,
  1529. pArgs,
  1530. sizeof(pArgs)/sizeof(*pArgs));
  1531. BREAK_ON_DWERR( dwErr );
  1532. Server.pszName = RASMON_CMD_ARG_GetPsz(&pArgs[0]);
  1533. if (wcscmp(Server.pszName, TOKEN_RASAAAA_ALLSERVERS) == 0)
  1534. {
  1535. dwErr = RasAaaaServerEnum(
  1536. RASAAAA_Acct,
  1537. RasAaaaServerDeleteAcctCb,
  1538. NULL);
  1539. }
  1540. else
  1541. {
  1542. dwErr = RasAaaaServerDelete(dwType, pvServer);
  1543. }
  1544. BREAK_ON_DWERR( dwErr );
  1545. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1546. } while (FALSE);
  1547. // Cleanup
  1548. //
  1549. {
  1550. RasAaaaServerCleanup(dwType, pvServer);
  1551. }
  1552. return dwErr;
  1553. }
  1554. DWORD
  1555. RasAaaaHandleSetAuth(
  1556. IN LPCWSTR pwszMachine,
  1557. IN OUT LPWSTR *ppwcArguments,
  1558. IN DWORD dwCurrentIndex,
  1559. IN DWORD dwArgCount,
  1560. IN DWORD dwFlags,
  1561. IN LPCVOID pvData,
  1562. OUT BOOL *pbDone
  1563. )
  1564. {
  1565. DWORD dwErr = NO_ERROR, dwValue;
  1566. HKEY hkProviders = NULL;
  1567. TOKEN_VALUE rgEnum[] =
  1568. {
  1569. {TOKEN_WINDOWS, 1},
  1570. {TOKEN_RADIUS, 0}
  1571. };
  1572. RASMON_CMD_ARG pArgs[] =
  1573. {
  1574. {
  1575. RASMONTR_CMD_TYPE_ENUM,
  1576. {TOKEN_PROVIDER, TRUE, FALSE},
  1577. rgEnum,
  1578. sizeof(rgEnum) / sizeof(*rgEnum),
  1579. NULL
  1580. }
  1581. };
  1582. do
  1583. {
  1584. // Parse the command line
  1585. //
  1586. dwErr = RutlParse(
  1587. ppwcArguments,
  1588. dwCurrentIndex,
  1589. dwArgCount,
  1590. pbDone,
  1591. pArgs,
  1592. sizeof(pArgs)/sizeof(*pArgs));
  1593. BREAK_ON_DWERR( dwErr );
  1594. dwValue = RASMON_CMD_ARG_GetDword(&pArgs[0]);
  1595. dwErr = RasAaaaServerKeyOpen(
  1596. RASAAAA_Auth,
  1597. RASAAAA_F_Provider,
  1598. &hkProviders);
  1599. BREAK_ON_DWERR(dwErr);
  1600. dwErr = RutlRegWriteString(
  1601. hkProviders,
  1602. pszRegValActiveProvider,
  1603. (dwValue) ? pszGuidWinAuth : pszGuidRadAuth);
  1604. BREAK_ON_DWERR(dwErr);
  1605. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1606. } while (FALSE);
  1607. // Cleanup
  1608. //
  1609. {
  1610. if (hkProviders)
  1611. {
  1612. RegCloseKey(hkProviders);
  1613. }
  1614. }
  1615. return dwErr;
  1616. }
  1617. DWORD
  1618. RasAaaaHandleSetAcct(
  1619. IN LPCWSTR pwszMachine,
  1620. IN OUT LPWSTR *ppwcArguments,
  1621. IN DWORD dwCurrentIndex,
  1622. IN DWORD dwArgCount,
  1623. IN DWORD dwFlags,
  1624. IN LPCVOID pvData,
  1625. OUT BOOL *pbDone
  1626. )
  1627. {
  1628. DWORD dwErr = NO_ERROR, dwValue;
  1629. HKEY hkProviders = NULL;
  1630. PWCHAR pszProvider = NULL;
  1631. TOKEN_VALUE rgEnum[] =
  1632. {
  1633. {TOKEN_WINDOWS, 1},
  1634. {TOKEN_RADIUS, 0},
  1635. {TOKEN_NONE, 2}
  1636. };
  1637. RASMON_CMD_ARG pArgs[] =
  1638. {
  1639. {
  1640. RASMONTR_CMD_TYPE_ENUM,
  1641. {TOKEN_PROVIDER, TRUE, FALSE},
  1642. rgEnum,
  1643. sizeof(rgEnum) / sizeof(*rgEnum),
  1644. NULL
  1645. }
  1646. };
  1647. do
  1648. {
  1649. // Parse the command line
  1650. //
  1651. dwErr = RutlParse(
  1652. ppwcArguments,
  1653. dwCurrentIndex,
  1654. dwArgCount,
  1655. pbDone,
  1656. pArgs,
  1657. sizeof(pArgs)/sizeof(*pArgs));
  1658. BREAK_ON_DWERR( dwErr );
  1659. dwValue = RASMON_CMD_ARG_GetDword(&pArgs[0]);
  1660. dwErr = RasAaaaServerKeyOpen(
  1661. RASAAAA_Acct,
  1662. RASAAAA_F_Provider,
  1663. &hkProviders);
  1664. BREAK_ON_DWERR(dwErr);
  1665. if (dwValue == 0)
  1666. {
  1667. pszProvider = pszGuidRadAcct;
  1668. }
  1669. else if (dwValue == 1)
  1670. {
  1671. pszProvider = pszGuidWinAcct;
  1672. }
  1673. else
  1674. {
  1675. pszProvider = L"";
  1676. }
  1677. dwErr = RutlRegWriteString(
  1678. hkProviders,
  1679. pszRegValActiveProvider,
  1680. pszProvider);
  1681. BREAK_ON_DWERR(dwErr);
  1682. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1683. } while (FALSE);
  1684. // Cleanup
  1685. //
  1686. {
  1687. if (hkProviders)
  1688. {
  1689. RegCloseKey(hkProviders);
  1690. }
  1691. }
  1692. return dwErr;
  1693. }
  1694. DWORD
  1695. RasAaaaHandleSetAuthServ(
  1696. IN LPCWSTR pwszMachine,
  1697. IN OUT LPWSTR *ppwcArguments,
  1698. IN DWORD dwCurrentIndex,
  1699. IN DWORD dwArgCount,
  1700. IN DWORD dwFlags,
  1701. IN LPCVOID pvData,
  1702. OUT BOOL *pbDone
  1703. )
  1704. {
  1705. DWORD dwErr = NO_ERROR;
  1706. RASAAAA_AUTH_SERVER Server;
  1707. RASMON_CMD_ARG pArgs[g_dwArgsAuthCount];
  1708. // Initialize
  1709. CopyMemory(pArgs, g_pArgsAuth, sizeof(g_pArgsAuth));
  1710. do
  1711. {
  1712. dwErr = RasAaaaServerInit(RASAAAA_Auth, (PVOID)&Server);
  1713. BREAK_ON_DWERR(dwErr);
  1714. // Parse the command line
  1715. //
  1716. dwErr = RutlParse(
  1717. ppwcArguments,
  1718. dwCurrentIndex,
  1719. dwArgCount,
  1720. pbDone,
  1721. pArgs,
  1722. sizeof(pArgs)/sizeof(*pArgs));
  1723. BREAK_ON_DWERR( dwErr );
  1724. Server.pszName = RASMON_CMD_ARG_GetPsz(pArgs + 0);
  1725. Server.pszSecret = RASMON_CMD_ARG_GetPsz(pArgs + 1);
  1726. dwErr = RasAaaaServerRead(RASAAAA_Auth, (PVOID)&Server, NULL);
  1727. BREAK_ON_DWERR(dwErr);
  1728. if (RASMON_CMD_ARG_Present(pArgs + 2))
  1729. {
  1730. Server.dwScore = RASMON_CMD_ARG_GetDword(pArgs + 2);
  1731. }
  1732. if (RASMON_CMD_ARG_Present(pArgs + 3))
  1733. {
  1734. Server.dwPort = RASMON_CMD_ARG_GetDword(pArgs + 3);
  1735. }
  1736. if (RASMON_CMD_ARG_Present(pArgs + 4))
  1737. {
  1738. Server.dwTimeout = RASMON_CMD_ARG_GetDword(pArgs + 4);
  1739. }
  1740. if (RASMON_CMD_ARG_Present(pArgs + 5))
  1741. {
  1742. Server.dwSignature = RASMON_CMD_ARG_GetDword(pArgs + 5);
  1743. }
  1744. dwErr = RasAaaaServerWrite(RASAAAA_Auth, (PVOID)&Server, NULL, FALSE);
  1745. BREAK_ON_DWERR(dwErr);
  1746. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1747. } while (FALSE);
  1748. // Cleanup
  1749. //
  1750. {
  1751. RasAaaaServerCleanup(RASAAAA_Auth, (PVOID)&Server);
  1752. }
  1753. return dwErr;
  1754. }
  1755. DWORD
  1756. RasAaaaHandleSetAcctServ(
  1757. IN LPCWSTR pwszMachine,
  1758. IN OUT LPWSTR *ppwcArguments,
  1759. IN DWORD dwCurrentIndex,
  1760. IN DWORD dwArgCount,
  1761. IN DWORD dwFlags,
  1762. IN LPCVOID pvData,
  1763. OUT BOOL *pbDone
  1764. )
  1765. {
  1766. DWORD dwErr = NO_ERROR;
  1767. RASAAAA_ACCT_SERVER Server;
  1768. RASMON_CMD_ARG pArgs[g_dwArgsAcctCount];
  1769. // Initialize
  1770. CopyMemory(pArgs, g_pArgsAcct, sizeof(g_pArgsAcct));
  1771. do
  1772. {
  1773. dwErr = RasAaaaServerInit(RASAAAA_Acct, (PVOID)&Server);
  1774. BREAK_ON_DWERR(dwErr);
  1775. // Parse the command line
  1776. //
  1777. dwErr = RutlParse(
  1778. ppwcArguments,
  1779. dwCurrentIndex,
  1780. dwArgCount,
  1781. pbDone,
  1782. pArgs,
  1783. sizeof(pArgs)/sizeof(*pArgs));
  1784. BREAK_ON_DWERR( dwErr );
  1785. Server.pszName = RASMON_CMD_ARG_GetPsz(pArgs + 0);
  1786. Server.pszSecret = RASMON_CMD_ARG_GetPsz(pArgs + 1);
  1787. dwErr = RasAaaaServerRead(RASAAAA_Acct, (PVOID)&Server, NULL);
  1788. BREAK_ON_DWERR(dwErr);
  1789. if (RASMON_CMD_ARG_Present(pArgs + 2))
  1790. {
  1791. Server.dwScore = RASMON_CMD_ARG_GetDword(pArgs + 2);
  1792. }
  1793. if (RASMON_CMD_ARG_Present(pArgs + 3))
  1794. {
  1795. Server.dwPort = RASMON_CMD_ARG_GetDword(pArgs + 3);
  1796. }
  1797. if (RASMON_CMD_ARG_Present(pArgs + 4))
  1798. {
  1799. Server.dwTimeout = RASMON_CMD_ARG_GetDword(pArgs + 4);
  1800. }
  1801. if (RASMON_CMD_ARG_Present(pArgs + 5))
  1802. {
  1803. Server.dwMessages = RASMON_CMD_ARG_GetDword(pArgs + 5);
  1804. }
  1805. dwErr = RasAaaaServerWrite(RASAAAA_Acct, (PVOID)&Server, NULL, FALSE);
  1806. BREAK_ON_DWERR(dwErr);
  1807. DisplayMessage(g_hModule, MSG_RASAAAA_MUST_RESTART_SERVICES);
  1808. } while (FALSE);
  1809. // Cleanup
  1810. //
  1811. {
  1812. RasAaaaServerCleanup(RASAAAA_Acct, (PVOID)&Server);
  1813. }
  1814. return dwErr;
  1815. }
  1816. DWORD
  1817. RasAaaaHandleShowAuth(
  1818. IN LPCWSTR pwszMachine,
  1819. IN OUT LPWSTR *ppwcArguments,
  1820. IN DWORD dwCurrentIndex,
  1821. IN DWORD dwArgCount,
  1822. IN DWORD dwFlags,
  1823. IN LPCVOID pvData,
  1824. OUT BOOL *pbDone
  1825. )
  1826. {
  1827. DWORD dwErr = NO_ERROR, dwProvider;
  1828. DWORD dwNumArgs = dwArgCount - dwCurrentIndex;
  1829. PWCHAR pszProvider = (PWCHAR)TOKEN_WINDOWS;
  1830. do
  1831. {
  1832. // Make sure no arguments were passed
  1833. //
  1834. if (dwNumArgs > 0)
  1835. {
  1836. dwErr = ERROR_INVALID_SYNTAX;
  1837. break;
  1838. }
  1839. dwErr = RasAaaaProviderRead(RASAAAA_Auth, &dwProvider);
  1840. BREAK_ON_DWERR(dwErr);
  1841. if (dwProvider == RASAAAA_Radius)
  1842. {
  1843. pszProvider = (PWCHAR)TOKEN_RADIUS;
  1844. }
  1845. DisplayMessage(
  1846. g_hModule,
  1847. MSG_RASAAAA_SHOW_AUTH,
  1848. pszProvider);
  1849. } while (FALSE);
  1850. // Cleanup
  1851. {
  1852. }
  1853. return dwErr;
  1854. }
  1855. DWORD
  1856. RasAaaaHandleShowAcct(
  1857. IN LPCWSTR pwszMachine,
  1858. IN OUT LPWSTR *ppwcArguments,
  1859. IN DWORD dwCurrentIndex,
  1860. IN DWORD dwArgCount,
  1861. IN DWORD dwFlags,
  1862. IN LPCVOID pvData,
  1863. OUT BOOL *pbDone
  1864. )
  1865. {
  1866. DWORD dwErr = NO_ERROR, dwProvider;
  1867. DWORD dwNumArgs = dwArgCount - dwCurrentIndex;
  1868. PWCHAR pszProvider = NULL;
  1869. do
  1870. {
  1871. // Make sure no arguments were passed
  1872. //
  1873. if (dwNumArgs > 0)
  1874. {
  1875. dwErr = ERROR_INVALID_SYNTAX;
  1876. break;
  1877. }
  1878. // Show the authentication provider
  1879. //
  1880. dwErr = RasAaaaProviderRead(RASAAAA_Acct, &dwProvider);
  1881. BREAK_ON_DWERR(dwErr);
  1882. if (dwProvider == RASAAAA_Radius)
  1883. {
  1884. pszProvider = (PWCHAR)TOKEN_RADIUS;
  1885. }
  1886. else if (dwProvider == RASAAAA_Windows)
  1887. {
  1888. pszProvider = (PWCHAR)TOKEN_WINDOWS;
  1889. }
  1890. else
  1891. {
  1892. pszProvider = (PWCHAR)TOKEN_NONE;
  1893. }
  1894. DisplayMessage(
  1895. g_hModule,
  1896. MSG_RASAAAA_SHOW_ACCT,
  1897. pszProvider);
  1898. } while (FALSE);
  1899. // Cleanup
  1900. {
  1901. }
  1902. return dwErr;
  1903. }
  1904. DWORD
  1905. RasAaaaHandleShowAuthServ(
  1906. IN LPCWSTR pwszMachine,
  1907. IN OUT LPWSTR *ppwcArguments,
  1908. IN DWORD dwCurrentIndex,
  1909. IN DWORD dwArgCount,
  1910. IN DWORD dwFlags,
  1911. IN LPCVOID pvData,
  1912. OUT BOOL *pbDone
  1913. )
  1914. {
  1915. DWORD dwErr = NO_ERROR;
  1916. RASAAAA_AUTH_SERVER Server;
  1917. RASMON_CMD_ARG pArgs[] =
  1918. {
  1919. {
  1920. RASMONTR_CMD_TYPE_STRING,
  1921. {TOKEN_NAME, FALSE, FALSE},
  1922. NULL,
  1923. 0,
  1924. NULL
  1925. }
  1926. };
  1927. do
  1928. {
  1929. ZeroMemory(&Server, sizeof(Server));
  1930. dwErr = RutlParse(
  1931. ppwcArguments,
  1932. dwCurrentIndex,
  1933. dwArgCount,
  1934. pbDone,
  1935. pArgs,
  1936. sizeof(pArgs)/sizeof(*pArgs));
  1937. BREAK_ON_DWERR( dwErr );
  1938. Server.pszName = RASMON_CMD_ARG_GetPsz(pArgs + 0);
  1939. // Display the header
  1940. //
  1941. DisplayMessage(
  1942. g_hModule,
  1943. MSG_RASAAAA_SHOW_AUTHSERV_HDR);
  1944. if (Server.pszName)
  1945. {
  1946. dwErr = RasAaaaServerRead(
  1947. RASAAAA_Auth,
  1948. (PVOID)&Server,
  1949. NULL);
  1950. BREAK_ON_DWERR(dwErr);
  1951. dwErr = RasAaaaServerAuthShow(
  1952. (PVOID)&Server,
  1953. NULL);
  1954. BREAK_ON_DWERR(dwErr);
  1955. }
  1956. else
  1957. {
  1958. // Show all the servers
  1959. //
  1960. dwErr = RasAaaaServerEnum(
  1961. RASAAAA_Auth,
  1962. RasAaaaServerAuthShow,
  1963. NULL);
  1964. BREAK_ON_DWERR(dwErr);
  1965. }
  1966. } while (FALSE);
  1967. // Cleanup
  1968. {
  1969. RasAaaaServerCleanup(RASAAAA_Auth, (PVOID)&Server);
  1970. }
  1971. return dwErr;
  1972. }
  1973. DWORD
  1974. RasAaaaHandleShowAcctServ(
  1975. IN LPCWSTR pwszMachine,
  1976. IN OUT LPWSTR *ppwcArguments,
  1977. IN DWORD dwCurrentIndex,
  1978. IN DWORD dwArgCount,
  1979. IN DWORD dwFlags,
  1980. IN LPCVOID pvData,
  1981. OUT BOOL *pbDone
  1982. )
  1983. {
  1984. DWORD dwErr = NO_ERROR;
  1985. RASAAAA_ACCT_SERVER Server;
  1986. RASMON_CMD_ARG pArgs[] =
  1987. {
  1988. {
  1989. RASMONTR_CMD_TYPE_STRING,
  1990. {TOKEN_NAME, FALSE, FALSE},
  1991. NULL,
  1992. 0,
  1993. NULL
  1994. }
  1995. };
  1996. do
  1997. {
  1998. ZeroMemory(&Server, sizeof(Server));
  1999. dwErr = RutlParse(
  2000. ppwcArguments,
  2001. dwCurrentIndex,
  2002. dwArgCount,
  2003. pbDone,
  2004. pArgs,
  2005. sizeof(pArgs)/sizeof(*pArgs));
  2006. BREAK_ON_DWERR( dwErr );
  2007. Server.pszName = RASMON_CMD_ARG_GetPsz(pArgs + 0);
  2008. // Display the header
  2009. //
  2010. DisplayMessage(
  2011. g_hModule,
  2012. MSG_RASAAAA_SHOW_ACCTSERV_HDR);
  2013. if (Server.pszName)
  2014. {
  2015. dwErr = RasAaaaServerRead(
  2016. RASAAAA_Acct,
  2017. (PVOID)&Server,
  2018. NULL);
  2019. BREAK_ON_DWERR(dwErr);
  2020. dwErr = RasAaaaServerAcctShow(
  2021. (PVOID)&Server,
  2022. NULL);
  2023. BREAK_ON_DWERR(dwErr);
  2024. }
  2025. else
  2026. {
  2027. // Show all the servers
  2028. //
  2029. dwErr = RasAaaaServerEnum(
  2030. RASAAAA_Acct,
  2031. RasAaaaServerAcctShow,
  2032. NULL);
  2033. BREAK_ON_DWERR(dwErr);
  2034. }
  2035. } while (FALSE);
  2036. // Cleanup
  2037. {
  2038. RasAaaaServerCleanup(RASAAAA_Auth, (PVOID)&Server);
  2039. }
  2040. return dwErr;
  2041. }