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.

226 lines
6.5 KiB

  1. /* ----------------------------------------------------------------------
  2. Module: ULS.DLL (Service Provider)
  3. File: spclient.h
  4. Content: This file contains the client object definition.
  5. History:
  6. 10/15/96 Chu, Lon-Chan [lonchanc]
  7. Created.
  8. Copyright (c) Microsoft Corporation 1996-1997
  9. ---------------------------------------------------------------------- */
  10. #ifndef _ILS_SP_CLIENTOBJ_H_
  11. #define _ILS_SP_CLIENTOBJ_H_
  12. #include <pshpack8.h>
  13. // Enumeration constants to represent client object members
  14. //
  15. enum
  16. {
  17. /* -- the following is for user -- */
  18. ENUM_CLIENTATTR_CN,
  19. ENUM_CLIENTATTR_FIRST_NAME,
  20. ENUM_CLIENTATTR_LAST_NAME,
  21. ENUM_CLIENTATTR_EMAIL_NAME,
  22. ENUM_CLIENTATTR_CITY_NAME,
  23. ENUM_CLIENTATTR_COMMENT,
  24. ENUM_CLIENTATTR_IP_ADDRESS,
  25. ENUM_CLIENTATTR_FLAGS,
  26. ENUM_CLIENTATTR_C,
  27. /* -- the following is for app -- */
  28. ENUM_CLIENTATTR_APP_NAME,
  29. ENUM_CLIENTATTR_APP_MIME_TYPE,
  30. ENUM_CLIENTATTR_APP_GUID,
  31. ENUM_CLIENTATTR_PROT_NAME,
  32. ENUM_CLIENTATTR_PROT_MIME,
  33. ENUM_CLIENTATTR_PROT_PORT,
  34. /* -- the above are resolvable -- */
  35. ENUM_CLIENTATTR_CLIENT_SIG,
  36. ENUM_CLIENTATTR_TTL,
  37. /* -- the above are changeable standard attributes for RTPerson -- */
  38. /* --- DO NOT ADD NEW ATTRIBUTES BELOW THIS LINE --- */
  39. /* --- COUNT_ENUM_REG_USER relies on this ---- */
  40. ENUM_CLIENTATTR_OBJECT_CLASS,
  41. ENUM_CLIENTATTR_O,
  42. COUNT_ENUM_CLIENTATTR
  43. };
  44. // Derived constants
  45. //
  46. #define COUNT_ENUM_REG_APP 6
  47. #define COUNT_ENUM_SET_APP_INFO 16
  48. #define COUNT_ENUM_SKIP_APP_ATTRS COUNT_ENUM_REG_APP
  49. #define COUNT_ENUM_CLIENT_INFO (ENUM_CLIENTATTR_TTL + 1)
  50. #define COUNT_ENUM_REG_USER (COUNT_ENUM_CLIENTATTR - 2 - COUNT_ENUM_SKIP_APP_ATTRS) // excluding o and objectClass
  51. #define COUNT_ENUM_SET_USER_INFO (ENUM_CLIENTATTR_C + 1)
  52. #define COUNT_ENUM_DIR_CLIENT_INFO (ENUM_CLIENTATTR_C + 1) // count of attrs in dir dlg
  53. #define COUNT_ENUM_RES_CLIENT_INFO (ENUM_CLIENTATTR_CLIENT_SIG - 1) // count of attrs resolvable
  54. // Shorthands for commonly used names
  55. //
  56. extern const TCHAR *c_apszClientStdAttrNames[];
  57. #define STR_CLIENT_CN (TCHAR *) c_apszClientStdAttrNames[ENUM_CLIENTATTR_CN]
  58. #define STR_CLIENT_O (TCHAR *) c_apszClientStdAttrNames[ENUM_CLIENTATTR_O]
  59. #define STR_CLIENT_C (TCHAR *) c_apszClientStdAttrNames[ENUM_CLIENTATTR_C]
  60. #define STR_CLIENT_IP_ADDR (TCHAR *) c_apszClientStdAttrNames[ENUM_CLIENTATTR_IP_ADDRESS]
  61. #define STR_CLIENT_TTL (TCHAR *) c_apszClientStdAttrNames[ENUM_CLIENTATTR_TTL]
  62. #define STR_CLIENT_APP_NAME (TCHAR *) c_apszClientStdAttrNames[ENUM_CLIENTATTR_APP_NAME]
  63. // Flags to indicate which fields are valid in CLIENT_INFO
  64. //
  65. #define CLIENTOBJ_F_CN 0x0001
  66. #define CLIENTOBJ_F_FIRST_NAME 0x0002
  67. #define CLIENTOBJ_F_LAST_NAME 0x0004
  68. #define CLIENTOBJ_F_EMAIL_NAME 0x0008
  69. #define CLIENTOBJ_F_CITY_NAME 0x0010
  70. #define CLIENTOBJ_F_C 0x0020
  71. #define CLIENTOBJ_F_COMMENT 0x0040
  72. #define CLIENTOBJ_F_IP_ADDRESS 0x0080
  73. #define CLIENTOBJ_F_FLAGS 0x0100
  74. #define CLIENTOBJ_F_APP_NAME 0x1000
  75. #define CLIENTOBJ_F_APP_MIME_TYPE 0x2000
  76. #define CLIENTOBJ_F_APP_GUID 0x4000
  77. #define CLIENTOBJ_F_USER_MASK 0x0FFF
  78. #define CLIENTOBJ_F_APP_MASK 0xF000
  79. // Client Info structure
  80. //
  81. typedef struct
  82. {
  83. DWORD dwFlags;
  84. // the following is to cache attributes
  85. TCHAR *apszStdAttrValues[COUNT_ENUM_CLIENTATTR];
  86. ANY_ATTRS AnyAttrs;
  87. // the following is scratch buffers
  88. TCHAR szIPAddress[INTEGER_STRING_LENGTH];
  89. TCHAR szFlags[INTEGER_STRING_LENGTH];
  90. TCHAR szTTL[INTEGER_STRING_LENGTH];
  91. TCHAR szClientSig[INTEGER_STRING_LENGTH];
  92. TCHAR szGuid[sizeof (GUID) * 2 + 2];
  93. }
  94. CLIENT_INFO;
  95. // A flag to indicate that this client object is valid
  96. //
  97. #define CLIENTOBJ_SIGNATURE ((ULONG) 0x12345678UL)
  98. // Client class
  99. //
  100. class SP_CClient
  101. {
  102. friend class SP_CRefreshScheduler;
  103. friend class SP_CProtocol;
  104. public:
  105. SP_CClient ( DWORD_PTR dwContext );
  106. ~SP_CClient ( VOID );
  107. ULONG AddRef ( VOID );
  108. ULONG Release ( VOID );
  109. HRESULT Register ( ULONG uRespID, SERVER_INFO *pServerInfo, LDAP_CLIENTINFO *pInfo );
  110. HRESULT UnRegister ( ULONG uRespID );
  111. HRESULT SetAttributes ( ULONG uRespID, LDAP_CLIENTINFO *pInfo );
  112. HRESULT UpdateIPAddress ( VOID );
  113. VOID SetRegNone ( VOID ) { m_RegStatus = ILS_REG_STATUS_NONE; }
  114. VOID SetRegLocally ( VOID ) { m_RegStatus = ILS_REG_STATUS_LOCALLY; }
  115. VOID SetRegRemotely ( VOID ) { m_RegStatus = ILS_REG_STATUS_REMOTELY; }
  116. BOOL IsRegistered ( VOID ) { return (m_RegStatus > ILS_REG_STATUS_NONE); }
  117. BOOL IsRegLocally ( VOID ) { return (m_RegStatus == ILS_REG_STATUS_LOCALLY); }
  118. BOOL IsRegRemotely ( VOID ) { return (m_RegStatus == ILS_REG_STATUS_REMOTELY); }
  119. BOOL IsValidObject ( VOID ) { return m_uSignature == CLIENTOBJ_SIGNATURE; }
  120. SERVER_INFO *GetServerInfo ( VOID ) { return &m_ServerInfo; }
  121. ULONG GetTTL ( VOID ) { return m_uTTL; }
  122. DWORD_PTR GetContext ( VOID ) { return m_dwContext; }
  123. protected:
  124. HRESULT AddProtocol ( ULONG uNotifyMsg, ULONG uRespID, SP_CProtocol *pProt );
  125. HRESULT RemoveProtocol ( ULONG uNotifyMsg, ULONG uRespID, SP_CProtocol *pProt );
  126. HRESULT UpdateProtocols ( ULONG uNotifyMsg, ULONG uRespID, SP_CProtocol *pProt );
  127. TCHAR *GetDN ( VOID ) { return m_pszDN; }
  128. ULONG GetAppPrefixCount ( VOID ) { return 2; }
  129. TCHAR *GetAppPrefixString ( VOID ) { return m_pszAppPrefix; }
  130. HRESULT SendRefreshMsg ( VOID );
  131. private:
  132. HRESULT RegisterUser ( VOID );
  133. HRESULT RegisterApp ( VOID );
  134. HRESULT UnRegisterUser ( VOID );
  135. HRESULT UnRegisterApp ( VOID );
  136. HRESULT SetUserAttributes ( VOID );
  137. HRESULT SetAppAttributes ( VOID );
  138. HRESULT CacheClientInfo ( LDAP_CLIENTINFO *pInfo );
  139. HRESULT CreateRegUserModArr ( LDAPMod ***pppMod );
  140. HRESULT CreateRegAppModArr ( LDAPMod ***pppMod );
  141. HRESULT CreateSetUserAttrsModArr ( LDAPMod ***pppMod );
  142. HRESULT CreateSetAppAttrsModArr ( LDAPMod ***pppMod );
  143. HRESULT CreateSetProtModArr ( LDAPMod ***pppMod );
  144. VOID FillModArrAttr ( LDAPMod *pMod, INT nIndex );
  145. BOOL IsOverAppAttrLine ( LONG i ) { return (ENUM_CLIENTATTR_APP_NAME <= (i)); }
  146. BOOL IsExternalIPAddressPassedIn ( VOID ) { return (m_ClientInfo.dwFlags & CLIENTOBJ_F_IP_ADDRESS); }
  147. LONG m_cRefs;
  148. ULONG m_uSignature;
  149. SERVER_INFO m_ServerInfo;
  150. CLIENT_INFO m_ClientInfo;
  151. CList m_Protocols;
  152. TCHAR *m_pszDN;
  153. TCHAR *m_pszAppPrefix;
  154. TCHAR *m_pszRefreshFilter;
  155. REG_STATUS m_RegStatus;
  156. BOOL m_fExternalIPAddress;
  157. DWORD m_dwIPAddress;
  158. ULONG m_uTTL;
  159. DWORD_PTR m_dwContext; // COM layer context
  160. };
  161. #include <poppack.h>
  162. #endif // _ILS_SP_USEROBJ_H_
  163.