home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / remote.srv / radmrpc.cpp < prev    next >
C/C++ Source or Header  |  1996-04-11  |  27KB  |  799 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  File Name 
  4. //      RADMRPC.CPP
  5. //
  6. //  Description
  7. //
  8. //  Author
  9. //      Irving De la Cruz
  10. //
  11. //  Revision: 1.7
  12. //
  13. // Written for Microsoft Windows Developer Support
  14. // Copyright (c) 1995-1996 Microsoft Corporation. All rights reserved.
  15. //
  16. #include "_WINDS.H"
  17. #include <RPC.H>
  18. #include "WINDS.H"      // Header file generated by the MIDL compiler
  19. #include "WDSADM.H"     // Header file generated by the MIDL compiler
  20. #include "COMMON.H"     // For the transmition of the DL members list
  21.  
  22. ///////////////////////////////////////////////////////////////////////////////
  23. //    RemoteAdmGetServerMailboxes()
  24. //
  25. //    Parameters
  26. //
  27. //    Purpose
  28. //
  29. //    Return Value
  30. //
  31. long RemoteAdmGetServerMailboxes (long * pPipeNumber)
  32. {
  33.     long lResult = GetServiceState();
  34.     if (lResult)
  35.     {
  36.         return lResult;
  37.     }
  38.  
  39.     *pPipeNumber = GetNextPipeID();
  40.  
  41.     SECURITY_ATTRIBUTES sa;
  42.     SECURITY_DESCRIPTOR sd;
  43.  
  44.     // Initialize the new security descriptor.
  45.     InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION);
  46.  
  47.     // Add a NULL descriptor ACL to the security descriptor.
  48.     SetSecurityDescriptorDacl (&sd, TRUE, (PACL)NULL, FALSE);
  49.  
  50.     sa.nLength = sizeof(sa);
  51.     sa.lpSecurityDescriptor = &sd;
  52.     sa.bInheritHandle = TRUE;
  53.  
  54.     // Create a pipe where we will expect the transport to send the data
  55.     TCHAR szPipeName[64];
  56.     wsprintf (szPipeName, SERVER_PIPE_NAME_FORMAT, *pPipeNumber);
  57.     HANDLE hPipe;
  58.     hPipe = CreateNamedPipe (szPipeName,
  59.                              PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED,
  60.                              PIPE_WAIT | PIPE_READMODE_BYTE | PIPE_TYPE_BYTE,
  61.                              1,
  62.                              IO_BUFFERSIZE,
  63.                              IO_BUFFERSIZE,
  64.                              0,
  65.                              &sa);
  66.     if (INVALID_HANDLE_VALUE == hPipe || ERROR_INVALID_PARAMETER == (DWORD)hPipe)
  67.     {
  68.         lResult = HRESULT_FROM_WIN32(GetLastError());
  69.         TraceResult ("RemoteAdmGetServerMailboxes: Failed to create pipe", lResult);
  70.         return lResult;
  71.     }
  72.  
  73.     EnterCriticalSection (&g_csIOInfo);
  74.     SetEvent (g_IOInfo.hResumeEvent);
  75.     g_IOInfo.Action           = IO_ADMIN_GET_SERVER_MAILBOXES;
  76.     g_IOInfo.hActionCompleted = NULL;
  77.     g_IOInfo.phLastError      = NULL;
  78.     g_IOInfo.hTmpFile         = hPipe;
  79.     LeaveCriticalSection (&g_csIOInfo);
  80.  
  81.     return lResult;
  82. }
  83.  
  84. ///////////////////////////////////////////////////////////////////////////////
  85. //    RemoteAdmGetServerDistLists()
  86. //
  87. //    Parameters
  88. //
  89. //    Purpose
  90. //
  91. //    Return Value
  92. //
  93. long RemoteAdmGetServerDistLists (long * pPipeNumber)
  94. {
  95.     long lResult = GetServiceState();
  96.     if (lResult)
  97.     {
  98.         return lResult;
  99.     }
  100.  
  101.     *pPipeNumber = GetNextPipeID();
  102.  
  103.     SECURITY_ATTRIBUTES sa;
  104.     SECURITY_DESCRIPTOR sd;
  105.  
  106.     // Initialize the new security descriptor.
  107.     InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION);
  108.  
  109.     // Add a NULL descriptor ACL to the security descriptor.
  110.     SetSecurityDescriptorDacl (&sd, TRUE, (PACL)NULL, FALSE);
  111.  
  112.     sa.nLength = sizeof(sa);
  113.     sa.lpSecurityDescriptor = &sd;
  114.     sa.bInheritHandle = TRUE;
  115.  
  116.     TCHAR szPipeName[64];
  117.     wsprintf (szPipeName, SERVER_PIPE_NAME_FORMAT, *pPipeNumber);
  118.     HANDLE hPipe;
  119.     hPipe = CreateNamedPipe (szPipeName,
  120.                              PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED,
  121.                              PIPE_WAIT | PIPE_READMODE_BYTE | PIPE_TYPE_BYTE,
  122.                              1,
  123.                              IO_BUFFERSIZE,
  124.                              IO_BUFFERSIZE,
  125.                              0,
  126.                              &sa);
  127.     if (INVALID_HANDLE_VALUE == hPipe || ERROR_INVALID_PARAMETER == (DWORD)hPipe)
  128.     {
  129.         lResult = HRESULT_FROM_WIN32(GetLastError());
  130.         TraceResult ("RemoteAdmGetServerDistLists: Failed to create pipe", lResult);
  131.         return lResult;
  132.     }
  133.  
  134.     EnterCriticalSection (&g_csIOInfo);
  135.     SetEvent (g_IOInfo.hResumeEvent);
  136.     g_IOInfo.Action           = IO_ADMIN_GET_SERVER_DISTLISTS;
  137.     g_IOInfo.hActionCompleted = NULL;
  138.     g_IOInfo.phLastError      = NULL;
  139.     g_IOInfo.hTmpFile         = hPipe;
  140.     LeaveCriticalSection (&g_csIOInfo);
  141.  
  142.     return lResult;
  143. }
  144.  
  145. ///////////////////////////////////////////////////////////////////////////////
  146. //    RemoteAdmIsServerRunning()
  147. //
  148. //    Parameters
  149. //
  150. //    Purpose
  151. //
  152. //    Return Value
  153. //
  154. long RemoteAdmIsServerRunning()
  155. {
  156.     return GetServiceState();
  157. }
  158.  
  159. ///////////////////////////////////////////////////////////////////////////////
  160. //    RemoteAdmCreateMailboxA()
  161. //
  162. //    Parameters
  163. //
  164. //    Purpose
  165. //
  166. //    Return Value
  167. //
  168. long RemoteAdmCreateMailboxA (ADM_MAILBOX_INFO_A * pMailboxInfo)
  169. {
  170.     long lResult = GetServiceState();
  171.     if (lResult)
  172.     {
  173.         return lResult;
  174.     }
  175.     if (FALSE == GlobalObjectMap.IsAliasNameAvailable ((LPSTR)pMailboxInfo->szMailboxName))
  176.     {
  177.         return HRESULT_FROM_WIN32(ERROR_USER_EXISTS);
  178.     }
  179.     
  180.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  181.     if (!hWaitEvent)
  182.     {
  183.         lResult = HRESULT_FROM_WIN32(GetLastError());
  184.         TraceResult ("RemoteAdmCreateMailboxA: Failed to create event for I/O thread", lResult);
  185.         return lResult;
  186.     }
  187.  
  188.     MAILBOX_INFO_A MBInfo = { 0 };
  189.     CopyMemory (&MBInfo, pMailboxInfo, sizeof(MAILBOX_INFO_A));
  190.     
  191.     EnterCriticalSection (&g_csIOInfo);
  192.     SetEvent (g_IOInfo.hResumeEvent);
  193.     g_IOInfo.Action           = IO_CREATE_NEW_MAILBOX;
  194.     g_IOInfo.hActionCompleted = hWaitEvent;
  195.     g_IOInfo.phLastError      = &lResult;
  196.     g_IOInfo.pMBInfo          = &MBInfo;
  197.     LeaveCriticalSection (&g_csIOInfo);
  198.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  199.     CloseHandle (hWaitEvent);
  200.     if (lResult)
  201.     {
  202.         TraceResult ("RemoteAdmCreateMailboxA: Failed to create the mailbox", lResult);
  203.         return lResult;
  204.     }
  205.  
  206.     GlobalObjectMap.Insert (MBInfo.dwObjID, MBInfo.szMailboxName, SERVER_USER_MAILBOX);
  207.  
  208.     // Notify clients (i.e. address books) that a new mail user has been added
  209.     PWINDS_NOTIFICATION pNotif = (PWINDS_NOTIFICATION)HeapAlloc (ghHeap,
  210.                                                                  HEAP_ZERO_MEMORY,
  211.                                                                  sizeof(WINDS_NOTIFICATION));
  212.     if (pNotif)
  213.     {
  214.         pNotif->Event = AB_USER_ADDED;
  215.         CopyMemory (&(pNotif->Info.MB), &MBInfo, sizeof(MAILBOX_INFO));
  216.         NotifyClients (pNotif); // This will take care of freeing the notification structure
  217.     }
  218.     else
  219.     {
  220.         // This is non-fatal
  221.         TraceResult ("RemoteAdmCreateMailboxA: Failed to allocate notification structure", E_OUTOFMEMORY);
  222.     }
  223.     return lResult;
  224. }
  225.  
  226. ///////////////////////////////////////////////////////////////////////////////
  227. //    RemoteAdmDeleteObject()
  228. //
  229. //    Parameters
  230. //
  231. //    Purpose
  232. //
  233. //    Return Value
  234. //
  235. long RemoteAdmDeleteObject (unsigned long dwObjID)
  236. {
  237.     long lResult = GetServiceState();
  238.     if (lResult)
  239.     {
  240.         return lResult;
  241.     }
  242.  
  243.     TCHAR szObjAlias[MAX_ALIAS_SIZE+1];
  244.     WINDS_AB_OBJTYPE Type = UNDEFINED_OBJECT_TYPE;
  245.     if (S_OK != GlobalObjectMap.FindObjFromID (dwObjID, szObjAlias, &Type))
  246.     {
  247.         return HRESULT_FROM_WIN32 (ERROR_FILE_NOT_FOUND);
  248.     }
  249.  
  250.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  251.     if (!hWaitEvent)
  252.     {
  253.         lResult = HRESULT_FROM_WIN32(GetLastError());
  254.         TraceResult ("RemoteAdmDeleteObject: Failed to create event for I/O thread", lResult);
  255.         return lResult;
  256.     }
  257.     MAILBOX_INFO MBInfo = { 0 };
  258.     DIST_LIST_INFO DLInfo = { 0 };
  259.  
  260.     EnterCriticalSection (&g_csIOInfo);
  261.     SetEvent (g_IOInfo.hResumeEvent);
  262.     g_IOInfo.hActionCompleted = hWaitEvent;
  263.     g_IOInfo.phLastError = &lResult;
  264.  
  265.     if (SERVER_USER_MAILBOX == Type)
  266.     {
  267.         lstrcpy (MBInfo.szMailboxName, szObjAlias);
  268.         g_IOInfo.Action = IO_REMOVE_MAILBOX;
  269.         g_IOInfo.pMBInfo = &MBInfo; // On return this will have all the mailbox properties
  270.     }
  271.     else
  272.     {
  273.         if (SERVER_DISTRIBUTION_LIST == Type)
  274.         {
  275.             lstrcpy (DLInfo.szDLAlias, szObjAlias);
  276.             g_IOInfo.Action = IO_DELETE_DISTRIBUTION_LIST;
  277.             g_IOInfo.pDLInfo = &DLInfo;
  278.         }
  279.         else
  280.         {
  281.             TraceMessage ("RemoteAdmDeleteObject: Remove GATEWAY recipient NYI");
  282.         }
  283.     }
  284.  
  285.     LeaveCriticalSection (&g_csIOInfo);
  286.  
  287.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  288.     CloseHandle (hWaitEvent);
  289.  
  290.     if (lResult)
  291.     {
  292.         TraceResult ("RemoteAdmDeleteObject: Failed to delete the mailbox", lResult);
  293.         return lResult;
  294.     }
  295.  
  296.     GlobalObjectMap.Delete (dwObjID);
  297.     // Notify client address books that a mail user has been deleted
  298.     PWINDS_NOTIFICATION pNotif = (PWINDS_NOTIFICATION)HeapAlloc (ghHeap,
  299.                                                                  HEAP_ZERO_MEMORY,
  300.                                                                  sizeof(WINDS_NOTIFICATION));
  301.     if (pNotif)
  302.     {
  303.         if (SERVER_USER_MAILBOX == Type)
  304.         {
  305.             pNotif->Event = AB_USER_DELETED;
  306.             CopyMemory (&(pNotif->Info.MB), &MBInfo, sizeof(MAILBOX_INFO));
  307.         }
  308.         else
  309.         {
  310.             if (SERVER_DISTRIBUTION_LIST == Type)
  311.             {
  312.                 pNotif->Event = AB_DL_DELETED;
  313.                 CopyMemory (&(pNotif->Info.DL), &DLInfo, sizeof(DIST_LIST_INFO));
  314.             }
  315.             else
  316.             {
  317.                 // TODO: Implement this for gateways
  318.             }
  319.         }
  320.         NotifyClients (pNotif); // This will take care of freeing the notification structure
  321.     }
  322.     else
  323.     {
  324.         // Non-fatal error
  325.         TraceResult ("RemoteAdmDeleteObject: Failed to allocate notification structure", E_OUTOFMEMORY);
  326.     }
  327.     return lResult;
  328. }
  329.  
  330. ///////////////////////////////////////////////////////////////////////////////
  331. //    RemoteAdmGetMailboxPropsA()
  332. //
  333. //    Parameters
  334. //
  335. //    Purpose
  336. //
  337. //    Return Value
  338. //
  339. long RemoteAdmGetMailboxPropsA (unsigned long           dwObjID,
  340.                                 unsigned long *         pdwObjType,
  341.                                 ADM_MAILBOX_INFO_A *    pMailboxInfo)
  342. {
  343.     long lResult = GetServiceState();
  344.     if (lResult)
  345.     {
  346.         return lResult;
  347.     }
  348.     return GetObjectProp (dwObjID, pdwObjType, (MAILBOX_INFO*)pMailboxInfo);
  349. }
  350.  
  351. ///////////////////////////////////////////////////////////////////////////////
  352. //    RemoteAdmSetMailboxPropsA()
  353. //
  354. //    Parameters
  355. //
  356. //    Purpose
  357. //
  358. //    Return Value
  359. //
  360. long RemoteAdmSetMailboxPropsA (ADM_MAILBOX_INFO_A * pMailboxInfo)
  361. {
  362.     long lResult = GetServiceState();
  363.     if (lResult)
  364.     {
  365.         return lResult;
  366.     }
  367.  
  368.     if (pMailboxInfo->dwObjID == 0)
  369.     {
  370.         TraceMessage ("RemoteAdmSetMailboxPropsA: Invoked with Object ID = 0, cannot accept");
  371.         return HRESULT_FROM_WIN32 (ERROR_NO_SUCH_USER);
  372.     }
  373.  
  374.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  375.     if (!hWaitEvent)
  376.     {
  377.         lResult = HRESULT_FROM_WIN32(GetLastError());
  378.         TraceResult ("RemoteAdmSetMailboxPropsA: Failed to create event for I/O thread", lResult);
  379.         return lResult;
  380.     }
  381.  
  382.     MAILBOX_INFO_A MBInfo = { 0 };
  383.     CopyMemory (&MBInfo, pMailboxInfo, sizeof(MAILBOX_INFO_A));
  384.  
  385.     EnterCriticalSection (&g_csIOInfo);
  386.     SetEvent (g_IOInfo.hResumeEvent);
  387.     g_IOInfo.Action           = IO_SET_MAILBOX_PROPERTIES;
  388.     g_IOInfo.hActionCompleted = hWaitEvent;
  389.     g_IOInfo.phLastError      = &lResult;
  390.     g_IOInfo.pMBInfo          = &MBInfo;
  391.     LeaveCriticalSection (&g_csIOInfo);
  392.  
  393.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  394.     CloseHandle (hWaitEvent);
  395.     if (!lResult)
  396.     {
  397.         // Notify client address books that a mail user has been modified
  398.         PWINDS_NOTIFICATION pNotif = (PWINDS_NOTIFICATION)HeapAlloc (ghHeap,
  399.                                                                      HEAP_ZERO_MEMORY,
  400.                                                                      sizeof(WINDS_NOTIFICATION));
  401.         if (pNotif)
  402.         {
  403.             pNotif->Event = AB_USER_MODIFIED;
  404.             CopyMemory (&(pNotif->Info.MB), &MBInfo, sizeof(MAILBOX_INFO));
  405.             NotifyClients (pNotif); // This will take care of freeing the notification structure
  406.         }
  407.         else
  408.         {
  409.             // This is non-fatal
  410.             TraceResult ("RemoteAdmSetMailboxPropsA: Failed to allocate notification structure", E_OUTOFMEMORY);
  411.         }
  412.     }
  413.     return lResult;
  414. }
  415.  
  416. ///////////////////////////////////////////////////////////////////////////////
  417. //    RemoteAdmTerminateNotifA()
  418. //
  419. //    Parameters
  420. //
  421. //    Purpose
  422. //
  423. //    Return Value
  424. //
  425. long RemoteAdmTerminateNotifA (unsigned char *   szComputerName,
  426.                               unsigned long     ulConnectionID)
  427. {
  428.     return RemoteTerminateNotifA (szComputerName, ulConnectionID);
  429. }
  430.  
  431. ///////////////////////////////////////////////////////////////////////////////
  432. //    RemoteAdmValidateNotifA()
  433. //
  434. //    Parameters
  435. //
  436. //    Purpose
  437. //
  438. //    Return Value
  439. //
  440. long RemoteAdmValidateNotifA (unsigned char *    szComputerName,
  441.                               unsigned long      ulNotifMask,
  442.                               unsigned long *    pulConnectionID)
  443. {
  444.     return RemoteValidateNotifA (szComputerName,
  445.                                  (unsigned char *)"WINDS ADMIN",
  446.                                  ulNotifMask,
  447.                                  pulConnectionID);
  448. }
  449.  
  450. ///////////////////////////////////////////////////////////////////////////////
  451. //    RemoteAdmGetGALDirectory()
  452. //
  453. //    Parameters
  454. //
  455. //    Purpose
  456. //
  457. //    Return Value
  458. //
  459. long RemoteAdmGetGALDirectory (unsigned long dwFlags, long * pPipeNumber)
  460. {
  461.     return RemoteGetContainerRecipients (dwFlags, GAL_CONTAINER_ID, pPipeNumber);
  462. }
  463.  
  464. ///////////////////////////////////////////////////////////////////////////////
  465. //    RemoteAdmEmptyMailbox()
  466. //
  467. //    Parameters
  468. //
  469. //    Purpose
  470. //
  471. //    Return Value
  472. //
  473. long RemoteAdmEmptyMailbox (unsigned long dwMailboxID)
  474. {
  475.     long lResult = GetServiceState();
  476.     if (lResult)
  477.     {
  478.         return lResult;
  479.     }
  480.  
  481.     TCHAR szObjAlias[MAX_ALIAS_SIZE+1];
  482.     WINDS_AB_OBJTYPE Type = UNDEFINED_OBJECT_TYPE;
  483.     if (S_OK != GlobalObjectMap.FindObjFromID (dwMailboxID, szObjAlias, &Type))
  484.     {
  485.         return HRESULT_FROM_WIN32 (ERROR_FILE_NOT_FOUND);
  486.     }
  487.     if (SERVER_USER_MAILBOX != Type)
  488.     {
  489.         return HRESULT_FROM_WIN32 (ERROR_NO_SUCH_USER);
  490.     }
  491.  
  492.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  493.     if (!hWaitEvent)
  494.     {
  495.         lResult = HRESULT_FROM_WIN32(GetLastError());
  496.         TraceResult ("RemoteAdmEmptyMailbox: Failed to create event for I/O thread", lResult);
  497.         return lResult;
  498.     }
  499.     
  500.     EnterCriticalSection (&g_csIOInfo);
  501.     SetEvent (g_IOInfo.hResumeEvent);
  502.     lstrcpy (g_IOInfo.szObject, szObjAlias);
  503.     g_IOInfo.Action           = IO_EMPTY_MAILBOX;
  504.     g_IOInfo.hActionCompleted = hWaitEvent;
  505.     g_IOInfo.phLastError      = &lResult;
  506.     LeaveCriticalSection (&g_csIOInfo);
  507.  
  508.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  509.     CloseHandle (hWaitEvent);
  510.  
  511.     TraceResult ("RemoteAdmEmptyMailbox", lResult);
  512.     return lResult;
  513. }
  514.  
  515. ///////////////////////////////////////////////////////////////////////////////
  516. //    RemoteAdmGetDLPropsA()
  517. //
  518. //    Parameters
  519. //
  520. //    Purpose
  521. //
  522. //    Return Value
  523. //
  524. long RemoteAdmGetDLPropsA (unsigned long        dwObjID,
  525.                            unsigned char *      szDLAlias,
  526.                            unsigned char *      szDLFullName,
  527.                            unsigned long *      pdwFlags,
  528.                            unsigned char *      szOwnerAlias,
  529.                            unsigned char *      szOwnerName,
  530.                            unsigned long *      pdwOwnerID,
  531.                            unsigned char *      szComments,
  532.                            DLM_XMIT_LIST_A *    pMembers)
  533. {
  534.     long lResult = GetServiceState();
  535.     if (lResult)
  536.     {
  537.         return lResult;
  538.     }
  539.  
  540.     if (0 == dwObjID)
  541.     {
  542.         TraceMessage ("RemoteAdmGetDLPropsA: Invoked with Object ID = 0, cannot accept");
  543.         return HRESULT_FROM_WIN32 (ERROR_NO_SUCH_GROUP);
  544.     }
  545.  
  546.     DIST_LIST_INFO DLInfo = { 0 };
  547.     WINDS_AB_OBJTYPE Type = UNDEFINED_OBJECT_TYPE;
  548.     if ((S_OK != GlobalObjectMap.FindObjFromID (dwObjID, DLInfo.szDLAlias, &Type)) ||
  549.         (SERVER_DISTRIBUTION_LIST != Type))
  550.     {
  551.         return HRESULT_FROM_WIN32 (ERROR_NO_SUCH_GROUP);
  552.     }
  553.  
  554.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  555.     if (!hWaitEvent)
  556.     {
  557.         lResult = HRESULT_FROM_WIN32(GetLastError());
  558.         TraceResult ("RemoteAdmGetDLPropsA: Failed to create event for I/O thread", lResult);
  559.         return lResult;
  560.     }
  561.     DLInfo.pMembers = (LPVOID)pMembers;
  562.  
  563.     EnterCriticalSection (&g_csIOInfo);
  564.     SetEvent (g_IOInfo.hResumeEvent);
  565.     g_IOInfo.Action           = IO_GET_DL_PROPERTIES;
  566.     g_IOInfo.hActionCompleted = hWaitEvent;
  567.     g_IOInfo.phLastError      = &lResult;
  568.     g_IOInfo.pDLInfo          = &DLInfo;
  569.     LeaveCriticalSection (&g_csIOInfo);
  570.  
  571.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  572.     CloseHandle (hWaitEvent);
  573.     if (!lResult)
  574.     {
  575.         lstrcpy ((LPSTR)szDLAlias, DLInfo.szDLAlias);
  576.         lstrcpy ((LPSTR)szDLFullName, DLInfo.szDLFullName);
  577.         *pdwFlags = DLInfo.dwFlags;
  578.         lstrcpy ((LPSTR)szOwnerAlias, DLInfo.szOwnerAlias);
  579.         lstrcpy ((LPSTR)szOwnerName, DLInfo.szOwnerName);
  580.         *pdwOwnerID = DLInfo.dwOwnerID;
  581.     }
  582.  
  583.     TraceResult ("RemoteAdmGetDLPropsA", lResult);
  584.     return lResult;
  585. }
  586.  
  587. ///////////////////////////////////////////////////////////////////////////////
  588. //    RemoteAdmSetDLPropsA()
  589. //
  590. //    Parameters
  591. //
  592. //    Purpose
  593. //
  594. //    Return Value
  595. //
  596. long RemoteAdmSetDLPropsA (unsigned long        dwObjID,
  597.                            unsigned char *      szDLAlias,
  598.                            unsigned char *      szDLFullName,
  599.                            unsigned long        dwFlags,
  600.                            unsigned char *      szOwnerAlias,
  601.                            unsigned char *      szOwnerName,
  602.                            unsigned long        dwOwnerID,
  603.                            unsigned char *      szComments,
  604.                            DLM_XMIT_LIST_A *    pMembers)
  605. {
  606.     long lResult = GetServiceState();
  607.     if (lResult)
  608.     {
  609.         return lResult;
  610.     }
  611.     if (dwObjID == 0)
  612.     {
  613.         TraceMessage ("RemoteAdmSetDLPropsA: Invoked with Object ID = 0, cannot accept");
  614.         return HRESULT_FROM_WIN32 (ERROR_NO_SUCH_GROUP);
  615.     }
  616.  
  617.     DIST_LIST_INFO DLInfo = { 0 };
  618.     lstrcpy (DLInfo.szDLAlias, (LPSTR)szDLAlias);
  619.     lstrcpy (DLInfo.szDLFullName, (LPSTR)szDLFullName);
  620.     DLInfo.dwObjID= dwObjID;
  621.     DLInfo.dwFlags = dwFlags;
  622.     lstrcpy (DLInfo.szOwnerAlias, (LPSTR)szOwnerAlias);
  623.     lstrcpy (DLInfo.szOwnerName, (LPSTR)szOwnerName);
  624.     DLInfo.dwOwnerID = dwOwnerID;
  625.     DLInfo.pMembers = (LPVOID)pMembers;
  626.  
  627.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  628.     if (!hWaitEvent)
  629.     {
  630.         lResult = HRESULT_FROM_WIN32(GetLastError());
  631.         TraceResult ("RemoteAdmSetDLPropsA: Failed to create event for I/O thread", lResult);
  632.         return lResult;
  633.     }
  634.  
  635.     EnterCriticalSection (&g_csIOInfo);
  636.     SetEvent (g_IOInfo.hResumeEvent);
  637.     g_IOInfo.Action           = IO_SET_DL_PROPERTIES;
  638.     g_IOInfo.hActionCompleted = hWaitEvent;
  639.     g_IOInfo.phLastError      = &lResult;
  640.     g_IOInfo.pDLInfo          = &DLInfo;
  641.     LeaveCriticalSection (&g_csIOInfo);
  642.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  643.     CloseHandle (hWaitEvent);
  644.  
  645.     if (!lResult)
  646.     {
  647.         PWINDS_NOTIFICATION pNotif = (PWINDS_NOTIFICATION)HeapAlloc (ghHeap,
  648.                                                                      HEAP_ZERO_MEMORY,
  649.                                                                      sizeof(WINDS_NOTIFICATION));
  650.         if (pNotif)
  651.         {
  652.             pNotif->Event = AB_DL_MODIFIED;
  653.             CopyMemory (&(pNotif->Info.DL), &DLInfo, sizeof(DIST_LIST_INFO));
  654.             NotifyClients (pNotif); // This will take care of freeing the notification structure
  655.         }
  656.         else
  657.         {
  658.             // This is non-fatal
  659.             TraceResult ("RemoteAdmSetDLPropsA: Failed to allocate the notification structure", E_OUTOFMEMORY);
  660.         }
  661.     }
  662.     TraceResult ("RemoteAdmSetDLPropsA", lResult);
  663.     return lResult;
  664. }
  665.  
  666. ///////////////////////////////////////////////////////////////////////////////
  667. //    RemoteAdmCreateDistListA()
  668. //
  669. //    Parameters
  670. //
  671. //    Purpose
  672. //
  673. //    Return Value
  674. //
  675. long RemoteAdmCreateDistListA (unsigned char *   szDLAlias,
  676.                                unsigned char *   szDLFullName,
  677.                                unsigned long     dwFlags,
  678.                                unsigned char *   szOwnerAlias,
  679.                                unsigned char *   szOwnerName,
  680.                                unsigned long     dwOwnerID,
  681.                                DLM_XMIT_LIST_A * pMembers)
  682. {
  683.     long lResult = GetServiceState();
  684.     if (lResult)
  685.     {
  686.         return lResult;
  687.     }
  688.     if (FALSE == GlobalObjectMap.IsAliasNameAvailable ((LPSTR)szDLAlias))
  689.     {
  690.         return HRESULT_FROM_WIN32(ERROR_GROUP_EXISTS);
  691.     }
  692.     
  693.     HANDLE hWaitEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
  694.     if (!hWaitEvent)
  695.     {
  696.         lResult = HRESULT_FROM_WIN32(GetLastError());
  697.         TraceResult ("RemoteAdmCreateDistListA: Failed to create event for I/O thread", lResult);
  698.         return lResult;
  699.     }
  700.  
  701.     DIST_LIST_INFO DLInfo = { 0 };
  702.     lstrcpy (DLInfo.szDLAlias, (LPSTR)szDLAlias);
  703.     lstrcpy (DLInfo.szDLFullName, (LPSTR)szDLFullName);
  704.     DLInfo.dwFlags = dwFlags;
  705.  
  706.     lstrcpy (DLInfo.szOwnerAlias, (LPSTR)szOwnerAlias);
  707.     lstrcpy (DLInfo.szOwnerName, (LPSTR)szOwnerName);
  708.     DLInfo.dwOwnerID = dwOwnerID;
  709.     if (pMembers->Info.szMemberName[0])
  710.     {
  711.         DLInfo.pMembers = (LPVOID)pMembers;
  712.     }
  713.     else
  714.     {
  715.         DLInfo.pMembers = NULL;
  716.     }
  717.  
  718.     EnterCriticalSection (&g_csIOInfo);
  719.     SetEvent (g_IOInfo.hResumeEvent);
  720.     g_IOInfo.Action           = IO_CREATE_DISTRIBUTION_LIST;
  721.     g_IOInfo.hActionCompleted = hWaitEvent;
  722.     g_IOInfo.phLastError      = &lResult;
  723.     g_IOInfo.pDLInfo          = &DLInfo;
  724.     LeaveCriticalSection (&g_csIOInfo);
  725.     WaitForSingleObject (hWaitEvent, GENERAL_TIME_OUT);
  726.     CloseHandle (hWaitEvent);
  727.     
  728.     if (lResult)
  729.     {
  730.         TraceResult ("RemoteAdmCreateDistListA", lResult);
  731.         return lResult;
  732.     }
  733.  
  734.     GlobalObjectMap.Insert (DLInfo.dwObjID, DLInfo.szDLAlias, SERVER_DISTRIBUTION_LIST);
  735.  
  736.     // Notify client address books that a distribution list has been added
  737.     PWINDS_NOTIFICATION pNotif = (PWINDS_NOTIFICATION)HeapAlloc (ghHeap,
  738.                                                                  HEAP_ZERO_MEMORY,
  739.                                                                  sizeof(WINDS_NOTIFICATION));
  740.     if (pNotif)
  741.     {
  742.         pNotif->Event = AB_DL_ADDED;
  743.         CopyMemory (&(pNotif->Info.DL), &DLInfo, sizeof(DIST_LIST_INFO));
  744.         NotifyClients (pNotif); // This will take care of freeing the notification structure
  745.     }
  746.     else
  747.     {
  748.         // This is non-fatal
  749.         TraceResult ("RemoteAdmCreateDistListA: Failed to allocate the notification structure", E_OUTOFMEMORY);
  750.     }
  751.     return lResult;
  752. }
  753.  
  754. // The UNICODE version of these function, has not been implemented yet.
  755. long RemoteAdmTerminateNotifW (wchar_t *        szComputerName,
  756.                                unsigned long    ulConnectionID)
  757. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  758. long RemoteAdmValidateNotifW (wchar_t *         szComputerName,
  759.                               unsigned long     ulNotifMask,
  760.                               unsigned long *   pulConnectionID)
  761. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  762. long RemoteAdmCreateMailboxW (ADM_MAILBOX_INFO_W * pMailboxInfo)
  763. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  764. long RemoteAdmGetMailboxPropsW (unsigned long        dwObjID,
  765.                                 unsigned long *      pdwUserType,
  766.                                 ADM_MAILBOX_INFO_W * pMailboxInfo)
  767. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  768. long RemoteAdmSetMailboxPropsW (ADM_MAILBOX_INFO_W * pMailboxInfo)
  769. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  770. long RemoteAdmCreateDistListW (wchar_t *         szDLAlias,
  771.                                wchar_t *         szDLFullName,
  772.                                unsigned long     dwFlags,
  773.                                wchar_t *         szOwnerAlias,
  774.                                wchar_t *         szOwnerName,
  775.                                unsigned long     dwOwnerID,
  776.                                DLM_XMIT_LIST_W * pMembers)
  777. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  778. long RemoteAdmGetDLPropsW (unsigned long        dwObjID,
  779.                            wchar_t *            szDLAlias,
  780.                            wchar_t *            szDLFullName,
  781.                            unsigned long *      pdwFlags,
  782.                            wchar_t *            szOwnerAlias,
  783.                            wchar_t *            szOwnerName,
  784.                            unsigned long *      pdwOwnerID,
  785.                            wchar_t *            szComments,
  786.                            DLM_XMIT_LIST_W *    pMembers)
  787. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  788. long RemoteAdmSetDLPropsW (unsigned long        dwObjID,
  789.                            wchar_t *            szDLAlias,
  790.                            wchar_t *            szDLFullName,
  791.                            unsigned long        dwFlags,
  792.                            wchar_t *            szOwnerAlias,
  793.                            wchar_t *            szOwnerName,
  794.                            unsigned long        dwOwnerID,
  795.                            wchar_t *            szComments,
  796.                            DLM_XMIT_LIST_W *    pMembers)
  797. { return HRESULT_FROM_WIN32(E_NOTIMPL); }
  798. // End of file for RADMRPC.CPP
  799.