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
4.6 KiB

  1. /*++
  2. Copyright (c) 1991-92 Microsoft Corporation
  3. Module Name:
  4. ConfFail.c
  5. Abstract:
  6. This routine is only used by the NetConfig API DLL stubs.
  7. See Net/API/ConfStub.c for more info.
  8. Author:
  9. John Rogers (JohnRo) 26-Nov-1991
  10. Environment:
  11. User Mode - Win32
  12. Only runs under NT; has an NT-specific interface (with Win32 types).
  13. Requires ANSI C extensions: slash-slash comments, long external names.
  14. Revision History:
  15. 26-Nov-1991 JohnRo
  16. Implement local NetConfig APIs.
  17. 07-Jan-1992 JohnRo
  18. Handle wksta not started better.
  19. 09-Mar-1992 JohnRo
  20. Fixed a bug or two.
  21. --*/
  22. // These must be included first:
  23. #include <nt.h> // IN, etc. (Only needed by temporary config.h)
  24. #include <ntrtl.h> // (Only needed by temporary config.h)
  25. #include <windef.h> // LPVOID, etc.
  26. #include <lmcons.h> // NET_API_STATUS, etc.
  27. #include <netdebug.h> // (Needed by config.h)
  28. // These may be included in any order:
  29. #include <config.h> // My prototype.
  30. #include <debuglib.h> // IF_DEBUG().
  31. #include <lmerr.h> // NERR_Success, etc.
  32. #include <lmremutl.h> // NetpRemoteComputerSupports(), SUPPORTS_ stuff
  33. #include <lmsname.h> // SERVICE_ equates.
  34. #include <netlib.h> // NetpIsServiceStarted().
  35. #define UnexpectedConfigMsg( debugString ) \
  36. { \
  37. NetpKdPrint(( FORMAT_LPDEBUG_STRING ": unexpected situation... " \
  38. debugString "; original api status is " FORMAT_API_STATUS \
  39. ".\n", DebugName, OriginalApiStatus )); \
  40. }
  41. NET_API_STATUS
  42. NetpHandleConfigFailure(
  43. IN LPDEBUG_STRING DebugName, // Used by UnexpectedConfigMsg().
  44. IN NET_API_STATUS OriginalApiStatus, // Used by UnexpectedConfigMsg().
  45. IN LPTSTR ServerNameValue OPTIONAL,
  46. OUT LPBOOL TryDownlevel
  47. )
  48. {
  49. DWORD OptionsSupported = 0;
  50. NET_API_STATUS TempApiStatus;
  51. *TryDownlevel = FALSE; // Be pesimistic until we know for sure.
  52. switch (OriginalApiStatus) {
  53. case NERR_CfgCompNotFound : /*FALLTHROUGH*/
  54. case NERR_CfgParamNotFound : /*FALLTHROUGH*/
  55. case ERROR_INVALID_PARAMETER : /*FALLTHROUGH*/
  56. case ERROR_INVALID_LEVEL : /*FALLTHROUGH*/
  57. *TryDownlevel = FALSE;
  58. return (OriginalApiStatus);
  59. }
  60. NetpAssert( OriginalApiStatus != NERR_Success );
  61. //
  62. // Learn about the machine. This is fairly easy since the
  63. // NetRemoteComputerSupports also handles the local machine (whether
  64. // or not a server name is given).
  65. //
  66. TempApiStatus = NetRemoteComputerSupports(
  67. ServerNameValue,
  68. SUPPORTS_RPC | SUPPORTS_LOCAL, // options wanted
  69. &OptionsSupported);
  70. if (TempApiStatus != NERR_Success) {
  71. // This is where machine not found gets handled.
  72. return (TempApiStatus);
  73. }
  74. if (OptionsSupported & SUPPORTS_LOCAL) {
  75. // We'll get here if ServerNameValue is NULL
  76. UnexpectedConfigMsg( "local, can't connect" );
  77. return (OriginalApiStatus);
  78. } else { // remote machine
  79. //
  80. // Local workstation is not started? (It must be in order to
  81. // remote APIs to the other system.)
  82. //
  83. if (! NetpIsServiceStarted( (LPTSTR) SERVICE_WORKSTATION) ) {
  84. return (NERR_WkstaNotStarted);
  85. } else { // local wksta is started
  86. //
  87. // Remote registry call failed. Try call to downlevel.
  88. //
  89. IF_DEBUG(CONFIG) {
  90. NetpKdPrint((FORMAT_LPDEBUG_STRING
  91. ": Remote registry call failed.\n", DebugName));
  92. }
  93. //
  94. // See if the machine supports RPC. If it does, we do not
  95. // try the downlevel calls, but just return the error.
  96. //
  97. if (OptionsSupported & SUPPORTS_RPC) {
  98. UnexpectedConfigMsg( "machine supports RPC, or other error." );
  99. return (OriginalApiStatus);
  100. } else { // need to call downlevel
  101. // NetpKdPrint((FORMAT_LPDEBUG_STRING
  102. // ": call downlevel.\n", DebugName));
  103. // Tell caller to try calling downlevel routine.
  104. *TryDownlevel = TRUE;
  105. return (ERROR_NOT_SUPPORTED); // any error code will do.
  106. } // need to call downlevel
  107. /*NOTREACHED*/
  108. } // local wksta is started
  109. /*NOTREACHED*/
  110. } // remote machine
  111. /*NOTREACHED*/
  112. } // NetpHandleConfigFailure