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.

866 lines
16 KiB

  1. /*++
  2. Copyright (c) 1991-1995 Microsoft Corporation
  3. Module Name:
  4. SmtpStub.C
  5. Abstract:
  6. These are the smtp service API RPC client stubs.
  7. Author:
  8. Johnson Apacible (johnsona) 17-Oct-1995
  9. template used srvstub.c (Dan Lafferty)
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. //
  15. // INCLUDES
  16. //
  17. #include <windows.h>
  18. #include <apiutil.h>
  19. #include <lmcons.h> // NET_API_STATUS
  20. #include <inetinfo.h>
  21. #include <smtpapi.h>
  22. #include <smtpsvc.h>
  23. NET_API_STATUS
  24. NET_API_FUNCTION
  25. SmtpQueryStatistics(
  26. IN LPWSTR servername,
  27. IN DWORD level,
  28. OUT LPBYTE *bufptr
  29. )
  30. /*++
  31. Routine Description:
  32. This is the DLL entrypoint for SmtpGetStatistics
  33. Arguments:
  34. servername --A pointer to an ASCIIZ string containing the name of
  35. the remote server on which the function is to execute. A NULL
  36. pointer or string specifies the local machine.
  37. level --Level of information required. 100, 101 and 102 are valid
  38. for all platforms. 302, 402, 403, 502 are valid for the
  39. appropriate platform.
  40. bufptr --On return a pointer to the return information structure
  41. is returned in the address pointed to by bufptr.
  42. Return Value:
  43. --*/
  44. {
  45. NET_API_STATUS apiStatus;
  46. *bufptr = NULL; // Must be NULL so RPC knows to fill it in.
  47. RpcTryExcept
  48. apiStatus = SmtprQueryStatistics(
  49. servername,
  50. level,
  51. (LPSTAT_INFO) bufptr);
  52. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  53. apiStatus = RpcExceptionCode( );
  54. RpcEndExcept
  55. return(apiStatus);
  56. } // SmtpQueryStatistics
  57. NET_API_STATUS
  58. NET_API_FUNCTION
  59. SmtpClearStatistics(
  60. IN LPWSTR Server OPTIONAL, IN DWORD dwInstance)
  61. {
  62. NET_API_STATUS status;
  63. RpcTryExcept
  64. {
  65. //
  66. // Try RPC (local or remote) version of API.
  67. //
  68. status = SmtpClearStatistics(
  69. Server, dwInstance
  70. );
  71. }
  72. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  73. {
  74. status = RpcExceptionCode();
  75. }
  76. RpcEndExcept
  77. return (status);
  78. } // SmtpClearStatistics
  79. NET_API_STATUS
  80. NET_API_FUNCTION
  81. SmtpGetAdminInformation(
  82. IN LPWSTR pszServer OPTIONAL,
  83. OUT LPSMTP_CONFIG_INFO * ppConfig,
  84. IN DWORD dwInstance
  85. )
  86. /*++
  87. Routine Description:
  88. This is the DLL entrypoint for SmtpGetAdminInformation
  89. Arguments:
  90. servername --A pointer to an ASCIIZ string containing the name of
  91. the remote server on which the function is to execute. A NULL
  92. pointer or string specifies the local machine.
  93. ppConfig --Configuration information returned from the server.
  94. Return Value:
  95. --*/
  96. {
  97. NET_API_STATUS apiStatus;
  98. *ppConfig = NULL; // Must be NULL so RPC knows to fill it in.
  99. RpcTryExcept
  100. apiStatus = SmtprGetAdminInformation(
  101. pszServer,
  102. (LPSMTP_CONFIG_INFO *) ppConfig,
  103. dwInstance);
  104. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  105. apiStatus = RpcExceptionCode( );
  106. RpcEndExcept
  107. return(apiStatus);
  108. } // SmtpGetAdminInformation
  109. NET_API_STATUS
  110. NET_API_FUNCTION
  111. SmtpSetAdminInformation(
  112. IN LPWSTR pszServer OPTIONAL,
  113. IN LPSMTP_CONFIG_INFO pConfig,
  114. IN DWORD dwInstance
  115. )
  116. /*++
  117. Routine Description:
  118. This is the DLL entrypoint for SmtpSetAdminInformation
  119. Arguments:
  120. servername --A pointer to an ASCIIZ string containing the name of
  121. the remote server on which the function is to execute. A NULL
  122. pointer or string specifies the local machine.
  123. pConfig --Configuration information to be set on the server.
  124. Return Value:
  125. --*/
  126. {
  127. NET_API_STATUS apiStatus;
  128. RpcTryExcept
  129. apiStatus = SmtprSetAdminInformation(
  130. pszServer,
  131. (LPSMTP_CONFIG_INFO) pConfig,
  132. dwInstance);
  133. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  134. apiStatus = RpcExceptionCode( );
  135. RpcEndExcept
  136. return(apiStatus);
  137. } // SmtpSetAdminInformation
  138. /*++
  139. Routine Description:
  140. SmtpGetConnectedUserList
  141. Return Value:
  142. API Status - NO_ERROR on success, WIN32 error code on failure.
  143. --*/
  144. NET_API_STATUS
  145. NET_API_FUNCTION
  146. SmtpGetConnectedUserList(
  147. IN LPWSTR wszServerName,
  148. OUT LPSMTP_CONN_USER_LIST *ppConnUserList,
  149. IN DWORD dwInstance
  150. )
  151. {
  152. NET_API_STATUS apiStatus;
  153. *ppConnUserList = NULL;
  154. RpcTryExcept
  155. {
  156. //
  157. // Try RPC (local or remote) version of API.
  158. //
  159. apiStatus = SmtprGetConnectedUserList(
  160. wszServerName,
  161. ppConnUserList,
  162. dwInstance
  163. );
  164. }
  165. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  166. {
  167. apiStatus = RpcExceptionCode();
  168. }
  169. RpcEndExcept
  170. return apiStatus;
  171. }
  172. /*++
  173. Routine Description:
  174. SmtpDisconnectUser
  175. Return Value:
  176. API Status - NO_ERROR on success, WIN32 error code on failure.
  177. --*/
  178. NET_API_STATUS
  179. NET_API_FUNCTION
  180. SmtpDisconnectUser(
  181. IN LPWSTR wszServerName,
  182. IN DWORD dwUserId,
  183. IN DWORD dwInstance
  184. )
  185. {
  186. NET_API_STATUS apiStatus;
  187. RpcTryExcept
  188. {
  189. //
  190. // Try RPC (local or remote) version of API.
  191. //
  192. apiStatus = SmtprDisconnectUser(
  193. wszServerName,
  194. dwUserId,
  195. dwInstance
  196. );
  197. }
  198. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  199. {
  200. apiStatus = RpcExceptionCode();
  201. }
  202. RpcEndExcept
  203. return apiStatus;
  204. }
  205. /*++
  206. Routine Description:
  207. SmtpCreateUser
  208. Return Value:
  209. API Status - NO_ERROR on success, WIN32 error code on failure.
  210. --*/
  211. NET_API_STATUS
  212. NET_API_FUNCTION
  213. SmtpCreateUser(
  214. IN LPWSTR wszServerName,
  215. IN LPWSTR wszEmail,
  216. IN LPWSTR wszForwardEmail,
  217. IN DWORD dwLocal,
  218. IN DWORD dwMailboxSize,
  219. IN DWORD dwMailboxMessageSize,
  220. IN LPWSTR wszVRoot,
  221. IN DWORD dwInstance
  222. )
  223. {
  224. NET_API_STATUS apiStatus;
  225. RpcTryExcept
  226. {
  227. //
  228. // Try RPC (local or remote) version of API.
  229. //
  230. apiStatus = SmtprCreateUser(
  231. wszServerName,
  232. wszEmail,
  233. wszForwardEmail,
  234. dwLocal,
  235. dwMailboxSize,
  236. dwMailboxMessageSize,
  237. wszVRoot,
  238. dwInstance
  239. );
  240. }
  241. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  242. {
  243. apiStatus = RpcExceptionCode();
  244. }
  245. RpcEndExcept
  246. return apiStatus;
  247. }
  248. /*++
  249. Routine Description:
  250. SmtpDeleteUser
  251. Return Value:
  252. API Status - NO_ERROR on success, WIN32 error code on failure.
  253. --*/
  254. NET_API_STATUS
  255. NET_API_FUNCTION
  256. SmtpDeleteUser(
  257. IN LPWSTR wszServerName,
  258. IN LPWSTR wszEmail,
  259. IN DWORD dwInstance
  260. )
  261. {
  262. NET_API_STATUS apiStatus;
  263. RpcTryExcept
  264. {
  265. //
  266. // Try RPC (local or remote) version of API.
  267. //
  268. apiStatus = SmtprDeleteUser(
  269. wszServerName,
  270. wszEmail,
  271. dwInstance
  272. );
  273. }
  274. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  275. {
  276. apiStatus = RpcExceptionCode();
  277. }
  278. RpcEndExcept
  279. return apiStatus;
  280. }
  281. /*++
  282. Routine Description:
  283. SmtpGetUserProps
  284. Return Value:
  285. API Status - NO_ERROR on success, WIN32 error code on failure.
  286. --*/
  287. NET_API_STATUS
  288. NET_API_FUNCTION
  289. SmtpGetUserProps(
  290. IN LPWSTR wszServerName,
  291. IN LPWSTR wszEmail,
  292. OUT LPSMTP_USER_PROPS *ppUserProps,
  293. IN DWORD dwInstance
  294. )
  295. {
  296. NET_API_STATUS apiStatus;
  297. *ppUserProps = NULL;
  298. RpcTryExcept
  299. {
  300. //
  301. // Try RPC (local or remote) version of API.
  302. //
  303. apiStatus = SmtprGetUserProps(
  304. wszServerName,
  305. wszEmail,
  306. ppUserProps,
  307. dwInstance
  308. );
  309. }
  310. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  311. {
  312. apiStatus = RpcExceptionCode();
  313. }
  314. RpcEndExcept
  315. return apiStatus;
  316. }
  317. /*++
  318. Routine Description:
  319. SmtpSetUserProps
  320. Return Value:
  321. API Status - NO_ERROR on success, WIN32 error code on failure.
  322. --*/
  323. NET_API_STATUS
  324. NET_API_FUNCTION
  325. SmtpSetUserProps(
  326. IN LPWSTR wszServerName,
  327. IN LPWSTR wszEmail,
  328. IN LPSMTP_USER_PROPS pUserProps,
  329. IN DWORD dwInstance
  330. )
  331. {
  332. NET_API_STATUS apiStatus;
  333. RpcTryExcept
  334. {
  335. //
  336. // Try RPC (local or remote) version of API.
  337. //
  338. apiStatus = SmtprSetUserProps(
  339. wszServerName,
  340. wszEmail,
  341. pUserProps,
  342. dwInstance
  343. );
  344. }
  345. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  346. {
  347. apiStatus = RpcExceptionCode();
  348. }
  349. RpcEndExcept
  350. return apiStatus;
  351. }
  352. /*++
  353. Routine Description:
  354. SmtpCreateDistList
  355. Return Value:
  356. API Status - NO_ERROR on success, WIN32 error code on failure.
  357. --*/
  358. NET_API_STATUS
  359. NET_API_FUNCTION
  360. SmtpCreateDistList(
  361. IN LPWSTR wszServerName,
  362. IN LPWSTR wszEmail,
  363. IN DWORD dwType,
  364. IN DWORD dwInstance
  365. )
  366. {
  367. NET_API_STATUS apiStatus;
  368. RpcTryExcept
  369. {
  370. //
  371. // Try RPC (local or remote) version of API.
  372. //
  373. apiStatus = SmtprCreateDistList(
  374. wszServerName,
  375. wszEmail,
  376. dwType,
  377. dwInstance
  378. );
  379. }
  380. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  381. {
  382. apiStatus = RpcExceptionCode();
  383. }
  384. RpcEndExcept
  385. return apiStatus;
  386. }
  387. /*++
  388. Routine Description:
  389. SmtpDeleteDistList
  390. Return Value:
  391. API Status - NO_ERROR on success, WIN32 error code on failure.
  392. --*/
  393. NET_API_STATUS
  394. NET_API_FUNCTION
  395. SmtpDeleteDistList(
  396. IN LPWSTR wszServerName,
  397. IN LPWSTR wszEmail,
  398. IN DWORD dwInstance
  399. )
  400. {
  401. NET_API_STATUS apiStatus;
  402. RpcTryExcept
  403. {
  404. //
  405. // Try RPC (local or remote) version of API.
  406. //
  407. apiStatus = SmtprDeleteDistList(
  408. wszServerName,
  409. wszEmail,
  410. dwInstance
  411. );
  412. }
  413. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  414. {
  415. apiStatus = RpcExceptionCode();
  416. }
  417. RpcEndExcept
  418. return apiStatus;
  419. }
  420. /*++
  421. Routine Description:
  422. SmtpCreateDistListMember
  423. Return Value:
  424. API Status - NO_ERROR on success, WIN32 error code on failure.
  425. --*/
  426. NET_API_STATUS
  427. NET_API_FUNCTION
  428. SmtpCreateDistListMember(
  429. IN LPWSTR wszServerName,
  430. IN LPWSTR wszEmail,
  431. IN LPWSTR wszEmailMember,
  432. IN DWORD dwInstance
  433. )
  434. {
  435. NET_API_STATUS apiStatus;
  436. RpcTryExcept
  437. {
  438. //
  439. // Try RPC (local or remote) version of API.
  440. //
  441. apiStatus = SmtprCreateDistListMember(
  442. wszServerName,
  443. wszEmail,
  444. wszEmailMember,
  445. dwInstance
  446. );
  447. }
  448. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  449. {
  450. apiStatus = RpcExceptionCode();
  451. }
  452. RpcEndExcept
  453. return apiStatus;
  454. }
  455. /*++
  456. Routine Description:
  457. SmtpDeleteDistListMember
  458. Return Value:
  459. API Status - NO_ERROR on success, WIN32 error code on failure.
  460. --*/
  461. NET_API_STATUS
  462. NET_API_FUNCTION
  463. SmtpDeleteDistListMember(
  464. IN LPWSTR wszServerName,
  465. IN LPWSTR wszEmail,
  466. IN LPWSTR wszEmailMember,
  467. IN DWORD dwInstance
  468. )
  469. {
  470. NET_API_STATUS apiStatus;
  471. RpcTryExcept
  472. {
  473. //
  474. // Try RPC (local or remote) version of API.
  475. //
  476. apiStatus = SmtprDeleteDistListMember(
  477. wszServerName,
  478. wszEmail,
  479. wszEmailMember,
  480. dwInstance
  481. );
  482. }
  483. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  484. {
  485. apiStatus = RpcExceptionCode();
  486. }
  487. RpcEndExcept
  488. return apiStatus;
  489. }
  490. /*++
  491. Routine Description:
  492. SmtpGetNameList
  493. Return Value:
  494. API Status - NO_ERROR on success, WIN32 error code on failure.
  495. --*/
  496. NET_API_STATUS
  497. NET_API_FUNCTION
  498. SmtpGetNameList(
  499. IN LPWSTR wszServerName,
  500. IN LPWSTR wszEmail,
  501. IN DWORD dwType,
  502. IN DWORD dwRowsRequested,
  503. IN BOOL fForward,
  504. OUT LPSMTP_NAME_LIST *ppNameList,
  505. IN DWORD dwInstance
  506. )
  507. {
  508. NET_API_STATUS apiStatus;
  509. // Make sure RPC knows we want them to fill it in
  510. *ppNameList = NULL;
  511. RpcTryExcept
  512. {
  513. //
  514. // Try RPC (local or remote) version of API.
  515. //
  516. apiStatus = SmtprGetNameList(
  517. wszServerName,
  518. wszEmail,
  519. dwType,
  520. dwRowsRequested,
  521. fForward,
  522. ppNameList,
  523. dwInstance
  524. );
  525. }
  526. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  527. {
  528. apiStatus = RpcExceptionCode();
  529. }
  530. RpcEndExcept
  531. return apiStatus;
  532. }
  533. /*++
  534. Routine Description:
  535. SmtpGetNameListFromList
  536. Return Value:
  537. API Status - NO_ERROR on success, WIN32 error code on failure.
  538. --*/
  539. NET_API_STATUS
  540. NET_API_FUNCTION
  541. SmtpGetNameListFromList(
  542. IN LPWSTR wszServerName,
  543. IN LPWSTR wszEmailList,
  544. IN LPWSTR wszEmail,
  545. IN DWORD dwType,
  546. IN DWORD dwRowsRequested,
  547. IN BOOL fForward,
  548. OUT LPSMTP_NAME_LIST *ppNameList,
  549. IN DWORD dwInstance
  550. )
  551. {
  552. NET_API_STATUS apiStatus;
  553. RpcTryExcept
  554. {
  555. //
  556. // Try RPC (local or remote) version of API.
  557. //
  558. apiStatus = SmtprGetNameListFromList(
  559. wszServerName,
  560. wszEmailList,
  561. wszEmail,
  562. dwType,
  563. dwRowsRequested,
  564. fForward,
  565. ppNameList,
  566. dwInstance
  567. );
  568. }
  569. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  570. {
  571. apiStatus = RpcExceptionCode();
  572. }
  573. RpcEndExcept
  574. return apiStatus;
  575. }
  576. /*++
  577. Routine Description:
  578. SmtpGetVRootSize
  579. Return Value:
  580. API Status - NO_ERROR on success, WIN32 error code on failure.
  581. --*/
  582. NET_API_STATUS
  583. NET_API_FUNCTION
  584. SmtpGetVRootSize(
  585. IN LPWSTR wszServerName,
  586. IN LPWSTR wszVRoot,
  587. IN LPDWORD pdwBytes,
  588. IN DWORD dwInstance
  589. )
  590. {
  591. NET_API_STATUS apiStatus;
  592. RpcTryExcept
  593. {
  594. //
  595. // Try RPC (local or remote) version of API.
  596. //
  597. apiStatus = SmtprGetVRootSize(
  598. wszServerName,
  599. wszVRoot,
  600. pdwBytes,
  601. dwInstance
  602. );
  603. }
  604. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  605. {
  606. apiStatus = RpcExceptionCode();
  607. }
  608. RpcEndExcept
  609. return apiStatus;
  610. }
  611. /*++
  612. Routine Description:
  613. SmtpBackupRoutingTable
  614. Return Value:
  615. API Status - NO_ERROR on success, WIN32 error code on failure.
  616. --*/
  617. NET_API_STATUS
  618. NET_API_FUNCTION
  619. SmtpBackupRoutingTable(
  620. IN LPWSTR wszServerName,
  621. IN LPWSTR wszPath,
  622. IN DWORD dwInstance
  623. )
  624. {
  625. NET_API_STATUS apiStatus;
  626. RpcTryExcept
  627. {
  628. //
  629. // Try RPC (local or remote) version of API.
  630. //
  631. apiStatus = SmtprBackupRoutingTable(
  632. wszServerName,
  633. wszPath,
  634. dwInstance
  635. );
  636. }
  637. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  638. {
  639. apiStatus = RpcExceptionCode();
  640. }
  641. RpcEndExcept
  642. return apiStatus;
  643. }