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.

161 lines
3.5 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. // validate incomming string lengths
  37. //
  38. if(Qualifier!=NULL && StringCchLength(Qualifier,1024,NULL) != S_OK) {
  39. return ERROR_INVALID_PARAMETER;
  40. }
  41. //
  42. // Make sure that the level is valid. Since it is an unsigned
  43. // value, it can never be less than 0.
  44. //
  45. if ( InfoStruct->Level > 1 ) {
  46. return ERROR_INVALID_LEVEL;
  47. }
  48. //
  49. // The qualifier cannot be null or can it be a null string
  50. //
  51. if ( Qualifier == NULL || *Qualifier == L'\0' ||
  52. InfoStruct->ConnectInfo.Level1 == NULL ) {
  53. return ERROR_INVALID_PARAMETER;
  54. }
  55. //
  56. // Make sure that the caller is allowed to get connection
  57. // information in the server.
  58. //
  59. error = SsCheckAccess(
  60. &SsConnectionSecurityObject,
  61. SRVSVC_CONNECTION_INFO_GET
  62. );
  63. if ( error != NO_ERROR ) {
  64. return ERROR_ACCESS_DENIED;
  65. }
  66. //
  67. // Set up the input parameters in the request buffer.
  68. //
  69. srp = SsAllocateSrp( );
  70. if ( srp == NULL ) {
  71. return ERROR_NOT_ENOUGH_MEMORY;
  72. }
  73. srp->Level = InfoStruct->Level;
  74. #ifdef UNICODE
  75. RtlInitUnicodeString( &srp->Name1, Qualifier );
  76. #else
  77. {
  78. OEM_STRING ansiString;
  79. NTSTATUS status;
  80. NetpInitOemString( &ansiString, Qualifier );
  81. status = RtlOemStringToUnicodeString( &srp->Name1, &ansiString, TRUE );
  82. SS_ASSERT( NT_SUCCESS(status) );
  83. }
  84. #endif
  85. if ( ARGUMENT_PRESENT( ResumeHandle ) ) {
  86. srp->Parameters.Get.ResumeHandle = *ResumeHandle;
  87. } else {
  88. srp->Parameters.Get.ResumeHandle = 0;
  89. }
  90. //
  91. // Get the data from the server. This routine will allocate the
  92. // return buffer and handle the case where PreferredMaximumLength ==
  93. // -1.
  94. //
  95. error = SsServerFsControlGetInfo(
  96. FSCTL_SRV_NET_CONNECTION_ENUM,
  97. srp,
  98. (PVOID *)&InfoStruct->ConnectInfo.Level1->Buffer,
  99. PreferredMaximumLength
  100. );
  101. //
  102. // Set up return information.
  103. //
  104. InfoStruct->ConnectInfo.Level1->EntriesRead =
  105. srp->Parameters.Get.EntriesRead;
  106. *TotalEntries = srp->Parameters.Get.TotalEntries;
  107. if ( srp->Parameters.Get.EntriesRead > 0 &&
  108. ARGUMENT_PRESENT( ResumeHandle ) ) {
  109. *ResumeHandle = srp->Parameters.Get.ResumeHandle;
  110. }
  111. #ifndef UNICODE
  112. RtlFreeUnicodeString( &srp->Name1 );
  113. #endif
  114. SsFreeSrp( srp );
  115. return error;
  116. } // NetrConnectionEnum