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.

301 lines
8.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. rasdial.h
  7. Definition of CRASProfile class and CRASUser class
  8. CRASProfile handles operations related to profile object in DS,
  9. including: load, save, enumerate all the profiles
  10. CRASUser handles operations related to RASUser object in DS,
  11. including: load, save
  12. FILE HISTORY:
  13. */
  14. //////////////////////////////////////////////////////////////////////
  15. #if !defined(AFX_RASPROFILE_H__484FE2B0_20A8_11D1_8531_00C04FC31FD3__INCLUDED_)
  16. #define AFX_RASPROFILE_H__484FE2B0_20A8_11D1_8531_00C04FC31FD3__INCLUDED_
  17. #if _MSC_VER >= 1000
  18. #pragma once
  19. #endif // _MSC_VER >= 1000
  20. #include <dialinusr.h>
  21. //#include <rassapi.h>
  22. #include "helper.h"
  23. #include <sdowrap.h>
  24. #include "sharesdo.h"
  25. #include <rtutils.h>
  26. extern DWORD g_dwTraceHandle;
  27. class CRASUSER;
  28. class CRASProfile;
  29. // constant definitions for the dialogs
  30. #define MIN_METRIC 1
  31. #define MAX_METRIC 0x7fffffff
  32. #define MIN_PREFIXLEN 1
  33. #define MAX_PREFIXLEN 32
  34. // constraint dialog
  35. #define MAX_LOGINS (UD_MAXVAL - 1)
  36. #define MAX_IDLETIMEOUT (UD_MAXVAL - 1)
  37. #define MAX_SESSIONTIME (UD_MAXVAL - 1)
  38. #define MAX_PORTLIMIT (UD_MAXVAL - 1)
  39. #define MAX_PERCENT 100
  40. #define MAX_TIME (UD_MAXVAL - 1)
  41. // copy from IPSEC
  42. //TODO get rid of these bogus error codes!
  43. // These are made up numbers so I can get useful information back to
  44. // IPSECDS clients.
  45. #define E_IPSEC_DS_DATA_VERSION 0x800f0001
  46. #define E_IPSEC_DS_ADSI_EXCEPTION 0x800f0002
  47. #define E_IPSEC_DS_NO_ADMIN_ACCESS 0x800f0003
  48. #define E_IPSEC_DS_NOT_FOUND 0x800f0004
  49. #define E_IPSEC_DS_STORAGE_NOT_OPEN 0x800f0005
  50. // These are error codes I get back from ADSI which are not
  51. // defined anywhere, so I made my own defines for them.
  52. // Unfortunately, this means that I have no guarantee that these
  53. // error codes won't change in the future.
  54. #define E_IPSEC_DS_ALREADY_EXISTS 0x800700b7
  55. #define E_IPSEC_DS_SCHEMA_LOCKED 0x800703eb
  56. #define E_RAS
  57. enum RasEnvType
  58. {
  59. RASUSER_ENV_LOCAL = 1,
  60. RASUSER_ENV_DS
  61. };
  62. // Port Types definition
  63. struct CName_Code{
  64. LPCTSTR m_pszName;
  65. int m_nCode;
  66. };
  67. extern CName_Code PortTypes[];
  68. #ifdef _TUNNEL
  69. extern CName_Code TunnelTypes[];
  70. extern CName_Code TunnelMediumTypes[];
  71. #endif
  72. // enumeration buffer size
  73. #define MAX_ENUM_IADS 20
  74. //
  75. //
  76. // CRASProfile class encapsulate the RASProfile object in DS
  77. //
  78. // Data type mapping:
  79. // interger32 --> DWORD, BSTR (String) --> CString
  80. // BSTR (String) multi-value --> CStrArray
  81. // BOOLEAN --> BOOL
  82. //
  83. // Member Functions:
  84. // Load(LPCWSTR pcswzUserPath)
  85. // Purpose: Load the data from DS, and fill the data members
  86. // pcswzUserPath: the ADsPath to the user object that contains
  87. // Save(LPCWSTR pcswzUserPath)
  88. // Purpose: Save the data to DS under specified user object
  89. // pcswzUserPath: the ADsPath for the container, when NULL, the ADsPath
  90. // used for loading is used.
  91. //
  92. #define EAPTYPE_KEY_EMPTY (-1)
  93. #define IF_KEY_SUPPORT_ENCRYPTION(k) ((k) != EAPTYPE_KEY_EMPTY && (k) != 0)
  94. // profile attribute bit flags PABF
  95. #define PABF_msNPTimeOfDay 0x00000002
  96. #define PABF_msNPCalledStationId 0x00000004
  97. #define PABF_msNPAllowedPortTypes 0x00000008
  98. #define PABF_msRADIUSIdleTimeout 0x00000010
  99. #define PABF_msRADIUSSessionTimeout 0x00000020
  100. #define PABF_msRADIUSFramedIPAddress 0x00000040
  101. #define PABF_msRADIUSPortLimit 0x00000080
  102. #define PABF_msRASBapRequired 0x00000100
  103. #define PABF_msRASBapLinednLimit 0x00000200
  104. #define PABF_msRASBapLinednTime 0x00000400
  105. #define PABF_msNPAuthenticationType 0x00000800
  106. #define PABF_msNPAllowedEapType 0x00001000
  107. #define PABF_msRASEncryptionType 0x00002000
  108. #define PABF_msRASAllowEncryption 0x00004000
  109. #define PAFB_msRASFilter 0x00008000
  110. class CRASProfileMerge
  111. {
  112. public:
  113. HRESULT Save(); // To SDO
  114. HRESULT Load(); // Using SDO
  115. CRASProfileMerge(ISdo* pIProfile, ISdoDictionaryOld* pIDictionary)
  116. {
  117. ASSERT(pIProfile);
  118. ASSERT(pIDictionary);
  119. m_spIProfile = pIProfile;
  120. m_spIDictionary = pIDictionary;
  121. m_nEAPTypeKey = EAPTYPE_KEY_EMPTY;
  122. m_dwAttributeFlags = 0;
  123. m_nFiltersSize = 0;
  124. }
  125. virtual ~CRASProfileMerge()
  126. {
  127. }
  128. public:
  129. // BIT flag for each attribute
  130. DWORD m_dwAttributeFlags;
  131. // networking page
  132. DWORD m_dwFramedIPAddress;
  133. CBSTR m_cbstrFilters;
  134. UINT m_nFiltersSize; // in bytes
  135. // constraints page
  136. CDWArray m_dwArrayAllowedPortTypes;
  137. DWORD m_dwSessionTimeout;
  138. DWORD m_dwIdleTimeout;
  139. CStrArray m_strArrayCalledStationId;
  140. DWORD m_dwSessionAllowed;
  141. CStrArray m_strArrayTimeOfDay;
  142. // authentication page
  143. CDWArray m_dwArrayAuthenticationTypes;
  144. DWORD m_dwEapType;
  145. // multilink page
  146. DWORD m_dwPortLimit;
  147. DWORD m_dwBapLineDnLimit;
  148. DWORD m_dwBapLineDnTime;
  149. BOOL m_dwBapRequired;
  150. // encryption page
  151. DWORD m_dwEncryptionType;
  152. DWORD m_dwEncryptionPolicy;
  153. public:
  154. // EAP type list -- !!! Need to implement
  155. HRESULT GetEapTypeList(CStrArray& EapTypes, CDWArray& EapIds, CDWArray& EapTypeKeys, AuthProviderArray* pProvList);
  156. // to detect if driver level support 128 bit encryption,
  157. HRESULT GetRasNdiswanDriverCaps(RAS_NDISWAN_DRIVER_INFO *pInfo);
  158. // Medium Type list -- !! Need to implement
  159. HRESULT GetPortTypeList(CStrArray& Names, CDWArray& MediumIds);
  160. void SetMachineName(LPCWSTR pMachineName){ m_strMachineName = pMachineName;};
  161. // the management key of the current EAP type, -1, not set
  162. int m_nEAPTypeKey;
  163. public:
  164. CComPtr<ISdo> m_spIProfile;
  165. CComPtr<ISdoDictionaryOld> m_spIDictionary;
  166. CSdoWrapper m_SdoWrapper;
  167. CString m_strMachineName;
  168. };
  169. //
  170. // CRASUser class encapsulate the RASUser object contained in user objectin DS
  171. //
  172. // Data type mapping:
  173. // interger32 --> DWORD, BSTR (String) --> CString
  174. // BSTR (String) multi-value --> CStrArray
  175. // BOOLEAN --> BOOL
  176. //
  177. // Member Functions:
  178. // Load(LPCWSTR pcswzUserPath)
  179. // Purpose: Load the data from DS, and fill the data members
  180. // pcswzUserPath: the ADsPath to the user object that contains
  181. // Save(LPCWSTR pcswzUserPath)
  182. // Purpose: Save the data to DS under specified user object
  183. // pcswzUserPath: the ADsPath for the container, when NULL, the ADsPath
  184. // used for loading is used.
  185. // ChangeProfile(LPCWSTR pcswzProfilePath)
  186. // Purpose: use profile specified in the path
  187. // pcswzProfilePath: the ADsPath of the profile
  188. //
  189. class CMarshalSdoServer;
  190. class CRASUserMerge
  191. {
  192. public:
  193. CRASUserMerge(RasEnvType type, LPCWSTR location, LPCWSTR userPath);
  194. ~CRASUserMerge()
  195. {
  196. // to test if problem is within here, to explicitly
  197. m_spISdoServer.Release();
  198. };
  199. // read or write information from DS
  200. virtual HRESULT Load();
  201. virtual HRESULT Save();
  202. #ifdef SINGLE_SDO_CONNECTION // for share the same sdo connection for multiple users
  203. CMarshalSdoServer* GetMarshalSdoServerHolder() { return &m_MarshalSdoServer;};
  204. #endif
  205. HRESULT HrGetDCName(CString& DcName);
  206. protected:
  207. BOOL IfAccessAttribute(ULONG id);
  208. HRESULT SetRegistryFootPrint();
  209. HRESULT HrIsInMixedDomain();
  210. BOOL IsFocusOnLocalUser(){ return (!m_strMachine.IsEmpty());};
  211. protected:
  212. // data members for the RAS User attribute defined in DS
  213. // this defines if dialin is allowed, and also the policy for callback
  214. // RAS_CALLBACK_CALLERSET, RAS_CALLBACK_SECURE is the mask
  215. DWORD m_dwDialinPermit; //1: allow, 0: deny, -1: not defined
  216. DWORD m_dwDefinedAttribMask;
  217. // static IP address
  218. // when m_bStaticIPAddress == false, m_dwFramedIPAddress is invalide
  219. // m_bStaticIPAddress is not an attribute in DS
  220. DWORD m_dwFramedIPAddress;
  221. // 10/20/97 weijiang removed -- use m_dwAllowDialin to hold this value
  222. // BOOL m_bStaticIPAddress;
  223. // CALLBACK
  224. CString m_strCallbackNumber;
  225. // the static routes
  226. CStrArray m_strArrayFramedRoute;
  227. // caller id
  228. CStrArray m_strArrayCallingStationId;
  229. protected:
  230. // CComPtr<ISdo> m_spIRasUser;
  231. CComPtr<ISdoMachine> m_spISdoServer;
  232. CUserSdoWrapper m_SdoWrapper;
  233. CString m_strUserPath; // the container's ADsPath
  234. CString m_strMachine; // when it's for a machine with NO DS, this will be useful
  235. RasEnvType m_type;
  236. #ifdef SINGLE_SDO_CONNECTION // for share the same sdo connection for multiple users
  237. CMarshalSdoServer m_MarshalSdoServer;
  238. #endif
  239. };
  240. #endif // !defined(AFX_RASPROFILE_H__484FE2B0_20A8_11D1_8531_00C04FC31FD3__INCLUDED_)