Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.1 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1989 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: session.c
  7. //
  8. // Description: This module contains support routines for the session
  9. // category API's for the AFP server service. These routines
  10. // will be called by the RPC runtime.
  11. //
  12. // History:
  13. // June 21,1992. NarenG Created original version.
  14. //
  15. #include "afpsvcp.h"
  16. //**
  17. //
  18. // Call: AfpAdminrSessionEnum
  19. //
  20. // Returns: NO_ERROR
  21. // ERROR_ACCESS_DENIED
  22. // non-zero returns from AfpServerIOCtrlGetInfo
  23. //
  24. // Description: This routine communicates with the AFP FSD to implement
  25. // the AfpAdminSessionEnum function.
  26. //
  27. DWORD
  28. AfpAdminrSessionEnum(
  29. IN AFP_SERVER_HANDLE hServer,
  30. IN OUT PSESSION_INFO_CONTAINER pInfoStruct,
  31. IN DWORD dwPreferedMaximumLength,
  32. OUT LPDWORD lpdwTotalEntries,
  33. IN OUT LPDWORD lpdwResumeHandle
  34. )
  35. {
  36. AFP_REQUEST_PACKET AfpSrp;
  37. DWORD dwRetCode=0;
  38. DWORD dwAccessStatus=0;
  39. AFP_PRINT( ( "AFPSVC_session: Received enum request\n"));
  40. // Check if caller has access
  41. //
  42. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  43. {
  44. AFP_PRINT(( "SFMSVC: AfpAdminrSessionEnum, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  45. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  46. dwRetCode, EVENTLOG_ERROR_TYPE );
  47. return( ERROR_ACCESS_DENIED );
  48. }
  49. if ( dwAccessStatus )
  50. {
  51. AFP_PRINT(( "SFMSVC: AfpAdminrSessionEnum, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  52. return( ERROR_ACCESS_DENIED );
  53. }
  54. // Set up request packet and make IOCTL to the FSD
  55. //
  56. AfpSrp.dwRequestCode = OP_SESSION_ENUM;
  57. AfpSrp.dwApiType = AFP_API_TYPE_ENUM;
  58. AfpSrp.Type.Enum.cbOutputBufSize = dwPreferedMaximumLength;
  59. if ( lpdwResumeHandle )
  60. AfpSrp.Type.Enum.EnumRequestPkt.erqp_Index = *lpdwResumeHandle;
  61. else
  62. AfpSrp.Type.Enum.EnumRequestPkt.erqp_Index = 0;
  63. dwRetCode = AfpServerIOCtrlGetInfo( &AfpSrp );
  64. if ( dwRetCode != ERROR_MORE_DATA && dwRetCode != NO_ERROR )
  65. return( dwRetCode );
  66. *lpdwTotalEntries = AfpSrp.Type.Enum.dwTotalAvail;
  67. pInfoStruct->pBuffer = (PAFP_SESSION_INFO)(AfpSrp.Type.Enum.pOutputBuf);
  68. pInfoStruct->dwEntriesRead = AfpSrp.Type.Enum.dwEntriesRead;
  69. if ( lpdwResumeHandle )
  70. *lpdwResumeHandle = AfpSrp.Type.Enum.EnumRequestPkt.erqp_Index;
  71. // Convert all offsets to pointers
  72. //
  73. AfpBufOffsetToPointer( (LPBYTE)(pInfoStruct->pBuffer),
  74. pInfoStruct->dwEntriesRead,
  75. AFP_SESSION_STRUCT );
  76. return( dwRetCode );
  77. }
  78. //**
  79. //
  80. // Call: AfpAdminrSessionClose
  81. //
  82. // Returns: NO_ERROR
  83. // ERROR_ACCESS_DENIED
  84. // non-zero returns from AfpServerIOCtrl
  85. //
  86. // Description: This routine communicates with the AFP FSD to implement
  87. // the AfpAdminSessionClose function.
  88. //
  89. DWORD
  90. AfpAdminrSessionClose( IN AFP_SERVER_HANDLE hServer,
  91. IN DWORD dwSessionId
  92. )
  93. {
  94. AFP_REQUEST_PACKET AfpSrp;
  95. DWORD dwAccessStatus=0;
  96. AFP_SESSION_INFO AfpSessionInfo;
  97. DWORD dwRetCode=0;
  98. // Check if caller has access
  99. //
  100. if ( dwRetCode = AfpSecObjAccessCheck( AFPSVC_ALL_ACCESS, &dwAccessStatus))
  101. {
  102. AFP_PRINT(( "SFMSVC: AfpAdminrSessionClose, AfpSecObjAccessCheck failed %ld\n",dwRetCode));
  103. AfpLogEvent( AFPLOG_CANT_CHECK_ACCESS, 0, NULL,
  104. dwRetCode, EVENTLOG_ERROR_TYPE );
  105. return( ERROR_ACCESS_DENIED );
  106. }
  107. if ( dwAccessStatus )
  108. {
  109. AFP_PRINT(( "SFMSVC: AfpAdminrSessionClose, AfpSecObjAccessCheck returned %ld\n",dwAccessStatus));
  110. return( ERROR_ACCESS_DENIED );
  111. }
  112. // The FSD expects an AFP_SESSION_INFO structure with only the id field
  113. // filled in.
  114. //
  115. AfpSessionInfo.afpsess_id = dwSessionId;
  116. // IOCTL the FSD to close the session
  117. //
  118. AfpSrp.dwRequestCode = OP_SESSION_CLOSE;
  119. AfpSrp.dwApiType = AFP_API_TYPE_DELETE;
  120. AfpSrp.Type.Delete.pInputBuf = &AfpSessionInfo;
  121. AfpSrp.Type.Delete.cbInputBufSize = sizeof(AFP_SESSION_INFO);
  122. return ( AfpServerIOCtrl( &AfpSrp ) );
  123. }