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.

436 lines
19 KiB

  1. //*********************************************************************
  2. //* Microsoft Internet Explorer **
  3. //* Copyright (c) Microsoft Corporation. All rights reserved. **
  4. //*********************************************************************
  5. #ifndef _MSLUAPI_H_
  6. #define _MSLUAPI_H_
  7. #ifdef USER_SETTINGS_IMPLEMENTED
  8. /************************************************************************
  9. IUserSettings interface
  10. This interface is used to manipulate the settings for a particular component,
  11. corresponding to a local user account. An IUserSettings interface may be
  12. obtained by CLSID or name, or through enumeration; in both cases, this is
  13. relative to a particular user.
  14. Member functions, other than IUnknown:
  15. GetCLSID(CLSID *pclsidOut)
  16. Returns the CLSID identifying the component. May be GUID_NULL if no
  17. CLSID is defined for the component.
  18. GetName(LPSTR pbBuffer, UINT cbBuffer)
  19. Returns a unique name identifying the component. This may be used
  20. instead of a CLSID if the component provider does not wish to provide
  21. a COM server to help administer the settings.
  22. GetDisplayName(LPSTR pbBuffer, UINT cbBuffer)
  23. Returns a user-friendly name for the component, suitable for presentation
  24. to the user.
  25. QueryKey(HKEY *phkeyOut)
  26. Returns a registry key where the component stores settings for the
  27. specified user. The key is owned by the interface and must not be
  28. closed by the application using RegCloseKey, otherwise changes will
  29. not be propagated correctly.
  30. ((((
  31. OpenKey(HKEY *phkeyOut, DWORD fdwAccess)
  32. Returns a registry key where the component stores settings for the
  33. specified user. The key MUST be closed using IUserSettings::CloseKey
  34. so that changes will be propagated correctly. fdwAccess indicates
  35. the type of access desired; valid values include GENERIC_READ and
  36. GENERIC_WRITE.
  37. CloseKey(HKEY hKey)
  38. Closes a registry key obtained via IUserSettings::OpenKey.
  39. Lock(BOOL fLock)
  40. Locks or unlocks the settings for updates. Attempting to lock the
  41. settings will fail if they are already locked. Locking the settings
  42. does not, however, affect any of the other member functions
  43. ))))
  44. ************************************************************************/
  45. DECLARE_INTERFACE_(IUserSettings, IUnknown)
  46. {
  47. // *** IUnknown methods ***
  48. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  49. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  50. STDMETHOD_(ULONG,Release) (THIS) PURE;
  51. STDMETHOD(GetCLSID) (THIS_ CLSID *pclsidOut) PURE;
  52. STDMETHOD(GetName) (THIS_ LPSTR pbBuffer, LPDWORD pcbBuffer) PURE;
  53. STDMETHOD(GetDisplayName) (THIS_ LPSTR pbBuffer, LPDWORD pcbBuffer) PURE;
  54. STDMETHOD(QueryKey) (THIS_ HKEY *phkeyOut) PURE;
  55. };
  56. #endif /* USER_SETTINGS_IMPLEMENTED */
  57. /************************************************************************
  58. IUser interface
  59. This interface is used to manipulate a local user account. It allows
  60. various operations to be performed on a particular user. To obtain one
  61. of these interfaces, the companion interface IUserDatabase must be
  62. used -- its AddUser, GetUser, and GetCurrentUser member functions all
  63. return IUser objects, as does IEnumUsers::Next.
  64. In all descriptions here, "the user" refers to the user which this
  65. ILocalUser object describes. "The current user" means the user who
  66. is currently logged on at the workstation.
  67. If the current user is a supervisor, all functions are allowed. Otherwise,
  68. a more limited set of member functions is available if the IUser object
  69. corresponds to the current user. If the current user is not a supervisor
  70. and the IUser object refers to a different user, a still more limited set
  71. of functions is allowed.
  72. Member functions, other than IUnknown:
  73. GetName(LPSTR pbBuffer, UINT cbBuffer)
  74. Returns the user's logon name.
  75. GetProfileDirectory(LPSTR pbBuffer, UINT cbBuffer)
  76. Returns the user's local profile directory (e.g., C:\WINDOWS\PROFILES\gregj).
  77. May fail if the user is the default user (doesn't really have a profile
  78. directory as such).
  79. IsSupervisor()
  80. Returns whether the user is a supervisor or not. This is not a generic
  81. property because it's actually based on the presence of security info
  82. in the user's PWL (at least on win95).
  83. SetSupervisorPrivilege(BOOL fMakeSupervisor, LPCSTR pszSupervisorPassword)
  84. Grants or revokes supervisor privilege for the user. Only supervisors
  85. can grant or revoke that privilege, of course. If pszSupervisorPassword
  86. is not NULL, it is used to determine whether the current user is a
  87. supervisor. If it is NULL, then the current user's password cache is
  88. used instead. This allows making any user into a supervisor without
  89. the current user being one.
  90. MakeTempSupervisor(BOOL fMakeSupervisor, LPCSTR pszSupervisorPassword)
  91. Grants or revokes supervisor privilege for the user, but only for the
  92. lifetime of this IUser object. As soon as the object is destroyed,
  93. the user is no longer considered a supervisor, and in fact other IUser
  94. objects currently in existence which refer to the same user will not
  95. indicate him as a supervisor.
  96. Note that MakeTempSupervisor(FALSE) only revokes temporary-supervisor
  97. privilege granted by MakeTempSupervisor(TRUE). If the user still has
  98. the supervisor password in his PWL, he will still be considered a
  99. supervisor.
  100. AppearsSupervisor()
  101. Returns whether or not the user should appear as a supervisor in a list
  102. of users. This allows querying this property on each user for display
  103. purposes without taking the large performance hit to locate each user's
  104. PWL, open it up, get the supervisor key out, and validate it. Instead,
  105. a registry value under the user's key is used to maintain this value.
  106. It should NOT be used to determine whether the user has permission to
  107. do something, because the simple registry value is not as secure.
  108. Authenticate(LPCSTR pszPassword)
  109. Attempts to authenticate the user using the given password. Returns
  110. S_OK if the password is correct for the user, or an error otherwise.
  111. No user interface is displayed by this function.
  112. ChangePassword(LPCSTR pszOldPassword, LPCSTR pszNewPassword)
  113. Attempts to change the user's password from the given old password
  114. to the given new password. Returns an error code indicating success
  115. or failure. If the current user is a supervisor, the old password
  116. may be NULL, in which case the supervisor's credentials are used to
  117. get the password via other means.
  118. GetPasswordCache(LPCSTR pszPassword, LPHPWL phOut)
  119. Returns a handle to the user's password cache, suitable for use with
  120. the MSPWL32.DLL APIs. May fail, of course, if password caching is
  121. disabled.
  122. LoadProfile(LPHKEY phkeyUser)
  123. Loads the user's profile into the registry and returns a handle to the
  124. root key. The current user can always load his own profile (just returns
  125. HKEY_CURRENT_USER); to load other users' profiles, the current user must
  126. be a supervisor. IUser::UnloadProfile() should always be called when the
  127. caller is done playing with the user's profile.
  128. UnloadProfile(HKEY hkeyUser)
  129. Unloads the user's profile from the registry if possible, and closes the
  130. key handle returned by IUser::LoadProfile. If the specified user is the
  131. current user, this function does nothing.
  132. GetComponentSettings(REFCLSID clsidComponent, LPCSTR pszName,
  133. IUnknown **ppOut, DWORD fdwAccess)
  134. CURRENTLY NOT IMPLEMENTED
  135. Returns an IUserSettings interface which can be used to access the
  136. user's settings for a particular component. Either clsidComponent or
  137. pszName may be used to refer to the component whose settings are to be
  138. accessed. If pszName is not NULL, it takes precedence over clsidComponent.
  139. fdwAccess specifies whether the caller wants read or write access to the
  140. settings. If the component's settings are restricted and the current user
  141. is not a supervisor, only GENERIC_READ access will be allowed;
  142. GENERIC_WRITE will fail.
  143. EnumerateComponentSettings(IEnumUnknown **ppOut, DWORD fdwAccess)
  144. CURRENTLY NOT IMPLEMENTED
  145. Returns an IEnumUnknown interface which can be used to enumerate all
  146. components which have settings recorded for the user. fdwAccess
  147. specifies the desired access, read or write. If the current user
  148. is not a supervisor and the caller requests write access, the enumerator
  149. will not return any components which do not permit such access.
  150. ************************************************************************/
  151. DECLARE_INTERFACE_(IUser, IUnknown)
  152. {
  153. // *** IUnknown methods ***
  154. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  155. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  156. STDMETHOD_(ULONG,Release) (THIS) PURE;
  157. STDMETHOD(GetName) (THIS_ LPSTR pbBuffer, LPDWORD pcbBuffer) PURE;
  158. STDMETHOD(GetProfileDirectory) (THIS_ LPSTR pbBuffer, LPDWORD pcbBuffer) PURE;
  159. STDMETHOD(IsSupervisor) (THIS) PURE;
  160. STDMETHOD(SetSupervisorPrivilege) (THIS_ BOOL fMakeSupervisor, LPCSTR pszSupervisorPassword) PURE;
  161. STDMETHOD(MakeTempSupervisor) (THIS_ BOOL fMakeSupervisor, LPCSTR pszSupervisorPassword) PURE;
  162. STDMETHOD(AppearsSupervisor) (THIS) PURE;
  163. STDMETHOD(Authenticate) (THIS_ LPCSTR pszPassword) PURE;
  164. STDMETHOD(ChangePassword) (THIS_ LPCSTR pszOldPassword, LPCSTR pszNewPassword) PURE;
  165. STDMETHOD(GetPasswordCache) (THIS_ LPCSTR pszPassword, LPHANDLE phOut) PURE;
  166. STDMETHOD(LoadProfile) (THIS_ HKEY *phkeyUser) PURE;
  167. STDMETHOD(UnloadProfile) (THIS_ HKEY hkeyUser) PURE;
  168. STDMETHOD(GetComponentSettings) (THIS_ REFCLSID clsidComponent,
  169. LPCSTR pszName, IUnknown **ppOut,
  170. DWORD fdwAccess) PURE;
  171. STDMETHOD(EnumerateComponentSettings) (THIS_ IEnumUnknown **ppOut,
  172. DWORD fdwAccess) PURE;
  173. };
  174. /************************************************************************
  175. IUserProfileInit interface
  176. This interface is a helper for IUserDatabase::Install and IUserDatabase::Create.
  177. It allows the client of those functions to perform initialization of a new
  178. user's profile before and after the new user's per-user folders are set up.
  179. Member functions, other than IUnknown:
  180. PreInitProfile(HKEY hkeyUser, LPCSTR pszProfileDir)
  181. Called when the user's profile has been created, but no per-user folders
  182. have been created or initialized yet. Here the implementer can add keys to
  183. the user's profile which will affect the initialization of those per-user
  184. folders. hkeyUser is the root of the user's profile, which would be
  185. HKEY_CURRENT_USER if the user were currently logged on.
  186. PostInitProfile(HKEY hkeyUser, LPCSTR pszProfileDir)
  187. Called after the user's per-user folders have been created and initialized.
  188. Here the implementer can add keys to the user's profile which will control
  189. roaming of per-user folders, without causing the IUserDatabase profile
  190. cloning code to want to initialize those folders from their default
  191. locations.
  192. ************************************************************************/
  193. DECLARE_INTERFACE_(IUserProfileInit, IUnknown)
  194. {
  195. // *** IUnknown methods ***
  196. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  197. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  198. STDMETHOD_(ULONG,Release) (THIS) PURE;
  199. STDMETHOD(PreInitProfile) (THIS_ HKEY hkeyUser, LPCSTR pszProfileDir) PURE;
  200. STDMETHOD(PostInitProfile) (THIS_ HKEY hkeyUser, LPCSTR pszProfileDir) PURE;
  201. };
  202. /************************************************************************
  203. IUserDatabase interface
  204. This interface is used to manage the local user database as a whole. Any
  205. activities which deal with the list of users in any way are done through
  206. this interface; operations which deal with the properties (other than the
  207. name) of an existing user are done through IUser.
  208. Member functions, other than IUnknown:
  209. Install(LPCSTR pszSupervisorName, LPCSTR pszSupervisorPassword,
  210. LPCSTR pszRatingsPassword, IUserProfileInit *pInit)
  211. Installs the user settings subsystem. This includes creating an account
  212. for the supervisor. A separate member function is necessary for doing
  213. this because all the others would insist that the current user already
  214. be a supervisor. The pInit object (optional, may be NULL) is called
  215. back to allow the installer to do initialization of the profile being
  216. created, before and after its per-user files are copied.
  217. AddUser(LPCSTR pszName, IUser *pSourceUser, IUserProfileInit *pInit,
  218. IUser **ppOut)
  219. Creates a new user on the system. This includes creating a profile
  220. for the user. It does not, however, include creating a password list
  221. file. IUser::ChangePassword can be used to configure the password
  222. for the user. An IUser object is returned to the caller so that the
  223. caller can configure the properties of the user. This function will
  224. fail if the current user is not a supervisor. The caller can optionally
  225. specify a user account to be cloned. The pInit object (optional, may be
  226. NULL) is called back to allow the installer to do initialization of the
  227. profile being created, before and after its per-user files are copied.
  228. GetUser(LPCSTR pszName, IUser **ppOut)
  229. Gets an IUser object corresponding to the specified user. The current
  230. user need not be a supervisor to call this function, and any user's
  231. name may be specified. The IUser interface will control what a non-
  232. supervisor can and cannot do to the user object.
  233. GetSpecialUser(DWORD nSpecialUserCode, IUser **ppOut)
  234. Gets an IUser object corresponding to a special particular user.
  235. Current values for nSpecialUserCode include GSU_CURRENT, meaning
  236. the currently logged on user, and GSU_DEFAULT, meaning the default
  237. user identity (i.e., the identity used when nobody is logged on,
  238. also used as a template when creating new identities).
  239. GetCurrentUser(IUser **ppOut)
  240. Gets an IUser object corresponding to the currently logged on user.
  241. Shorthand for GetSpecialUser(GSU_CURRENT, ppOut).
  242. SetCurrentUser(IUser *pUser)
  243. Sets this IUserDatabase object's idea of who the current user is.
  244. The user must have previously been authenticated. This user object
  245. is used for all checks which, for example, determine whether the
  246. "current user" is a supervisor, or whether a user can access his
  247. or her own settings, etc. SetCurrentUser does not AddRef the IUser
  248. object passed.
  249. DeleteUser(LPCSTR pszName)
  250. Deletes the profile and password cache for the specified user,
  251. effectively destroying that user's identity. This function may
  252. only be called if the current user is a supervisor. Any existing
  253. IUser objects which refer to the user are no longer useful, but
  254. still must be destroyed in the ordinary way (Release()).
  255. RenameUser(LPCSTR pszOldName, LPCSTR pszNewName)
  256. Changes the username of a user. This function may only be called
  257. if the current user is a supervisor.
  258. EnumUsers(IEnumUnknown **ppOut)
  259. Returns an IEnumUnknown object which the caller can use to enumerate
  260. the local users on the system.
  261. Authenticate(HWND hwndOwner, DWORD dwFlags, LPCSTR pszName, LPCSTR pszPassword,
  262. IUser **ppOut)
  263. Attempts to authenticate a user. dwFlags specifies whether or not
  264. to prompt for credentials, and whether or not non-supervisors are
  265. acceptable. If no dialog is to be displayed by the API, then the
  266. pszName and pszPassword parameters are used instead. If the credentials
  267. are authenticated succcessfully, S_OK is returned. The ppOut parameter,
  268. if not NULL, is filled with a pointer to an IUser object describing the
  269. user who was authenticated, in case the caller cares to find out about
  270. who typed in their name and password.
  271. The dwFlags parameter specifies whether UI will be displayed by the
  272. function, and whether or not the credentials will be cached in memory
  273. for use at the next logon.
  274. InstallComponent(REFCLSID clsidComponent, LPCSTR pszName, DWORD dwFlags)
  275. CURRENTLY NOT IMPLEMENTED
  276. Installs a component into the settings database, so that it will appear
  277. in the settings UI. clsidComponent or pszName can be used to refer to
  278. the component being installed; use of a CLSID is preferable because
  279. then the component can provide server code which renders the settings
  280. UI for that component, and knows how to initialize the settings for a
  281. new user.
  282. The only bit currently defined for dwFlags is:
  283. SETTINGS_NS_CAN_WRITE: Non-supervisors can change their own settings
  284. for this component.
  285. A component's settings for the current user can always be read, at least
  286. programmatically -- there is no point in storing settings which can only
  287. be accessed if the current user is a supervisor. If non-supervisors
  288. should not be shown the UI for restricted settings (even a read-only UI),
  289. that decision can be made at the UI level.
  290. InstallComponent fails if the current user is not a supervisor.
  291. RemoveComponent(REFCLSID clsidComponent, LPCSTR pszName)
  292. CURRENTLY NOT IMPLEMENTED
  293. Removes a component from the settings database, so that it will no longer
  294. appear in the settings UI. This also removes this component's settings
  295. from all user identities.
  296. RemoveComponent fails if the current user is not a supervisor.
  297. InstallWizard(HWND hwndParent)
  298. Runs the wizard that switches to multiuser mode.
  299. AddUserWizard(HWND hwndParent)
  300. Runs the wizard that adds a new user, invoking the go-multiuser wizard
  301. if necessary.
  302. UserCPL(HWND hwndParent)
  303. Invokes the general user management UI as seen in Control panel, invoking
  304. the go-multiuser wizard if necessary.
  305. ************************************************************************/
  306. DECLARE_INTERFACE_(IUserDatabase, IUnknown)
  307. {
  308. // *** IUnknown methods ***
  309. STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  310. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  311. STDMETHOD_(ULONG,Release) (THIS) PURE;
  312. STDMETHOD(Install) (THIS_ LPCSTR pszSupervisorName, LPCSTR pszSupervisorPassword,
  313. LPCSTR pszRatingsPassword, IUserProfileInit *pInit) PURE;
  314. STDMETHOD(AddUser) (THIS_ LPCSTR pszName, IUser *pSourceUser,
  315. IUserProfileInit *pInit, IUser **ppOut) PURE;
  316. STDMETHOD(GetUser) (THIS_ LPCSTR pszName, IUser **ppOut) PURE;
  317. STDMETHOD(GetSpecialUser) (THIS_ DWORD nSpecialUserCode, IUser **ppOut) PURE;
  318. STDMETHOD(GetCurrentUser) (THIS_ IUser **ppOut) PURE;
  319. STDMETHOD(SetCurrentUser) (THIS_ IUser *pUser) PURE;
  320. STDMETHOD(DeleteUser) (THIS_ LPCSTR pszName) PURE;
  321. STDMETHOD(RenameUser) (THIS_ LPCSTR pszOldName, LPCSTR pszNewName) PURE;
  322. STDMETHOD(EnumUsers) (THIS_ IEnumUnknown **ppOut) PURE;
  323. STDMETHOD(Authenticate) (THIS_ HWND hwndOwner, DWORD dwFlags,
  324. LPCSTR pszName, LPCSTR pszPassword,
  325. IUser **ppOut) PURE;
  326. STDMETHOD(InstallComponent) (THIS_ REFCLSID clsidComponent, LPCSTR pszName,
  327. DWORD dwFlags) PURE;
  328. STDMETHOD(RemoveComponent) (THIS_ REFCLSID clsidComponent, LPCSTR pszName) PURE;
  329. STDMETHOD(InstallWizard) (THIS_ HWND hwndParent) PURE;
  330. STDMETHOD(AddUserWizard) (THIS_ HWND hwndParent) PURE;
  331. STDMETHOD(UserCPL) (THIS_ HWND hwndParent) PURE;
  332. };
  333. // codes for IUserDatabase::GetSpecialUser
  334. const DWORD GSU_CURRENT = 0; // current user
  335. const DWORD GSU_DEFAULT = 1; // default user profile
  336. // flags for IUserDatabase::Authenticate
  337. const DWORD LUA_DIALOG = 0x00000001; // display dialog to get credentials
  338. // otherwise use pszName, pszPassword
  339. const DWORD LUA_SUPERVISORONLY = 0x00000002; // authenticate supervisors only
  340. const DWORD LUA_FORNEXTLOGON = 0x00000004; // cache credentials for next logon
  341. // flags for IUserDatabase::InstallComponent
  342. const DWORD SETTINGS_NS_CAN_WRITE = 0x01; // non-supervisors can change their own settings
  343. #endif // _MSLUAPI_H_