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.

147 lines
4.4 KiB

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