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.

153 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1991-1992 Microsoft Corporation
  3. Module Name:
  4. Conn.c
  5. Abstract:
  6. This module contains support for the Connection catagory of APIs for
  7. the NT server service.
  8. Author:
  9. David Treadwell (davidtr) 23-Feb-1991
  10. Revision History:
  11. --*/
  12. #include "srvsvcp.h"
  13. NET_API_STATUS NET_API_FUNCTION
  14. NetrConnectionEnum (
  15. IN LPTSTR ServerName,
  16. IN LPTSTR Qualifier,
  17. IN LPCONNECT_ENUM_STRUCT InfoStruct,
  18. IN DWORD PreferredMaximumLength,
  19. OUT LPDWORD TotalEntries,
  20. IN OUT LPDWORD ResumeHandle OPTIONAL
  21. )
  22. /*++
  23. Routine Description:
  24. This routine communicates with the server FSD to implement the
  25. NetConnectionEnum function.
  26. Arguments:
  27. None.
  28. Return Value:
  29. NET_API_STATUS - NO_ERROR or reason for failure.
  30. --*/
  31. {
  32. NET_API_STATUS error;
  33. PSERVER_REQUEST_PACKET srp;
  34. ServerName;
  35. //
  36. // Make sure that the level is valid. Since it is an unsigned
  37. // value, it can never be less than 0.
  38. //
  39. if ( InfoStruct->Level > 1 ) {
  40. return ERROR_INVALID_LEVEL;
  41. }
  42. //
  43. // The qualifier cannot be null or can it be a null string
  44. //
  45. if ( Qualifier == NULL || *Qualifier == L'\0' ||
  46. InfoStruct->ConnectInfo.Level1 == NULL ) {
  47. return ERROR_INVALID_PARAMETER;
  48. }
  49. //
  50. // Make sure that the caller is allowed to get connection
  51. // information in the server.
  52. //
  53. error = SsCheckAccess(
  54. &SsConnectionSecurityObject,
  55. SRVSVC_CONNECTION_INFO_GET
  56. );
  57. if ( error != NO_ERROR ) {
  58. return ERROR_ACCESS_DENIED;
  59. }
  60. //
  61. // Set up the input parameters in the request buffer.
  62. //
  63. srp = SsAllocateSrp( );
  64. if ( srp == NULL ) {
  65. return ERROR_NOT_ENOUGH_MEMORY;
  66. }
  67. srp->Level = InfoStruct->Level;
  68. #ifdef UNICODE
  69. RtlInitUnicodeString( &srp->Name1, Qualifier );
  70. #else
  71. {
  72. OEM_STRING ansiString;
  73. NTSTATUS status;
  74. NetpInitOemString( &ansiString, Qualifier );
  75. status = RtlOemStringToUnicodeString( &srp->Name1, &ansiString, TRUE );
  76. SS_ASSERT( NT_SUCCESS(status) );
  77. }
  78. #endif
  79. if ( ARGUMENT_PRESENT( ResumeHandle ) ) {
  80. srp->Parameters.Get.ResumeHandle = *ResumeHandle;
  81. } else {
  82. srp->Parameters.Get.ResumeHandle = 0;
  83. }
  84. //
  85. // Get the data from the server. This routine will allocate the
  86. // return buffer and handle the case where PreferredMaximumLength ==
  87. // -1.
  88. //
  89. error = SsServerFsControlGetInfo(
  90. FSCTL_SRV_NET_CONNECTION_ENUM,
  91. srp,
  92. (PVOID *)&InfoStruct->ConnectInfo.Level1->Buffer,
  93. PreferredMaximumLength
  94. );
  95. //
  96. // Set up return information.
  97. //
  98. InfoStruct->ConnectInfo.Level1->EntriesRead =
  99. srp->Parameters.Get.EntriesRead;
  100. *TotalEntries = srp->Parameters.Get.TotalEntries;
  101. if ( srp->Parameters.Get.EntriesRead > 0 &&
  102. ARGUMENT_PRESENT( ResumeHandle ) ) {
  103. *ResumeHandle = srp->Parameters.Get.ResumeHandle;
  104. }
  105. #ifndef UNICODE
  106. RtlFreeUnicodeString( &srp->Name1 );
  107. #endif
  108. SsFreeSrp( srp );
  109. return error;
  110. } // NetrConnectionEnum