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.

183 lines
5.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990 **/
  4. /**********************************************************************/
  5. /*
  6. * History
  7. * gregj 5/21/91 Removed from USER for general use
  8. * gregj 5/22/91 Added LOCATION_TYPE enum
  9. * rustanl 6/14/91 Inherit from LM_OBJ
  10. * rustanl 7/01/91 Code review changes from code review
  11. * attended by TerryK, JonN, o-SimoP, RustanL.
  12. * Main change: inherit from BASE.
  13. * rustanl 7/15/91 Code review changes from code review
  14. * attended by ChuckC, Hui-LiCh, TerryK, RustanL.
  15. * jonn 7/26/91 Added Set(const LOCATION & loc);
  16. * terryk 10/7/91 type changes for NT
  17. * jonn 4/21/92 Added LOCATION_NT_TYPE to CheckIfNT()
  18. * jonn 5/06/92 CheckIfNT() checks registry for NT_TYPE
  19. * Yi-HsinS5/13/92 Added QueryDisplayName
  20. *
  21. */
  22. #ifndef _LMOLOC_HXX_
  23. #define _LMOLOC_HXX_
  24. #include "string.hxx"
  25. /*
  26. The following enumeration is used for the "default values"
  27. constructor of a LOCATION.
  28. */
  29. enum LOCATION_TYPE
  30. {
  31. LOC_TYPE_LOCAL, // local computer
  32. LOC_TYPE_LOGONDOMAIN // logon domain
  33. }; // enum LOCATION_TYPE
  34. enum LOCATION_NT_TYPE
  35. {
  36. LOC_NT_TYPE_UNKNOWN, // for internal use only
  37. LOC_NT_TYPE_LANMANNT, // Windows NT Server (PDC or BDC)
  38. LOC_NT_TYPE_WINDOWSNT, // Windows NT Workstation
  39. LOC_NT_TYPE_SERVERNT // Windows NT Server (non-DC)
  40. }; // enum LOCATION_TYPE
  41. /*************************************************************************
  42. NAME: LOCATION
  43. SYNOPSIS: "Location" (server/domain) name validator, and more...
  44. INTERFACE: LOCATION()
  45. Construct with server or domain name (or with
  46. another LOCATION object); default is the local
  47. workstation. Alternate constructor takes
  48. a LOCATION_TYPE enum.
  49. If construction fails, only the Set method and
  50. destructor are valid. If a subsequent call to
  51. Set succeeds, the object can be treated as if it
  52. had been constructed successfully in the first
  53. place. Once in a successfully-constructed
  54. state, the object will never leave this state;
  55. if subsequent Set calls fail, the object will
  56. "snap back" to its previous state.
  57. A LOCATION object is guaranteed to construct
  58. when given a NULL pointer, or the LOC_TYPE_LOCAL
  59. value.
  60. QueryServer()
  61. Returns the passed name if it was a server
  62. name (NULL if local wksta was specified),
  63. or the name of the PDC of the specified domain.
  64. Note, a non-local server name is returned in
  65. the form \\server.
  66. QueryDomain()
  67. Returns the domain name of the location, or NULL
  68. if the object was constructed specifying a server.
  69. QueryName()
  70. Returns the name passed in to specify the
  71. location. It is:
  72. NULL if local wksta was specified
  73. the server name if one was passed in
  74. domain name if one was specified
  75. Set()
  76. Sets the value of the object. Performs a function
  77. very similar to the constructor.
  78. IsDomain
  79. IsServer
  80. These methods can be used to determine how
  81. the LOCATION object was constructed (or Set).
  82. If it was constructed by somehow specifying a
  83. domain, IsDomain will return TRUE; otherwise, it
  84. will return FALSE. IsServer always returns the
  85. complement of IsDomain.
  86. As should be of no surprise to the experienced
  87. UI library client, these methods are not defined
  88. for objects that did not construct properly.
  89. CheckIfNT
  90. Determines if the location we are pointing at is
  91. an NT server, and optionally, whether the
  92. location is a LanmanNT or WindowsNT server.
  93. PARENT: BASE
  94. USES: DOMAIN, WKSTA_10
  95. HISTORY:
  96. gregj 5/21/91 Removed from USER for general use
  97. gregj 5/22/91 Added LOCATION_TYPE constructor
  98. Johnl 5/31/91 Added SetLocation, SetAndValidate methods
  99. rustanl 6/14/91 Clarified behavior of IsDomain and IsServer.
  100. Inherit from LM_OBJ.
  101. rustanl 7/01/91 Code review changes, inherit from BASE.
  102. Johnl 8/13/91 Added IsNT
  103. Kevinl 9/26/91 Added fGetPDC
  104. Johnl 11/15/91 Changed IsNT to CheckIfNT and implemented
  105. JonN 4/21/92 Added LOCATION_NT_TYPE to CheckIfNT()
  106. jonn 5/06/92 CheckIfNT() checks registry for NT_TYPE
  107. **************************************************************************/
  108. DLL_CLASS LOCATION : public BASE
  109. {
  110. private:
  111. DECL_CLASS_NLS_STR( _nlsDomain, DNLEN );
  112. DECL_CLASS_NLS_STR( _nlsServer, MAX_PATH );
  113. /* These are used to determine if the location we are looking at is an
  114. * NT Workstation.
  115. */
  116. UINT _uiNOSMajorVer ;
  117. UINT _uiNOSMinorVer ;
  118. enum LOCATION_TYPE _loctype; // type of local access (or
  119. // LOC_TYPE_LOCAL if a server
  120. // name was passed in)
  121. enum LOCATION_NT_TYPE _locnttype; // cached
  122. APIERR W_Set( const TCHAR * pszLocation, enum LOCATION_TYPE loctype, BOOL fGetPDC );
  123. public:
  124. LOCATION( const TCHAR * pszLocation = NULL, BOOL fGetPDC = TRUE );
  125. LOCATION( enum LOCATION_TYPE loctype, BOOL fGetPDC = TRUE );
  126. LOCATION( const LOCATION & loc );
  127. ~LOCATION();
  128. const TCHAR * QueryName( VOID ) const;
  129. const TCHAR * QueryServer( VOID ) const;
  130. const TCHAR * QueryDomain( VOID ) const;
  131. APIERR QueryDisplayName( NLS_STR *pnls ) const;
  132. APIERR Set( const TCHAR * pszLocation = NULL, BOOL fGetPDC = TRUE )
  133. { return W_Set( pszLocation, LOC_TYPE_LOCAL, fGetPDC ); }
  134. APIERR Set( enum LOCATION_TYPE loctype, BOOL fGetPDC = TRUE )
  135. { return W_Set( NULL, loctype, fGetPDC ); }
  136. APIERR Set( const LOCATION & loc );
  137. BOOL IsDomain( VOID ) const ;
  138. BOOL IsServer( VOID ) const ;
  139. APIERR CheckIfNT( BOOL * pfIsNT );
  140. APIERR CheckIfNT( BOOL * pfIsNT,
  141. enum LOCATION_NT_TYPE * plocnttype ) ;
  142. APIERR QueryNOSVersion( UINT * puiVersMajor, UINT * puiVersMinor ) ;
  143. }; // class LOCATION
  144. #endif // _LMOLOC_HXX_