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.

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