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.

189 lines
5.3 KiB

  1. /*++
  2. Module Name:
  3. NetUtils.h
  4. Abstract:
  5. This is the header file for the utility functions for Network APIs.
  6. */
  7. #ifndef _NETUTILS_H
  8. #define _NETUTILS_H
  9. #include "stdafx.h"
  10. #include <wtypes.h> // For define types like DWORD, HANDLE etc.
  11. #include <oleauto.h> // For SysAllocString().
  12. #include <lmerr.h> // For Lan Manager API error codes and return value types.
  13. #include <lmcons.h> // For Lan Manager API constants.
  14. #include <lmserver.h> // For Server specific Lan Manager APIs.
  15. #include <lmaccess.h> // For NetGetDCInfo.
  16. #include <lmapibuf.h> // For NetApiBufferFree.
  17. #include <shlobj.h>
  18. #include <dsclient.h>
  19. #include <lmwksta.h>
  20. #include <lmshare.h>
  21. #include <icanon.h> // I_Net
  22. #include "dfsenums.h"
  23. #include <list>
  24. using namespace std;
  25. class NETNAME // Structure to store and send a list of names
  26. {
  27. public:
  28. CComBSTR bstrNetName; // To store Name of Domain, Server, Share etc.
  29. };
  30. typedef list<NETNAME*> NETNAMELIST;
  31. class ROOTINFO
  32. {
  33. public:
  34. CComBSTR bstrRootName;
  35. enum DFS_TYPE enumRootType;
  36. };
  37. typedef list<ROOTINFO*> ROOTINFOLIST;
  38. class SUBSCRIBER
  39. {
  40. public:
  41. CComBSTR bstrMemberDN;
  42. CComBSTR bstrRootPath;
  43. };
  44. typedef list<SUBSCRIBER*> SUBSCRIBERLIST;
  45. /*----------------------------------------------------------------------
  46. H E L P E R F U N C T I O N S
  47. ------------------------------------------------------------------------*/
  48. // Recursive function to flatten the domain tree returned by GetDomains() method
  49. // of IBrowserDomainTree into a NETNAME list.
  50. // This is done by using a depth first algorithm.
  51. // Used in Get50Domains().
  52. HRESULT FlatAdd
  53. (
  54. IN DOMAIN_DESC* i_pDomDesc, // Pointer to the Domain Description Structure returned by IBrowserDomainTree::GetDomains()
  55. OUT NETNAMELIST* o_pDomainList // Pointer to the list of NETNAME is returned here.
  56. );
  57. /*----------------------------------------------------------------------
  58. D O M A I N R E L A T E D F U N C T I O N S
  59. ------------------------------------------------------------------------*/
  60. // Returns the list of all 5.0 domains present in the DS Domain Tree only.
  61. // The domain names will be in DNS forms
  62. HRESULT Get50Domains
  63. (
  64. OUT NETNAMELIST* o_pDomains // List of NETNAME structures.
  65. );
  66. // Contacts the domain and determines if it is 5.0 Domain.
  67. // The domain name can be in DNS form.
  68. // returns the netbios name if second parameter is not null.
  69. HRESULT Is50Domain
  70. (
  71. IN BSTR i_bstrDomain,
  72. OUT BSTR* o_bstrDnsDomainName = NULL
  73. );
  74. /*----------------------------------------------------------------------
  75. S E R V E R R E L A T E D F U N C T I O N S
  76. ------------------------------------------------------------------------*/
  77. // Gets the domain, and OS version of a machine.
  78. // If the last parameter in not null the the current
  79. // machine name is returned in it.
  80. HRESULT GetServerInfo
  81. (
  82. IN BSTR i_bstrServer, // NULL means use current server.
  83. OUT BSTR *o_pbstrDomain = NULL,
  84. OUT BSTR *o_pbstrNetbiosName = NULL,
  85. OUT BOOL *o_pbValidDSObject = NULL,
  86. OUT BSTR *o_pbstrDnsName = NULL,
  87. OUT BSTR *o_pbstrGuid = NULL,
  88. OUT BSTR *o_pbstrFQDN = NULL,
  89. OUT SUBSCRIBERLIST *o_pFRSRootList = NULL,
  90. OUT long *o_lMajorNo = NULL,
  91. OUT long *o_lMinorNo = NULL
  92. );
  93. HRESULT IsServerRunningDfs
  94. (
  95. IN BSTR i_bstrServer
  96. );
  97. BOOL CheckReparsePoint(IN BSTR i_bstrServer, IN BSTR i_bstrShare);
  98. HRESULT CheckShare
  99. (
  100. IN BSTR i_bstrServer,
  101. IN BSTR i_bstrShare,
  102. OUT BOOL* o_pbFound
  103. );
  104. HRESULT CreateShare
  105. (
  106. IN BSTR i_bstrServerName,
  107. IN BSTR i_bstrShareName,
  108. IN BSTR i_bstrComment,
  109. IN BSTR i_bstrPath
  110. );
  111. // Checks if \\<server>\<share>\x\y\z is on a valid disktree share
  112. // and return the path local to the server
  113. HRESULT GetFolderInfo
  114. (
  115. IN BSTR i_bstrServerName, // <server>
  116. IN BSTR i_bstrFolder, // <share>\x\y\z
  117. OUT BSTR *o_bstrPath = NULL // return <share path>\x\y\z
  118. );
  119. void FreeNetNameList(NETNAMELIST *pList);
  120. void FreeRootInfoList(ROOTINFOLIST *pList);
  121. void FreeSubscriberList(SUBSCRIBERLIST *pList);
  122. HRESULT GetLocalComputerName(OUT BSTR* o_pbstrComputerName);
  123. HRESULT
  124. GetDomainDfsRoots(
  125. OUT NETNAMELIST* o_pDfsRootList,
  126. IN LPCTSTR i_lpszDomainName
  127. );
  128. HRESULT
  129. GetMultiDfsRoots(
  130. OUT ROOTINFOLIST* o_pDfsRootList,
  131. IN LPCTSTR i_lpszScope
  132. );
  133. /*
  134. bool
  135. IsDfsPath
  136. (
  137. LPTSTR i_lpszNetPath
  138. );
  139. */
  140. HRESULT CheckUNCPath(
  141. IN LPCTSTR i_lpszPath
  142. );
  143. HRESULT GetUNCPathComponent(
  144. IN LPCTSTR i_lpszPath,
  145. OUT BSTR* o_pbstrComponent,
  146. IN UINT i_nStartBackslashes, // index starting from 1
  147. IN UINT i_nEndBackslashes // index starting from 1
  148. );
  149. BOOL FilterMatch(LPCTSTR lpszString, FILTERDFSLINKS_TYPE lLinkFilterType, LPCTSTR lpszFilter);
  150. HRESULT IsHostingDfsRoot(IN BSTR i_bstrServer, OUT BSTR* o_pbstrRootEntryPath = NULL);
  151. /*
  152. void GetTimeDelta(LPCTSTR str, SYSTEMTIME* ptime0, SYSTEMTIME* ptime1);
  153. */
  154. #endif //#ifndef _NETUTILS_H