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.

154 lines
2.6 KiB

  1. #define MAX_ENTRIES 20
  2. #define AGE_LIMIT_VALID_ENTRIES 300
  3. #define AGE_LIMIT_INVALID_ENTRIES 180
  4. #define CACHE_HIT 1
  5. #define CACHE_MISS 0
  6. #define INVALID_ENTRY_TYPE 0
  7. #define DOMAIN_ENTRY_TYPE 1
  8. #define COMPUTER_ENTRY_TYPE 2
  9. #define WORKGROUP_ENTRY_TYPE 3
  10. #define DOMAIN_ENTRY_TYPE_RO 4
  11. typedef struct _classentry{
  12. BOOL bInUse;
  13. SYSTEMTIME st;
  14. BOOL fCacheHit;
  15. DWORD dwElementType; // if it is type domain then we have a PDC
  16. LPWSTR pszElementName;
  17. union {
  18. LPWSTR pszDomainName;
  19. LPWSTR pszPDCName;
  20. LPWSTR pszDCName;
  21. } u;
  22. }CLASSENTRY, *PCLASSENTRY;
  23. class CObjNameCache {
  24. public:
  25. HRESULT
  26. CObjNameCache::
  27. addentry(
  28. LPWSTR pszElementName,
  29. BOOL fCacheHit,
  30. DWORD dwElementType,
  31. LPWSTR pszName // This will be PDC if Element= Domain
  32. );
  33. HRESULT
  34. CObjNameCache::
  35. findentry(
  36. LPWSTR pszElementName,
  37. PDWORD pdwIndex
  38. );
  39. HRESULT
  40. CObjNameCache::
  41. getentry(
  42. LPWSTR pszElementName,
  43. PBOOL pfHit,
  44. PDWORD pdwEntryType,
  45. LPWSTR pszName
  46. );
  47. HRESULT
  48. CObjNameCache::
  49. InvalidateStaleEntries();
  50. CObjNameCache::
  51. CObjNameCache();
  52. CObjNameCache::
  53. ~CObjNameCache();
  54. static
  55. HRESULT
  56. CObjNameCache::
  57. CreateClassCache(
  58. CObjNameCache FAR * FAR * ppClassCache
  59. );
  60. DWORD
  61. CObjNameCache::
  62. IsOlderThan(
  63. DWORD i,
  64. DWORD j
  65. );
  66. protected:
  67. DWORD _dwMaxCacheSize;
  68. CLASSENTRY _ClassEntries[MAX_ENTRIES];
  69. CRITICAL_SECTION _cs;
  70. BOOL _fCriticalSectionInitialized;
  71. };
  72. HRESULT
  73. WinNTGetCachedDCName(
  74. LPWSTR pszDomainName,
  75. LPWSTR pszPDCName,
  76. DWORD dwFlags
  77. );
  78. HRESULT
  79. WinNTGetCachedComputerName(
  80. LPWSTR pszComputerName,
  81. LPWSTR pszDomainName,
  82. LPWSTR pszSAMName,
  83. CWinNTCredentials& Credentials
  84. );
  85. //
  86. // helper function for the above
  87. //
  88. HRESULT
  89. WinNTGetCachedObject(
  90. LPWSTR pszElementName,
  91. DWORD dwElementType,
  92. LPWSTR pszName,
  93. LPWSTR pszSAMName,
  94. DWORD dwFlags,
  95. CWinNTCredentials& Credentials
  96. );
  97. HRESULT
  98. WinNTGetCachedName(
  99. LPWSTR pszElementName,
  100. PDWORD pdwElementType,
  101. LPWSTR pszName,
  102. LPWSTR pszSAMName,
  103. CWinNTCredentials& Credentials
  104. );
  105. LONG
  106. TimeDifference(
  107. SYSTEMTIME st1,
  108. SYSTEMTIME st2
  109. );
  110. BOOL
  111. IsAddressNumeric(
  112. LPWSTR HostName
  113. );
  114.