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.

103 lines
3.0 KiB

  1. #pragma once
  2. #include <ComDef.h>
  3. #include <DsGetDc.h>
  4. //
  5. // These functions are used to obtain the name of a domain controller in the
  6. // specified domain. The 4 version is for code that must be loadable on NT4
  7. // or earlier machines. The 5 version is for code that only is loaded on W2K
  8. // or later machines.
  9. //
  10. DWORD __stdcall GetDcName4(PCWSTR pszDomainName, ULONG ulFlags, _bstr_t& strNameDns, _bstr_t& strNameFlat);
  11. DWORD __stdcall GetDcName5(PCWSTR pszDomainName, ULONG ulFlags, _bstr_t& strNameDns, _bstr_t& strNameFlat);
  12. inline DWORD __stdcall GetDcName4(PCWSTR pszDomainName, ULONG ulFlags, _bstr_t& strName)
  13. {
  14. _bstr_t strNameDns;
  15. _bstr_t strNameFlat;
  16. DWORD dwError = GetDcName4(pszDomainName, ulFlags, strNameDns, strNameFlat);
  17. if (dwError == ERROR_SUCCESS)
  18. {
  19. strName = !strNameDns ? strNameFlat : strNameDns;
  20. }
  21. return dwError;
  22. }
  23. inline DWORD __stdcall GetDcName5(PCWSTR pszDomainName, ULONG ulFlags, _bstr_t& strName)
  24. {
  25. _bstr_t strNameDns;
  26. _bstr_t strNameFlat;
  27. DWORD dwError = GetDcName5(pszDomainName, ulFlags, strNameDns, strNameFlat);
  28. if (dwError == ERROR_SUCCESS)
  29. {
  30. strName = !strNameDns ? strNameFlat : strNameDns;
  31. }
  32. return dwError;
  33. }
  34. inline DWORD __stdcall GetAnyDcName4(PCWSTR pszDomainName, _bstr_t& strName)
  35. {
  36. return GetDcName4(pszDomainName, DS_DIRECTORY_SERVICE_PREFERRED, strName);
  37. }
  38. inline DWORD __stdcall GetAnyDcName5(PCWSTR pszDomainName, _bstr_t& strName)
  39. {
  40. return GetDcName5(pszDomainName, DS_DIRECTORY_SERVICE_PREFERRED, strName);
  41. }
  42. //
  43. // This function obtains the name of a
  44. // global catalog server for the specified domain.
  45. //
  46. DWORD __stdcall GetGlobalCatalogServer4(PCWSTR pszDomainName, _bstr_t& strServer);
  47. DWORD __stdcall GetGlobalCatalogServer5(PCWSTR pszDomainName, _bstr_t& strServer);
  48. //
  49. // These functions are used to obtain the flat and DNS names for a specified domain.
  50. // The 4 version is for code that must be loadable on NT4 or earlier machines. The 5
  51. // version is for code that only is loaded on W2K or later machines.
  52. //
  53. DWORD __stdcall GetDomainNames4(PCWSTR pszDomainName, _bstr_t& strFlatName, _bstr_t& strDnsName);
  54. DWORD __stdcall GetDomainNames5(PCWSTR pszDomainName, _bstr_t& strFlatName, _bstr_t& strDnsName);
  55. inline bool __stdcall GetDnsAndNetbiosFromName(PCWSTR pszName, PWSTR pszFlatName, PWSTR pszDnsName)
  56. {
  57. *pszDnsName = L'\0';
  58. *pszFlatName = L'\0';
  59. _bstr_t strDnsName;
  60. _bstr_t strFlatName;
  61. DWORD dwError = GetDomainNames4(pszName, strDnsName, strFlatName);
  62. if (dwError == ERROR_SUCCESS)
  63. {
  64. if (strDnsName.length() > 0)
  65. {
  66. wcscpy(pszDnsName, strDnsName);
  67. }
  68. if (strFlatName.length() > 0)
  69. {
  70. wcscpy(pszFlatName, strFlatName);
  71. }
  72. }
  73. return (dwError == ERROR_SUCCESS);
  74. }
  75. HRESULT __stdcall GetRidPoolAllocator4(PCWSTR pszDomainName, _bstr_t& strDnsName, _bstr_t& strFlatName);