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.

422 lines
12 KiB

  1. /*++
  2. Microsoft Windows NT RPC Name Service
  3. Copyright (C) Microsoft Corporation, 1995 - 1999
  4. Module Name:
  5. api.hxx
  6. Abstract:
  7. This module defines the locator class which keeps all top level
  8. state and defines the essential APIs in object form.
  9. Author:
  10. Satish Thatte (SatishT) 010/10/95 Created all the code below except where
  11. otherwise indicated.
  12. --*/
  13. #ifndef _API_
  14. #define _API_
  15. enum SystemType {
  16. Workgroup,
  17. Domain
  18. };
  19. enum LocatorRole {
  20. Master,
  21. Backup,
  22. Client
  23. };
  24. enum LookupType {
  25. BroadcastLookup,
  26. LocalLookup
  27. };
  28. class CInterfaceIndex;
  29. /*++
  30. Class Definition:
  31. Locator
  32. Abstract:
  33. The class that defines the top level operations of the locator and
  34. encapsulates its major data structures. The operations include both
  35. API-oriented methods, and utility methods.
  36. There is a possibility that this structure will be destroyed in
  37. case of domain name change and we are expected to keep locator
  38. running.
  39. We will be destroying this structure and recreating it.
  40. --*/
  41. class Locator {
  42. LocatorRole Role;
  43. SystemType System;
  44. int fDCsAreDown;
  45. TGSLEntryList * pInternalCache;
  46. // cache that maintains the list of the entries
  47. // for responding to broadcast requests.
  48. CInterfaceIndex * pCacheInterfaceIndex;
  49. // list of interfaces that actually maintains
  50. // that is in the cache on the local machine.
  51. TSLLBroadcastQP *psllBroadcastHistory;
  52. CPrivateCriticalSection PCSBroadcastHistory;
  53. CStringW *pComputerName, *pPrimaryDCName;
  54. TGSLString * pAllMasters;
  55. void InitializeDomainBasedLocator();
  56. void InitializeWorkgroupBasedLocator();
  57. BOOL SetRoleAndSystemType(DSROLE_PRIMARY_DOMAIN_INFO_BASIC dsrole);
  58. void SetCompatConfigInfo(DSROLE_PRIMARY_DOMAIN_INFO_BASIC dsrole);
  59. void SetConfigInfoFromDS(DSROLE_PRIMARY_DOMAIN_INFO_BASIC dsrole);
  60. static TGSLString *
  61. EnumDCs(
  62. CStringW * DomainName,
  63. DWORD ServerType,
  64. long lNumWanted
  65. );
  66. public:
  67. BOOL fNT4Compat;
  68. // flag that decides on whether to
  69. // provide compatibilty or not.
  70. BOOL fDSEnabled;
  71. // flag that sees whether a DS is
  72. // available in the current domain.
  73. CStringW *pRpcContainerDN;
  74. CStringW *pDomainName;
  75. CStringW *pDomainNameDns;
  76. Locator();
  77. ~Locator();
  78. unsigned long ulMaxCacheAge;
  79. READ_MAIL_SLOT *hMailslotForReplies, *hMasterFinderSlot;
  80. BOOL broadcastCleared(
  81. QueryPacket& NetRequest,
  82. ULONG cacheTolerance
  83. );
  84. void markBroadcast(
  85. QueryPacket& NetRequest
  86. )
  87. {
  88. SimpleCriticalSection me(PCSBroadcastHistory);
  89. psllBroadcastHistory->insert(new CBroadcastQueryPacket(NetRequest));
  90. }
  91. TSLLEntryListIterator *IndexLookup(
  92. CGUIDVersion * pGVinterface
  93. )
  94. {
  95. TSLLEntryList * pELL = pCacheInterfaceIndex->lookup(pGVinterface);
  96. if (pELL->size()>1) pELL->rotate(rand() % pELL->size()); // simple randomizing
  97. TSLLEntryListIterator *pIndexIter = new TSLLEntryListIterator(*pELL);
  98. delete pELL; // see CServerLookupHandle::CServerLookupHandle
  99. return pIndexIter;
  100. }
  101. CStringW* getDomainName() {
  102. return pDomainName;
  103. }
  104. CStringW* getDomainNameDns() {
  105. return pDomainNameDns;
  106. }
  107. CStringW* getComputerName() {
  108. return pComputerName;
  109. }
  110. TGSLString * getMasters() {
  111. return pAllMasters;
  112. }
  113. CStringW * getPDC() {
  114. return pPrimaryDCName;
  115. }
  116. void addMaster(STRING_T szMaster) {
  117. CStringW *pNewMaster = new CStringW(szMaster);
  118. if (Duplicate == pAllMasters->insert(pNewMaster)) delete pNewMaster;
  119. }
  120. int IsInWorkgroup() {
  121. return System == Workgroup;
  122. }
  123. int IsInMasterRole() {
  124. return Role == Master;
  125. }
  126. void becomeMasterLocator() {
  127. Role = Master;
  128. }
  129. int IsInBackupRole() {
  130. return fDCsAreDown || (Role == Backup);
  131. }
  132. void SetDCsDown() {
  133. fDCsAreDown = TRUE;
  134. }
  135. void SetDCsUp() {
  136. fDCsAreDown = FALSE;
  137. }
  138. int IsInDomain() {
  139. return System == Domain;
  140. }
  141. int IsSelf(
  142. STRING_T szName
  143. )
  144. {
  145. return CStringW(szName) == *pComputerName;
  146. }
  147. CEntry * findEntry(CStringW * pName) {
  148. return pInternalCache->find(pName);
  149. }
  150. CFullServerEntry *
  151. GetEntryFromCache(
  152. UNSIGNED32 EntryNameSyntax,
  153. STRING_T EntryName
  154. );
  155. void
  156. respondToLocatorSeeker(
  157. IN QUERYLOCATOR Query
  158. );
  159. void
  160. TryBroadcastingForMasterLocator();
  161. BOOL
  162. nsi_binding_export(
  163. UNSIGNED32 EntryNameSyntax,
  164. STRING_T EntryName,
  165. NSI_INTERFACE_ID_T * Interface,
  166. NSI_SERVER_BINDING_VECTOR_T * BindingVector,
  167. NSI_UUID_VECTOR_P_T ObjectVector,
  168. IN ExportType type
  169. );
  170. void
  171. nsi_mgmt_binding_unexport(
  172. UNSIGNED32 EntryNameSyntax,
  173. STRING_T EntryName,
  174. NSI_IF_ID_P_T Interface,
  175. UNSIGNED32 VersOption,
  176. NSI_UUID_VECTOR_P_T ObjectVector
  177. );
  178. NSI_NS_HANDLE_T
  179. nsi_binding_lookup_begin(
  180. UNSIGNED32 EntryNameSyntax,
  181. STRING_T EntryName,
  182. NSI_INTERFACE_ID_T * Interface,
  183. NSI_UUID_P_T Object,
  184. UNSIGNED32 VectorSize,
  185. UNSIGNED32 MaxCacheAge,
  186. LookupType type
  187. );
  188. CLookupHandle *
  189. nsi_binding_lookup_begin_null(
  190. CGUIDVersion * pGVinterface,
  191. CGUIDVersion * pGVsyntax,
  192. CGUID * pIDobject,
  193. UNSIGNED32 ulVectorSize,
  194. UNSIGNED32 MaxCacheAge,
  195. int * fTentativeStatus
  196. );
  197. CLookupHandle *
  198. nsi_binding_lookup_begin_name(
  199. UNSIGNED32 EntryNameSyntax,
  200. STRING_T EntryName,
  201. CGUIDVersion * pGVinterface,
  202. CGUIDVersion * pGVsyntax,
  203. CGUID * pIDobject,
  204. UNSIGNED32 ulVectorSize,
  205. UNSIGNED32 MaxCacheAge,
  206. LookupType type,
  207. int * fTentativeStatus
  208. );
  209. NSI_NS_HANDLE_T
  210. nsi_entry_object_inq_begin(
  211. UNSIGNED32 EntryNameSyntax,
  212. STRING_T EntryName,
  213. LookupType type
  214. );
  215. void
  216. nsi_profile_elt_add(
  217. IN UNSIGNED32 profile_name_syntax,
  218. IN STRING_T profile_name,
  219. IN NSI_IF_ID_P_T if_id,
  220. IN UNSIGNED32 member_name_syntax,
  221. IN STRING_T member_name,
  222. IN UNSIGNED32 priority,
  223. IN STRING_T annotation
  224. );
  225. void
  226. nsi_profile_elt_remove(
  227. IN UNSIGNED32 profile_name_syntax,
  228. IN STRING_T profile_name,
  229. IN NSI_IF_ID_P_T if_id,
  230. IN UNSIGNED32 member_name_syntax,
  231. IN STRING_T member_name
  232. );
  233. void nsi_group_mbr_add(
  234. IN UNSIGNED32 group_name_syntax,
  235. IN STRING_T group_name,
  236. IN UNSIGNED32 member_name_syntax,
  237. IN STRING_T member_name
  238. );
  239. void nsi_group_mbr_remove(
  240. IN UNSIGNED32 group_name_syntax,
  241. IN STRING_T group_name,
  242. IN UNSIGNED32 member_name_syntax,
  243. IN STRING_T member_name
  244. );
  245. NSI_NS_HANDLE_T nsi_group_mbr_inq_begin(
  246. IN UNSIGNED32 group_name_syntax,
  247. IN STRING_T group_name,
  248. IN UNSIGNED32 member_name_syntax
  249. );
  250. NSI_NS_HANDLE_T nsi_profile_elt_inq_begin(
  251. IN UNSIGNED32 profile_name_syntax,
  252. IN STRING_T profile_name,
  253. IN UNSIGNED32 inquiry_type,
  254. IN NSI_IF_ID_P_T if_id,
  255. IN UNSIGNED32 vers_option,
  256. IN UNSIGNED32 member_name_syntax,
  257. IN STRING_T member_name
  258. );
  259. void
  260. nsi_mgmt_entry_create(
  261. IN UNSIGNED32 entry_name_syntax,
  262. IN STRING_T entry_name
  263. );
  264. void
  265. nsi_mgmt_entry_delete(
  266. IN UNSIGNED32 entry_name_syntax,
  267. IN STRING_T entry_name,
  268. EntryType entry_type
  269. );
  270. void
  271. nsi_group_delete(
  272. UNSIGNED32 group_name_syntax,
  273. STRING_T group_name
  274. );
  275. void
  276. nsi_profile_delete(
  277. UNSIGNED32 profile_name_syntax,
  278. STRING_T profile_name
  279. );
  280. // The functions that actually puts it in the DS.
  281. HRESULT
  282. CreateEntryInDS(CEntryName *pEntryName);
  283. //-----------------------
  284. void
  285. UpdateCache(
  286. STRING_T entry_name,
  287. UNSIGNED32 entry_name_syntax,
  288. RPC_SYNTAX_IDENTIFIER rsiInterface,
  289. RPC_SYNTAX_IDENTIFIER rsiTransferSyntax,
  290. STRING_T string,
  291. NSI_UUID_VECTOR_P_T pUuidVector,
  292. TSSLEntryList * psslTempNetCache
  293. );
  294. CRemoteLookupHandle *
  295. NetLookup(
  296. UNSIGNED32 EntryNameSyntax,
  297. STRING_T EntryName,
  298. CGUIDVersion * pGVInterface,
  299. CGUIDVersion * pGVTransferSyntax,
  300. CGUID * pIDobject,
  301. unsigned long ulVectorSize,
  302. unsigned long ulCacheAge
  303. );
  304. CLookupHandle *
  305. DSLookup(
  306. UNSIGNED32 EntryNameSyntax,
  307. STRING_T EntryName,
  308. CGUIDVersion * pGVInterface,
  309. CGUIDVersion * pGVTransferSyntax,
  310. CGUID * pIDobject,
  311. unsigned long ulVectorSize,
  312. unsigned long ulCacheAge
  313. );
  314. CObjectInqHandle *
  315. NetObjectInquiry(
  316. UNSIGNED32 EntryNameSyntax,
  317. STRING_T EntryName
  318. );
  319. };
  320. #endif _API_