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.

295 lines
7.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. lmoesrv3.hxx
  7. This file contains the class declarations for the TRIPLE_SERVER_ENUM
  8. class and its associated iterator classes.
  9. FILE HISTORY:
  10. KeithMo 17-Mar-1992 Created for the Server Manager.
  11. */
  12. #ifndef _LMOESRV3_HXX_
  13. #define _LMOESRV3_HXX_
  14. #include "lmoent.hxx"
  15. #include "lmoeusr.hxx"
  16. #include "lmoesrv.hxx"
  17. //
  18. // Change this manifest to 1 if we need to manually insert
  19. // the PDC into the list of known server trust accounts.
  20. //
  21. // This was necessary in early builds when the PDCs did
  22. // not have SAM machine accounts. Now that they do, we
  23. // don't need to manually insert the PDC into our list
  24. // of known servers.
  25. //
  26. #define FORCE_PDC 0
  27. //
  28. // This enum represents the "type" of a target server.
  29. //
  30. typedef enum _SERVER_TYPE
  31. {
  32. ActiveNtServerType,
  33. InactiveNtServerType,
  34. ActiveLmServerType,
  35. InactiveLmServerType,
  36. WfwServerType,
  37. Windows95ServerType,
  38. UnknownServerType
  39. } SERVER_TYPE, * PSERVER_TYPE;
  40. //
  41. // This enum represents the "role" of a target server.
  42. //
  43. typedef enum _SERVER_ROLE
  44. {
  45. PrimaryRole,
  46. DeadPrimaryRole,
  47. BackupRole,
  48. DeadBackupRole,
  49. WkstaRole,
  50. ServerRole,
  51. LmServerRole,
  52. UnknownRole,
  53. WkstaOrServerRole
  54. } SERVER_ROLE, * PSERVER_ROLE;
  55. //
  56. // This structure is used when merging the servers from
  57. // NT_MACHINE_ENUM with those from USER0_ENUM.
  58. //
  59. typedef struct _KNOWN_SERVER_INFO
  60. {
  61. const TCHAR * pszName;
  62. SERVER_TYPE ServerType;
  63. SERVER_ROLE ServerRole;
  64. } KNOWN_SERVER_INFO, * PKNOWN_SERVER_INFO;
  65. //
  66. // This structure is used when merging the KNOWN_SERVERS list
  67. // with those from SERVER1_ENUM.
  68. //
  69. typedef struct _TRIPLE_SERVER_INFO
  70. {
  71. const TCHAR * pszName;
  72. const TCHAR * pszComment;
  73. SERVER_TYPE ServerType;
  74. SERVER_ROLE ServerRole;
  75. UINT verMajor;
  76. UINT verMinor;
  77. ULONG TypeMask;
  78. } TRIPLE_SERVER_INFO, * PTRIPLE_SERVER_INFO;
  79. /*************************************************************************
  80. NAME: TRIPLE_SERVER_ENUM
  81. SYNOPSIS: TRIPLE_SERVER_ENUM is a "special" server enumerator
  82. used (mainly) by the Server Manager. This enumerator
  83. will enumerator servers from three different sources
  84. to get the maximum amount information about servers
  85. in a domain.
  86. INTERFACE: TRIPLE_SERVER_ENUM - Class constructor.
  87. CallAPI - Invokes the enumeration API(s).
  88. PARENT: LM_ENUM
  89. HISTORY:
  90. KeithMo 17-Mar-1992 Created for the Server Manager.
  91. **************************************************************************/
  92. DLL_CLASS TRIPLE_SERVER_ENUM : public LM_ENUM
  93. {
  94. private:
  95. //
  96. // These data members point to the "standard" enumerators
  97. // used to create this enumerator's data.
  98. //
  99. NT_MACHINE_ENUM * _pmach;
  100. USER0_ENUM * _puser;
  101. SERVER1_ENUM * _psrv;
  102. #if FORCE_PDC
  103. DOMAIN_DISPLAY_MACHINE _ddm; // fake entry for PDC
  104. #endif // FORCE_PDC
  105. //
  106. // We'll use these to keep a copy of the domain & server names.
  107. //
  108. NLS_STR _nlsDomainName;
  109. NLS_STR _nlsPrimaryName;
  110. const TCHAR * _pszPrimaryNoWhacks;
  111. BOOL _fIsNtPrimary;
  112. //
  113. // These BOOLs are used to filter the machines
  114. // produced by this enumerator.
  115. //
  116. BOOL _fAllowWkstas;
  117. BOOL _fAllowServers;
  118. BOOL _fAccountsOnly;
  119. //
  120. // This flag is set to TRUE if the target domain's PDC
  121. // is available.
  122. //
  123. BOOL _fPDCAvailable;
  124. //
  125. // This virtual callback invokes any necessary API(s).
  126. //
  127. virtual APIERR CallAPI( BYTE ** ppbBuffer,
  128. UINT * pcEntriesRead );
  129. //
  130. // These worker methods are used during the merges.
  131. //
  132. VOID MapNtToKnown( const DOMAIN_DISPLAY_MACHINE * pddm,
  133. KNOWN_SERVER_INFO * pKnownObj );
  134. VOID MapLmToKnown( const struct user_info_0 * pui0,
  135. KNOWN_SERVER_INFO * pKnownObj );
  136. VOID MapKnownToTriple( const KNOWN_SERVER_INFO * pKnownObj,
  137. TRIPLE_SERVER_INFO * pTripleObj );
  138. VOID MapBrowserToTriple( const struct server_info_1 * psi1,
  139. TRIPLE_SERVER_INFO * pTripleObj );
  140. VOID CombineIntoTriple( const struct server_info_1 * psi1,
  141. const KNOWN_SERVER_INFO * pKnownObj,
  142. TRIPLE_SERVER_INFO * pTripleObj );
  143. SERVER_ROLE MapTypeMaskToRole( ULONG TypeMask ) const;
  144. SERVER_TYPE MapTypeMaskToType( ULONG TypeMask ) const;
  145. //
  146. // These static methods are used by qsort() to sort various buffers.
  147. //
  148. static int __cdecl CompareNtServers( const void * p1,
  149. const void * p2 );
  150. static int __cdecl CompareLmServers( const void * p1,
  151. const void * p2 );
  152. static int __cdecl CompareBrowserServers( const void * p1,
  153. const void * p2 );
  154. public:
  155. //
  156. // Usual constructor/destructor goodies.
  157. //
  158. TRIPLE_SERVER_ENUM( const TCHAR * pszDomainName,
  159. const TCHAR * pszPrimaryName,
  160. BOOL fIsNtPrimary,
  161. BOOL fAllowWkstas = TRUE,
  162. BOOL fAllowServers = TRUE,
  163. BOOL fAccountsOnly = FALSE );
  164. ~TRIPLE_SERVER_ENUM( VOID );
  165. }; // class TRIPLE_SERVER_ENUM
  166. class TRIPLE_SERVER_ITER; // Forward reference.
  167. /*************************************************************************
  168. NAME: TRIPLE_SERVER_ENUM_OBJ
  169. SYNOPSIS: This is basically the return type from the
  170. TRIPLE_SERVER_ENUM_ITER iterator.
  171. INTERFACE: QueryName - Returns the server name.
  172. QueryComment - Returns the server comment.
  173. QueryType - Returns the server "type"
  174. (NT vs LM).
  175. QueryRole - Returns the server "role"
  176. (PRIMARY vs SERVER vs WKSTA).
  177. QueryMajorVer - Returns the major OS version.
  178. QueryMinorVer - Returns the minor OS version.
  179. PARENT: ENUM_OBJ_BASE
  180. HISTORY:
  181. KeithMo 17-Mar-1992 Created for the Server Manager.
  182. **************************************************************************/
  183. DLL_CLASS TRIPLE_SERVER_ENUM_OBJ : public ENUM_OBJ_BASE
  184. {
  185. public:
  186. //
  187. // Provide properly-casted buffer Query/Set methods.
  188. //
  189. const TRIPLE_SERVER_INFO * QueryBufferPtr( VOID ) const
  190. { return (const TRIPLE_SERVER_INFO *)ENUM_OBJ_BASE::QueryBufferPtr(); }
  191. VOID SetBufferPtr( const TRIPLE_SERVER_INFO * pBuffer )
  192. { ENUM_OBJ_BASE :: SetBufferPtr( (const BYTE *)pBuffer ); }
  193. //
  194. // Accessors.
  195. //
  196. DECLARE_ENUM_ACCESSOR( QueryName, const TCHAR *, pszName );
  197. DECLARE_ENUM_ACCESSOR( QueryComment, const TCHAR *, pszComment );
  198. DECLARE_ENUM_ACCESSOR( QueryType, SERVER_TYPE, ServerType );
  199. DECLARE_ENUM_ACCESSOR( QueryRole, SERVER_ROLE, ServerRole );
  200. DECLARE_ENUM_ACCESSOR( QueryMajorVer, UINT, verMajor );
  201. DECLARE_ENUM_ACCESSOR( QueryMinorVer, UINT, verMinor );
  202. DECLARE_ENUM_ACCESSOR( QueryTypeMask, ULONG, TypeMask );
  203. }; // class TRIPLE_SERVER_ENUM_OBJ
  204. DECLARE_LM_ENUM_ITER_OF( TRIPLE_SERVER, TRIPLE_SERVER_INFO );
  205. #endif // _LMOESRV3_HXX_