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.

326 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. sitesecu.h
  5. Abstract:
  6. Site Security property page definitions
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _SITESECU_H_
  14. #define _SITESECU_H_
  15. #define DEFAULT_GRANTED 0
  16. #define DEFAULT_DENIED 1
  17. class COMDLL CIPAccessDescriptor : public CObjectPlus
  18. /*++
  19. Class Description:
  20. Access description object
  21. Public Interface:
  22. CIPAccessDescriptor : Various overload constructors for the different types
  23. SetValues : Set values, overloaded on a per type basis
  24. DuplicateInList : Check to see if a duplicate entry exists in the list
  25. GrantAccess : Grant or deny access
  26. HasAccess : Query whether the object describes a 'grant' or 'deny'
  27. item
  28. IsSingle : Query whether the object describes a single IP address
  29. IsMultiple : Query whether the object describes a range of ip
  30. addresses
  31. IsDomainName : Query whether the object describes a domain name
  32. QueryIPAddress : Get the object's IP address
  33. QuerySubnetMask : Get the object's subnet mask value
  34. QueryDomainName : Get the object's domain name
  35. operator == : Comparison operator
  36. OrderByAddress : Sorting helper
  37. --*/
  38. {
  39. protected:
  40. //
  41. // Access descriptor types
  42. //
  43. enum AD_TYPE
  44. {
  45. ADT_SINGLE,
  46. ADT_MULTIPLE,
  47. ADT_DOMAIN,
  48. };
  49. //
  50. // Constructors
  51. //
  52. public:
  53. //
  54. // Construct NULL descriptor
  55. //
  56. CIPAccessDescriptor(
  57. IN BOOL fGranted = TRUE
  58. );
  59. //
  60. // Copy Constructor
  61. //
  62. CIPAccessDescriptor(
  63. IN const CIPAccessDescriptor & ac
  64. );
  65. //
  66. // Construct with ip address(ip address/subnet mask) descriptor
  67. // if subnet massk is ffffffff this describes a single ip address
  68. //
  69. CIPAccessDescriptor(
  70. IN BOOL fGranted,
  71. IN DWORD dwIpAddress,
  72. IN DWORD dwSubnetMask = NULL_IP_MASK,
  73. IN BOOL fNetworkByteOrder = FALSE
  74. );
  75. //
  76. // Construct domain name descriptor
  77. //
  78. CIPAccessDescriptor(
  79. IN BOOL fGranted,
  80. IN LPCTSTR lpstrDomain
  81. );
  82. //
  83. // Interface
  84. //
  85. public:
  86. //
  87. // Set ip address/ip range value
  88. //
  89. void SetValues(
  90. IN BOOL fGranted,
  91. IN DWORD dwIpAddress,
  92. IN DWORD dwSubnetMask = NULL_IP_MASK,
  93. BOOL fNetworkByteOrder = FALSE
  94. );
  95. //
  96. // Set domain name
  97. //
  98. void SetValues(
  99. IN BOOL fGranted,
  100. IN LPCTSTR lpstrDomain
  101. );
  102. //
  103. // Check to see if a duplicate exists in the
  104. // list.
  105. //
  106. BOOL DuplicateInList(
  107. IN CObListPlus & oblList
  108. );
  109. //
  110. // Access
  111. //
  112. public:
  113. //
  114. // Access Functions
  115. //
  116. BOOL HasAccess() const;
  117. //
  118. // Grant/deny access
  119. //
  120. void GrantAccess(
  121. IN BOOL fGranted = TRUE
  122. );
  123. //
  124. // TRUE if this item is single ip address
  125. //
  126. BOOL IsSingle() const;
  127. //
  128. // True if this item describes an ip range
  129. //
  130. BOOL IsMultiple() const;
  131. //
  132. // True if this item describes a domain name
  133. //
  134. BOOL IsDomainName() const;
  135. //
  136. // Get the ip address as a DWORD
  137. //
  138. DWORD QueryIPAddress(
  139. IN BOOL fNetworkByteOrder
  140. ) const;
  141. //
  142. // Get the ip address as ip address object
  143. //
  144. CIPAddress QueryIPAddress() const;
  145. //
  146. // Get the subnet mask as a DWORD
  147. //
  148. DWORD QuerySubnetMask(
  149. IN BOOL fNetworkByteOrder
  150. ) const;
  151. //
  152. // Get the subnet mask as an ip address object
  153. //
  154. CIPAddress QuerySubnetMask() const;
  155. //
  156. // Get the domain name
  157. //
  158. LPCTSTR QueryDomainName() const;
  159. public:
  160. //
  161. // Comparison Operator
  162. //
  163. BOOL operator ==(
  164. IN const CIPAccessDescriptor & ac
  165. ) const;
  166. //
  167. // Sorting Helper
  168. //
  169. int OrderByAddress(
  170. IN const CObjectPlus * pobAccess
  171. ) const;
  172. private:
  173. BOOL m_fGranted;
  174. AD_TYPE m_adtType;
  175. CString m_strDomain;
  176. CIPAddress m_iaIPAddress;
  177. CIPAddress m_iaSubnetMask;
  178. };
  179. //
  180. // Helper Functions
  181. //
  182. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  183. //
  184. // Convert an oblist of access descriptors to a blob
  185. //
  186. void
  187. COMDLL
  188. BuildIplBlob(
  189. IN CObListPlus & oblAccessList,
  190. IN BOOL fGrantByDefault,
  191. OUT CBlob & blob
  192. );
  193. //
  194. // Reverse the above, build an oblist of access descriptors
  195. // from a blob
  196. //
  197. DWORD
  198. COMDLL
  199. BuildIplOblistFromBlob(
  200. IN CBlob & blob,
  201. OUT CObListPlus & oblAccessList,
  202. OUT BOOL & fGrantByDefault
  203. );
  204. //
  205. // Inline Expansion
  206. //
  207. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  208. inline BOOL CIPAccessDescriptor::HasAccess() const
  209. {
  210. return m_fGranted;
  211. }
  212. inline void CIPAccessDescriptor::GrantAccess(
  213. IN BOOL fGranted
  214. )
  215. {
  216. m_fGranted = fGranted;
  217. }
  218. inline BOOL CIPAccessDescriptor::IsSingle() const
  219. {
  220. return m_adtType == ADT_SINGLE;
  221. }
  222. inline BOOL CIPAccessDescriptor::IsMultiple() const
  223. {
  224. return m_adtType == ADT_MULTIPLE;
  225. }
  226. inline BOOL CIPAccessDescriptor::IsDomainName() const
  227. {
  228. return m_adtType == ADT_DOMAIN;
  229. }
  230. inline DWORD CIPAccessDescriptor::QueryIPAddress(
  231. IN BOOL fNetworkByteOrder
  232. ) const
  233. {
  234. ASSERT(!IsDomainName());
  235. return m_iaIPAddress.QueryIPAddress(fNetworkByteOrder);
  236. }
  237. inline CIPAddress CIPAccessDescriptor::QueryIPAddress() const
  238. {
  239. ASSERT(!IsDomainName());
  240. return m_iaIPAddress;
  241. }
  242. inline DWORD CIPAccessDescriptor::QuerySubnetMask(
  243. IN BOOL fNetworkByteOrder
  244. ) const
  245. {
  246. ASSERT(!IsDomainName());
  247. return m_iaSubnetMask.QueryIPAddress(fNetworkByteOrder);
  248. }
  249. inline CIPAddress CIPAccessDescriptor::QuerySubnetMask() const
  250. {
  251. ASSERT(!IsDomainName());
  252. return m_iaSubnetMask;
  253. }
  254. inline LPCTSTR CIPAccessDescriptor::QueryDomainName() const
  255. {
  256. ASSERT(IsDomainName());
  257. return (LPCTSTR)m_strDomain;
  258. }
  259. #endif // _SITESECU_H_