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.

328 lines
11 KiB

  1. //****************************************************************************
  2. //
  3. // Module: ULS.DLL
  4. // File: localusr.h
  5. // Content: This file contains the User object definition.
  6. // History:
  7. // Wed 17-Apr-1996 11:18:47 -by- Viroon Touranachun [viroont]
  8. // Thu 1-16-97 combined localusr/localapp/ulsuser/ulsapp
  9. //
  10. // Copyright (c) Microsoft Corporation 1996-1997
  11. //
  12. //****************************************************************************
  13. #ifndef _LOCALUSER_H_
  14. #define _LOCALUSER_H_
  15. #include "connpt.h"
  16. #include "attribs.h"
  17. #include "culs.h"
  18. //****************************************************************************
  19. // Constant definition
  20. //****************************************************************************
  21. //
  22. #define LU_MOD_NONE 0x00000000
  23. #define LU_MOD_FIRSTNAME 0x00000001
  24. #define LU_MOD_LASTNAME 0x00000002
  25. #define LU_MOD_EMAIL 0x00000004
  26. #define LU_MOD_CITY 0x00000008
  27. #define LU_MOD_COUNTRY 0x00000010
  28. #define LU_MOD_COMMENT 0x00000020
  29. #define LU_MOD_FLAGS 0x00000040
  30. #define LU_MOD_IP_ADDRESS 0x00000080
  31. #define LU_MOD_GUID 0x00000100
  32. #define LU_MOD_MIME 0x00000200
  33. #define LU_MOD_ATTRIB 0x00000400
  34. #define LU_MOD_ALL (LU_MOD_FIRSTNAME + LU_MOD_LASTNAME + \
  35. LU_MOD_EMAIL + LU_MOD_CITY + \
  36. LU_MOD_COUNTRY + LU_MOD_COMMENT +\
  37. LU_MOD_FLAGS +\
  38. LU_MOD_IP_ADDRESS +\
  39. LU_MOD_GUID + LU_MOD_MIME +\
  40. LU_MOD_ATTRIB \
  41. )
  42. //****************************************************************************
  43. // Enumeration type
  44. //****************************************************************************
  45. //
  46. typedef enum {
  47. ILS_APP_SET_ATTRIBUTES,
  48. ILS_APP_REMOVE_ATTRIBUTES,
  49. } APP_CHANGE_ATTRS;
  50. typedef enum {
  51. ILS_APP_ADD_PROT,
  52. ILS_APP_REMOVE_PROT,
  53. } APP_CHANGE_PROT;
  54. // server
  55. typedef enum {
  56. ULSSVR_INVALID = 0,
  57. ULSSVR_INIT,
  58. ULSSVR_REG_USER,
  59. ULSSVR_REG_PROT,
  60. ULSSVR_CONNECT,
  61. ULSSVR_UNREG_PROT,
  62. ULSSVR_UNREG_USER,
  63. ULSSVR_RELOGON,
  64. ULSSVR_NETWORK_DOWN,
  65. } ULSSVRSTATE;
  66. //****************************************************************************
  67. // CIlsUser definition
  68. //****************************************************************************
  69. //
  70. class CIlsUser : public IIlsUser,
  71. public IConnectionPointContainer
  72. {
  73. private:
  74. /* ------ user ------ */
  75. LONG m_cRef;
  76. BOOL m_fReadonly;
  77. ULONG m_cLock;
  78. ULONG m_uModify;
  79. LPTSTR m_szID;
  80. LPTSTR m_szFirstName;
  81. LPTSTR m_szLastName;
  82. LPTSTR m_szEMailName;
  83. LPTSTR m_szCityName;
  84. LPTSTR m_szCountryName;
  85. LPTSTR m_szComment;
  86. DWORD m_dwFlags;
  87. LPTSTR m_szIPAddr;
  88. LPTSTR m_szAppName;
  89. GUID m_guid;
  90. LPTSTR m_szMimeType;
  91. CAttributes m_ExtendedAttrs;
  92. CList m_ProtList;
  93. CIlsServer *m_pIlsServer;
  94. CConnectionPoint *m_pConnPt;
  95. /* ------ server ------ */
  96. ULSSVRSTATE m_uState;
  97. HANDLE m_hLdapUser;
  98. ULONG m_uReqID;
  99. ULONG m_uLastMsgID;
  100. IEnumIlsProtocols *m_pep;
  101. private: // user
  102. STDMETHODIMP InternalGetUserInfo (BOOL fAddNew,
  103. PLDAP_CLIENTINFO *ppUserInfo,
  104. ULONG uFields);
  105. HRESULT RemoveProtocolFromList ( CLocalProt *pLocalProt );
  106. public: // user
  107. // Constructor and destructor
  108. CIlsUser (void);
  109. ~CIlsUser (void);
  110. // Lock and unlock User operation
  111. //
  112. ULONG Lock(void) {m_cLock++; return m_cLock;}
  113. ULONG Unlock(void) {m_cLock--; return m_cLock;}
  114. BOOL IsLocked(void) {return (m_cLock != 0);}
  115. STDMETHODIMP Init (BSTR bstrUserID, BSTR bstrAppName);
  116. STDMETHODIMP Init (CIlsServer *pIlsServer, PLDAP_CLIENTINFO pui);
  117. STDMETHODIMP RegisterResult(ULONG ulRegID, HRESULT hr);
  118. STDMETHODIMP UnregisterResult (ULONG uReqID, HRESULT hResult);
  119. STDMETHODIMP UpdateResult(ULONG ulUpdateID, HRESULT hr);
  120. STDMETHODIMP StateChanged ( LONG Type, BOOL fPrimary);
  121. STDMETHODIMP ProtocolChangeResult ( IIlsProtocol *pProtcol,
  122. ULONG uReqID, HRESULT hResult,
  123. APP_CHANGE_PROT uCmd);
  124. STDMETHODIMP GetProtocolResult (ULONG uReqID, PLDAP_PROTINFO_RES ppir);
  125. STDMETHODIMP EnumProtocolsResult (ULONG uReqID, PLDAP_ENUM ple);
  126. STDMETHODIMP NotifySink (void *pv, CONN_NOTIFYPROC pfn);
  127. // Internal methods
  128. STDMETHODIMP SaveChanges (void);
  129. #ifdef LATER
  130. void LocalAsyncRespond (ULONG msg, ULONG uReqID, LPARAM lParam)
  131. {PostMessage(g_hwndCulsWindow, msg, uReqID, lParam); return;}
  132. #endif //LATER
  133. // Ldap Information
  134. //
  135. HRESULT GetProtocolHandle (CLocalProt *pLocalProt, PHANDLE phProt);
  136. HRESULT RegisterLocalProtocol( BOOL fAddToList, CLocalProt *pProt, PLDAP_ASYNCINFO plai );
  137. HRESULT UnregisterLocalProtocol( CLocalProt *pProt, PLDAP_ASYNCINFO plai );
  138. HRESULT UpdateProtocol ( IIlsProtocol *pProtocol, ULONG *puReqID, APP_CHANGE_PROT uCmd );
  139. // IUnknown
  140. STDMETHODIMP QueryInterface (REFIID iid, void **ppv);
  141. STDMETHODIMP_(ULONG) AddRef (void);
  142. STDMETHODIMP_(ULONG) Release (void);
  143. // IIlsLocalUser
  144. STDMETHODIMP Clone ( IIlsUser **ppUser );
  145. STDMETHODIMP GetState (ILS_STATE *puULSState);
  146. STDMETHODIMP GetStandardAttribute(
  147. ILS_STD_ATTR_NAME stdAttr,
  148. BSTR *pbstrStdAttr);
  149. STDMETHODIMP SetStandardAttribute(
  150. ILS_STD_ATTR_NAME stdAttr,
  151. BSTR pbstrStdAttr);
  152. STDMETHODIMP GetExtendedAttribute ( BSTR bstrName, BSTR *pbstrValue );
  153. STDMETHODIMP SetExtendedAttribute ( BSTR bstrName, BSTR bstrValue );
  154. STDMETHODIMP RemoveExtendedAttribute ( BSTR bstrName );
  155. STDMETHODIMP GetAllExtendedAttributes ( IIlsAttributes **ppAttributes );
  156. STDMETHODIMP IsWritable ( BOOL *pValue);
  157. STDMETHODIMP Register ( IIlsServer *pServer, ULONG *puReqID );
  158. STDMETHODIMP Unregister( ULONG *puReqID );
  159. STDMETHODIMP Update ( ULONG *puReqID );
  160. STDMETHODIMP GetVisible ( DWORD *pfVisible );
  161. STDMETHODIMP SetVisible ( DWORD fVisible );
  162. STDMETHODIMP GetGuid ( GUID *pGuid );
  163. STDMETHODIMP SetGuid ( GUID *pGuid );
  164. STDMETHODIMP CreateProtocol(
  165. BSTR bstrProtocolID,
  166. ULONG uPortNumber,
  167. BSTR bstrMimeType,
  168. IIlsProtocol **ppProtocol);
  169. STDMETHODIMP AddProtocol(
  170. IIlsProtocol *pProtocol,
  171. ULONG *puReqID);
  172. STDMETHODIMP RemoveProtocol(
  173. IIlsProtocol *pProtocol,
  174. ULONG *puReqID);
  175. STDMETHODIMP GetProtocol(
  176. BSTR bstrProtocolID,
  177. IIlsAttributes *pAttributes,
  178. IIlsProtocol **ppProtocol,
  179. ULONG *puReqID);
  180. STDMETHODIMP EnumProtocols(
  181. IIlsFilter *pFilter,
  182. IIlsAttributes *pAttributes,
  183. IEnumIlsProtocols **ppEnumProtocol,
  184. ULONG *puReqID);
  185. // IConnectionPointContainer
  186. STDMETHODIMP EnumConnectionPoints(IEnumConnectionPoints **ppEnum);
  187. STDMETHODIMP FindConnectionPoint(REFIID riid,
  188. IConnectionPoint **ppcp);
  189. public: // server
  190. // Server registration result
  191. //
  192. HRESULT InternalRegisterNext ( HRESULT );
  193. HRESULT InternalUnregisterNext ( HRESULT );
  194. // Register/Unregister
  195. //
  196. HRESULT InternalRegister (ULONG uReqID);
  197. HRESULT InternalUnregister (ULONG uReqID);
  198. HRESULT InternalCleanupRegistration ( BOOL fKeepProtList );
  199. HRESULT EnumLocalProtocols ( IEnumIlsProtocols **pEnumProtocol );
  200. // Server properties
  201. //
  202. ILS_STATE GetULSState ( VOID );
  203. VOID SetULSState ( ULSSVRSTATE State ) { m_uState = State; }
  204. private: // server
  205. void NotifyULSRegister(HRESULT hr);
  206. void NotifyULSUnregister(HRESULT hr);
  207. HRESULT AddPendingRequest(ULONG uReqType, ULONG uMsgID);
  208. };
  209. //****************************************************************************
  210. // CEnumUsers definition
  211. //****************************************************************************
  212. //
  213. class CEnumUsers : public IEnumIlsUsers
  214. {
  215. private:
  216. LONG m_cRef;
  217. CIlsUser **m_ppu;
  218. ULONG m_cUsers;
  219. ULONG m_iNext;
  220. public:
  221. // Constructor and Initialization
  222. CEnumUsers (void);
  223. ~CEnumUsers (void);
  224. STDMETHODIMP Init (CIlsUser **ppuList, ULONG cUsers);
  225. // IUnknown
  226. STDMETHODIMP QueryInterface (REFIID iid, void **ppv);
  227. STDMETHODIMP_(ULONG) AddRef (void);
  228. STDMETHODIMP_(ULONG) Release (void);
  229. // IEnumIlsAttributes
  230. STDMETHODIMP Next(ULONG cUsers, IIlsUser **rgpu,
  231. ULONG *pcFetched);
  232. STDMETHODIMP Skip(ULONG cUsers);
  233. STDMETHODIMP Reset();
  234. STDMETHODIMP Clone(IEnumIlsUsers **ppEnum);
  235. };
  236. //****************************************************************************
  237. // CEnumLocalAppProtocols definition
  238. //****************************************************************************
  239. //
  240. class CEnumProtocols : public IEnumIlsProtocols
  241. {
  242. private:
  243. LONG m_cRef;
  244. CList m_ProtList;
  245. HANDLE hEnum;
  246. public:
  247. // Constructor and Initialization
  248. CEnumProtocols (void);
  249. ~CEnumProtocols (void);
  250. STDMETHODIMP Init (CList *pProtList);
  251. // IUnknown
  252. STDMETHODIMP QueryInterface (REFIID iid, void **ppv);
  253. STDMETHODIMP_(ULONG) AddRef (void);
  254. STDMETHODIMP_(ULONG) Release (void);
  255. // IEnumIlsProtocols
  256. STDMETHODIMP Next(ULONG cProtocols, IIlsProtocol **rgpProt,
  257. ULONG *pcFetched);
  258. STDMETHODIMP Skip(ULONG cProtocols);
  259. STDMETHODIMP Reset();
  260. STDMETHODIMP Clone(IEnumIlsProtocols **ppEnum);
  261. };
  262. #endif //_LOCALUSER_H_