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.

141 lines
6.1 KiB

  1. /****************************************************************************/
  2. // anmint.c
  3. //
  4. // Network Manager internal functions
  5. //
  6. // Copyright(C) Microsoft Corporation 1997-1998
  7. /****************************************************************************/
  8. #include <precomp.h>
  9. #pragma hdrstop
  10. #define TRC_GROUP TRC_GROUP_NETWORK
  11. #define TRC_FILE "anmint"
  12. #define pTRCWd (pRealNMHandle->pWDHandle)
  13. #include <adcg.h>
  14. #include <acomapi.h>
  15. #include <anmint.h>
  16. #include <asmapi.h>
  17. #include <nwdwapi.h>
  18. /****************************************************************************/
  19. /* Name: NMDetachUserReq */
  20. /* */
  21. /* Purpose: Call MCSDetachUserReq */
  22. /* */
  23. /* Returns: TRUE - DetachUser issued successfully */
  24. /* FALSE - DetachUser failed */
  25. /* */
  26. /* Params: pRealNMHandle - NM Handle */
  27. /****************************************************************************/
  28. BOOL RDPCALL NMDetachUserReq(PNM_HANDLE_DATA pRealNMHandle)
  29. {
  30. BOOL rc = FALSE;
  31. MCSError MCSErr;
  32. DetachUserIndication DUin;
  33. DC_BEGIN_FN("NMDetachUserReq");
  34. /************************************************************************/
  35. /* Make the call. */
  36. /************************************************************************/
  37. MCSErr = MCSDetachUserRequest(pRealNMHandle->hUser);
  38. if (MCSErr == MCS_NO_ERROR)
  39. {
  40. TRC_NRM((TB, "DetachUser OK"));
  41. DUin.UserID = pRealNMHandle->userID;
  42. DUin.bSelf = TRUE;
  43. DUin.Reason = REASON_USER_REQUESTED;
  44. NMDetachUserInd(pRealNMHandle,
  45. REASON_USER_REQUESTED,
  46. pRealNMHandle->userID);
  47. rc = TRUE;
  48. }
  49. else {
  50. TRC_ERR((TB, "Failed to send DetachUserRequest, MCSErr %d", MCSErr));
  51. }
  52. DC_END_FN();
  53. return rc;
  54. } /* NMDetachUserReq */
  55. /****************************************************************************/
  56. /* Name: NMAbortConnect */
  57. /* */
  58. /* Purpose: Abort a half-formed connection */
  59. /* */
  60. /* Returns: none */
  61. /* */
  62. /* Params: pRealNMHandle - NM Handle */
  63. /* */
  64. /* Operation: This function is called at any point during the connection */
  65. /* sequence to clean up resources if anything goes wrong */
  66. /* */
  67. /****************************************************************************/
  68. void RDPCALL NMAbortConnect(PNM_HANDLE_DATA pRealNMHandle)
  69. {
  70. DC_BEGIN_FN("NMAbortConnect");
  71. /************************************************************************/
  72. /* It is my belief that I don't need to leave the channels I have */
  73. /* joined, but that I must call DetachUser if AttachUser has completed. */
  74. /************************************************************************/
  75. if (pRealNMHandle->connectStatus & NM_CONNECT_ATTACH)
  76. {
  77. TRC_NRM((TB, "User attached, need to detach"));
  78. NMDetachUserReq(pRealNMHandle);
  79. }
  80. /************************************************************************/
  81. /* Tell SM that the connection failed */
  82. /************************************************************************/
  83. SM_OnConnected(pRealNMHandle->pSMHandle, 0, NM_CB_CONN_ERR, NULL, 0);
  84. DC_END_FN();
  85. } /* NMAbortConnect */
  86. /****************************************************************************/
  87. /* Name: NMDetachUserInd */
  88. /* */
  89. /* Purpose: Handle DetachUserIndication from MCS */
  90. /* */
  91. /* Returns: none */
  92. /* */
  93. /* Params: pRealNMHandle - NM Handle */
  94. /* pDUin - MCSDetachUserIndication Ioctl */
  95. /****************************************************************************/
  96. void RDPCALL NMDetachUserInd(PNM_HANDLE_DATA pRealNMHandle,
  97. MCSReason Reason,
  98. UserID userID)
  99. {
  100. UINT32 result;
  101. DC_BEGIN_FN("NMDetachUserInd");
  102. /************************************************************************/
  103. /* Tell SM */
  104. /************************************************************************/
  105. result = Reason == REASON_USER_REQUESTED ? NM_CB_DISC_CLIENT :
  106. Reason == REASON_DOMAIN_DISCONNECTED ? NM_CB_DISC_SERVER :
  107. Reason == REASON_PROVIDER_INITIATED ? NM_CB_DISC_LOGOFF :
  108. NM_CB_DISC_NETWORK;
  109. TRC_NRM((TB, "Detach user %d, reason %d, result %d",
  110. userID, Reason, result));
  111. if (userID == pRealNMHandle->userID)
  112. {
  113. TRC_NRM((TB, "Local user detaching - tell SM"));
  114. SM_OnDisconnected(pRealNMHandle->pSMHandle, userID, result);
  115. }
  116. DC_END_FN();
  117. } /* NMDetachUserInd */