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.

289 lines
8.4 KiB

  1. //=============================================================================
  2. // Copyright (c) 2000 Microsoft Corporation
  3. //
  4. // wincrui.h
  5. //
  6. // Contains the public structures and functions for the credential manager
  7. // user interface APIs.
  8. //
  9. // Created 02/17/2000 johnstep (John Stephens)
  10. //=============================================================================
  11. #ifndef __WINCRUI_H__
  12. #define __WINCRUI_H__
  13. #include <wincred.h>
  14. #include <commctrl.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. //-----------------------------------------------------------------------------
  19. // Functions
  20. //-----------------------------------------------------------------------------
  21. CREDUIAPI
  22. BOOL
  23. WINAPI
  24. CredUIInitControls();
  25. // call this api to store a single-sign-on credential
  26. // retruns ERROR_SUCCESS if success
  27. //
  28. // pszRealm - if this is null, we will use the default realm
  29. CREDUIAPI
  30. DWORD
  31. WINAPI
  32. CredUIStoreSSOCredA (
  33. PCSTR pszRealm,
  34. PCSTR pszUsername,
  35. PCSTR pszPassword,
  36. BOOL bPersist
  37. );
  38. #ifdef UNICODE
  39. #define CredUIStoreSSOCred CredUIStoreSSOCredW
  40. #else
  41. #define CredUIStoreSSOCred CredUIStoreSSOCredA
  42. #endif
  43. // call this api to retrieve the username for a single-sign-on credential
  44. // retruns ERROR_SUCCESS if success, ERROR_NOT_FOUND if none was found
  45. // pszRealm - if this is null, we will use the default realm
  46. //
  47. // Caller should call LocalFree on *ppszUsername returned if ERROR_SUCCESS
  48. //
  49. CREDUIAPI
  50. DWORD
  51. WINAPI
  52. CredUIReadSSOCredA (
  53. PCSTR pszRealm,
  54. PSTR* ppszUsername
  55. );
  56. #ifdef UNICODE
  57. #define CredUIReadSSOCred CredUIReadSSOCredW
  58. #else
  59. #define CredUIReadSSOCred CredUIReadSSOCredA
  60. #endif
  61. //-----------------------------------------------------------------------------
  62. // Credential Control
  63. //-----------------------------------------------------------------------------
  64. // Class
  65. #define WC_CREDENTIALA "SysCredential"
  66. #define WC_CREDENTIALW L"SysCredential"
  67. #ifdef UNICODE
  68. #define WC_CREDENTIAL WC_CREDENTIALW
  69. #else
  70. #define WC_CREDENTIAL WC_CREDENTIALA
  71. #endif
  72. // Styles
  73. #define CRS_USERNAMES 0x0001
  74. #define CRS_CERTIFICATES 0x0002
  75. #define CRS_SMARTCARDS 0x0004
  76. #define CRS_ADMINISTRATORS 0x0008
  77. #define CRS_AUTOCOMPLETE 0x0010
  78. #define CRS_BALLOONS 0x0020
  79. #define CRS_SAVECHECK 0x0040
  80. #define CRS_COMPLETEUSERNAME 0x0080
  81. #define CRS_PREFILLADMIN 0x0100
  82. #define CRS_SINGLESIGNON 0x0200
  83. #define CRS_KEEPUSERNAME 0x0400
  84. #define CRS_NORMAL (CRS_AUTOCOMPLETE | CRS_BALLOONS)
  85. #define CREDUI_CONTROL_MIN_WIDTH 188
  86. #define CREDUI_CONTROL_MIN_HEIGHT 30
  87. #define CREDUI_CONTROL_ADD_SAVE 17
  88. #define CREDUI_CONTROL_FULL_HEIGHT (CREDUI_CONTROL_MIN_HEIGHT +\
  89. CREDUI_CONTROL_ADD_SAVE )
  90. // Messages
  91. #define CRM_FIRST 0x1000
  92. #define CRM_INITSTYLE (CRM_FIRST + 1)
  93. #define CRM_SETUSERNAMEMAX (CRM_FIRST + 2)
  94. #define CRM_SETPASSWORDMAX (CRM_FIRST + 3)
  95. #define CRM_SETUSERNAMEA (CRM_FIRST + 4)
  96. #define CRM_SETUSERNAMEW (CRM_FIRST + 5)
  97. #define CRM_GETUSERNAMEA (CRM_FIRST + 6)
  98. #define CRM_GETUSERNAMEW (CRM_FIRST + 7)
  99. #define CRM_SETPASSWORDA (CRM_FIRST + 8)
  100. #define CRM_SETPASSWORDW (CRM_FIRST + 9)
  101. #define CRM_GETPASSWORDA (CRM_FIRST + 10)
  102. #define CRM_GETPASSWORDW (CRM_FIRST + 11)
  103. #define CRM_SETFOCUS (CRM_FIRST + 12)
  104. #define CRM_SHOWBALLOONA (CRM_FIRST + 13)
  105. #define CRM_SHOWBALLOONW (CRM_FIRST + 14)
  106. #define CRM_GETMINSIZE (CRM_FIRST + 15)
  107. #define CRM_SETCHECK (CRM_FIRST + 16)
  108. #define CRM_GETCHECK (CRM_FIRST + 17)
  109. #define CRM_GETUSERNAMELENGTH (CRM_FIRST + 18)
  110. #define CRM_GETPASSWORDLENGTH (CRM_FIRST + 19)
  111. #define CRM_GETUSERNAMEMAX (CRM_FIRST + 20)
  112. #define CRM_GETPASSWORDMAX (CRM_FIRST + 21)
  113. #define CRM_DOCMDLINE (CRM_FIRST + 22)
  114. #define CRM_ENABLEUSERNAME (CRM_FIRST + 23)
  115. #define CRM_DISABLEUSERNAME (CRM_FIRST + 24)
  116. // Notification Messages
  117. #define CRN_USERNAMECHANGE 1
  118. #define CRN_PASSWORDCHANGE 2
  119. #ifdef UNICODE
  120. #define CRM_SETUSERNAME CRM_SETUSERNAMEW
  121. #define CRM_GETUSERNAME CRM_GETUSERNAMEW
  122. #define CRM_SETPASSWORD CRM_SETPASSWORDW
  123. #define CRM_GETPASSWORD CRM_GETPASSWORDW
  124. #define CRM_SHOWBALLOON CRM_SHOWBALLOONW
  125. #else
  126. #define CRM_SETUSERNAME CRM_SETUSERNAMEA
  127. #define CRM_GETUSERNAME CRM_GETUSERNAMEA
  128. #define CRM_SETPASSWORD CRM_SETPASSWORDA
  129. #define CRM_GETPASSWORD CRM_GETPASSWORDA
  130. #define CRM_SHOWBALLOON CRM_SHOWBALLOONA
  131. #endif
  132. // Types and Values for Messages
  133. #define CREDUI_CONTROL_USERNAME 1
  134. #define CREDUI_CONTROL_PASSWORD 2
  135. #define CREDUI_CONTROL_SAVE 3
  136. #define CREDUI_MAX_BALLOON_TITLE_LENGTH 255
  137. #define CREDUI_MAX_BALLOON_MESSAGE_LENGTH 255
  138. #define CREDUI_BALLOON_ICON_NONE TTI_NONE
  139. #define CREDUI_BALLOON_ICON_INFO TTI_INFO
  140. #define CREDUI_BALLOON_ICON_WARNING TTI_WARNING
  141. #define CREDUI_BALLOON_ICON_ERROR TTI_ERROR
  142. typedef struct _CREDUI_BALLOONA
  143. {
  144. DWORD dwVersion;
  145. INT iControl;
  146. INT iIcon;
  147. PSTR pszTitleText;
  148. PSTR pszMessageText;
  149. } CREDUI_BALLOONA, *PCREDUI_BALLOONA;
  150. typedef struct _CREDUI_BALLOONW
  151. {
  152. DWORD dwVersion;
  153. INT iControl;
  154. INT iIcon;
  155. PWSTR pszTitleText;
  156. PWSTR pszMessageText;
  157. } CREDUI_BALLOONW, *PCREDUI_BALLOONW;
  158. #ifdef UNICODE
  159. typedef CREDUI_BALLOONW CREDUI_BALLOON;
  160. typedef PCREDUI_BALLOONW PCREDUI_BALLOON;
  161. #else
  162. typedef CREDUI_BALLOONA CREDUI_BALLOON;
  163. typedef PCREDUI_BALLOONA PCREDUI_BALLOON;
  164. #endif
  165. // Macros
  166. #define Credential_InitStyle(hwnd, style)\
  167. (BOOL) SendMessage(hwnd, CRM_INITSTYLE, (WPARAM)(style), 0)
  168. #define Credential_SetUserNameMaxChars(hwnd, maxChars)\
  169. (BOOL) SendMessage(hwnd, CRM_SETUSERNAMEMAX, (WPARAM)(maxChars), 0)
  170. #define Credential_EnableUserName(hwnd)\
  171. (BOOL) SendMessage(hwnd, CRM_ENABLEUSERNAME, (WPARAM)(0), 0)
  172. #define Credential_DisableUserName(hwnd)\
  173. (BOOL) SendMessage(hwnd, CRM_DISABLEUSERNAME, (WPARAM)(0), 0)
  174. #define Credential_SetPasswordMaxChars(hwnd, maxChars)\
  175. (BOOL) SendMessage(hwnd, CRM_SETPASSWORDMAX, (WPARAM)(maxChars), 0)
  176. #define Credential_SetUserName(hwnd, pszUserName)\
  177. (BOOL) SendMessage(hwnd, CRM_SETUSERNAME, 0, (LPARAM)(pszUserName))
  178. #define Credential_GetUserName(hwnd, pszUserName, maxChars)\
  179. (BOOL) SendMessage(hwnd, CRM_GETUSERNAME, WPARAM(maxChars),\
  180. (LPARAM)(pszUserName))
  181. #define Credential_SetPassword(hwnd, pszPassword)\
  182. (BOOL) SendMessage(hwnd, CRM_SETPASSWORD, 0, (LPARAM)(pszPassword))
  183. #define Credential_GetPassword(hwnd, pszPassword, maxChars)\
  184. (BOOL) SendMessage(hwnd, CRM_GETPASSWORD, WPARAM(maxChars),\
  185. (LPARAM)(pszPassword))
  186. #define Credential_SetUserNameFocus(hwnd)\
  187. (BOOL) SendMessage(hwnd, CRM_SETFOCUS, CREDUI_CONTROL_USERNAME, 0)
  188. #define Credential_SetPasswordFocus(hwnd)\
  189. (BOOL) SendMessage(hwnd, CRM_SETFOCUS, CREDUI_CONTROL_PASSWORD, 0)
  190. #define Credential_ShowUserNameBalloon(hwnd, image, title, message){\
  191. CREDUI_BALLOON balloon = { 1, CREDUI_CONTROL_USERNAME,\
  192. image, title, message };\
  193. (BOOL) SendMessage(hwnd, CRM_SHOWBALLOON, 0, (LPARAM)(&balloon));}
  194. #define Credential_ShowPasswordBalloon(hwnd, image, title, message){\
  195. CREDUI_BALLOON balloon = { 1, CREDUI_CONTROL_PASSWORD,\
  196. image, title, message };\
  197. (BOOL) SendMessage(hwnd, CRM_SHOWBALLOON, 0, (LPARAM)(&balloon));}
  198. #define Credential_HideBalloon(hwnd)\
  199. (BOOL) SendMessage(hwnd, CRM_SHOWBALLOON, 0, NULL)
  200. #define Credential_GetMinSize(hwnd, rect)\
  201. (BOOL) SendMessage(hwnd, CRM_GETMINSIZE, 0, (LPARAM) &rect)
  202. #define Credential_CheckSave(hwnd, enabled)\
  203. (BOOL) SendMessage(hwnd, CRM_SETCHECK, CREDUI_CONTROL_SAVE, enabled)
  204. #define Credential_IsSaveChecked(hwnd)\
  205. (BOOL) SendMessage(hwnd, CRM_GETCHECK, CREDUI_CONTROL_SAVE, 0)
  206. #define Credential_GetUserNameLength(hwnd)\
  207. (LONG) SendMessage(hwnd, CRM_GETUSERNAMELENGTH, 0, 0)
  208. #define Credential_GetPasswordLength(hwnd)\
  209. (LONG) SendMessage(hwnd, CRM_GETPASSWORDLENGTH, 0, 0)
  210. #define Credential_GetUserNameMax(hwnd)\
  211. (ULONG) SendMessage(hwnd, CRM_GETUSERNAMEMAX, 0, 0)
  212. #define Credential_GetPasswordMax(hwnd)\
  213. (ULONG) SendMessage(hwnd, CRM_GETPASSWORDMAX, 0, 0)
  214. //-----------------------------------------------------------------------------
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218. #endif