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.

247 lines
5.9 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1992 - 1996
  6. //
  7. // File: logonses.h
  8. //
  9. // Contents: prototypes and structures for the logon session list
  10. //
  11. //
  12. // History: 16-April-1996 Created MikeSw
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __LOGONSES_H__
  16. #define __LOGONSES_H__
  17. //
  18. // All global variables declared as EXTERN will be allocated in the file
  19. // that defines LOGONSES_ALLOCATE
  20. //
  21. #ifdef EXTERN
  22. #undef EXTERN
  23. #endif
  24. #ifdef LOGONSES_ALLOCATE
  25. #define EXTERN
  26. #else
  27. #define EXTERN extern
  28. #endif
  29. EXTERN KERBEROS_LIST KerbLogonSessionList;
  30. EXTERN BOOLEAN KerberosLogonSessionsInitialized;
  31. //
  32. // Keep track a list of session keys for network service in ISC. These keys are
  33. // used in ASC to detect whether a kerb logon session is from ISC called by the
  34. // local network serivce (the client)
  35. //
  36. EXTERN LIST_ENTRY KerbNetworkServiceSKeyList;
  37. EXTERN RTL_RESOURCE KerbNetworkServiceSKeyLock;
  38. //
  39. // the number of entries is only used in debugger spew of checked builds
  40. //
  41. #if DBG
  42. EXTERN volatile LONG KerbcSKeyEntries;
  43. #endif
  44. //
  45. // timer used to clean up the session key list above
  46. //
  47. EXTERN HANDLE KerbhSKeyTimerQueue;
  48. //
  49. // NOTICE: The logon session resource, credential resource, and context
  50. // resource must all be acquired carefully to prevent deadlock. They
  51. // can only be acquired in this order:
  52. //
  53. // 1. Logon Sessions
  54. // 2. Credentials
  55. // 3. Contexts
  56. //
  57. #if DBG
  58. #ifdef WIN32_CHICAGO
  59. #define KerbWriteLockLogonSessions(_X_) \
  60. { \
  61. DebugLog((DEB_TRACE_LOCKS,"Write locking LogonSessions\n")); \
  62. DsysAssert(KerbGlobalContextsLocked != GetCurrentThreadId()); \
  63. EnterCriticalSection(&(_X_)->Lock); \
  64. }
  65. #define KerbReadLockLogonSessions(_X_) \
  66. { \
  67. DebugLog((DEB_TRACE_LOCKS,"Read locking LogonSessions\n")); \
  68. DsysAssert(KerbGlobalContextsLocked != GetCurrentThreadId()); \
  69. EnterCriticalSection(&(_X_)->Lock); \
  70. }
  71. #define KerbUnlockLogonSessions(_X_) \
  72. { \
  73. DebugLog((DEB_TRACE_LOCKS,"Unlocking LogonSessions\n")); \
  74. LeaveCriticalSection(&(_X_)->Lock); \
  75. }
  76. #else // WIN32_CHICAGO
  77. #define KerbWriteLockLogonSessions(_X_) \
  78. { \
  79. DebugLog((DEB_TRACE_LOCKS,"Write locking LogonSession %p\n",(_X_))); \
  80. DsysAssert(KerbGlobalContextsLocked != GetCurrentThreadId()); \
  81. RtlEnterCriticalSection(&(_X_)->Lock); \
  82. }
  83. #define KerbReadLockLogonSessions(_X_) \
  84. { \
  85. DebugLog((DEB_TRACE_LOCKS,"Read locking LogonSession %p\n",(_X_))); \
  86. DsysAssert(KerbGlobalContextsLocked != GetCurrentThreadId()); \
  87. RtlEnterCriticalSection(&(_X_)->Lock); \
  88. }
  89. #define KerbUnlockLogonSessions(_X_) \
  90. { \
  91. DebugLog((DEB_TRACE_LOCKS,"Unlocking LogonSessions\n")); \
  92. RtlLeaveCriticalSection(&(_X_)->Lock); \
  93. }
  94. #endif // WIN32_CHICAGO
  95. #else
  96. #ifdef WIN32_CHICAGO
  97. #define KerbWriteLockLogonSessions(_X_) \
  98. EnterCriticalSection(&(_X_)->Lock)
  99. #define KerbReadLockLogonSessions(_X_) \
  100. EnterCriticalSection(&(_X_)->Lock)
  101. #define KerbUnlockLogonSessions(_X_) \
  102. LeaveCriticalSection(&(_X_)->Lock)
  103. #else // WIN32_CHICAGO
  104. #define KerbWriteLockLogonSessions(_X_) \
  105. RtlEnterCriticalSection(&(_X_)->Lock);
  106. #define KerbReadLockLogonSessions(_X_) \
  107. RtlEnterCriticalSection(&(_X_)->Lock);
  108. #define KerbUnlockLogonSessions(_X_) \
  109. RtlLeaveCriticalSection(&(_X_)->Lock);
  110. #endif // WIN32_CHICAGO
  111. #endif
  112. //
  113. // Helper routines for Logon Sessions
  114. //
  115. NTSTATUS
  116. KerbInitLogonSessionList(
  117. VOID
  118. );
  119. NTSTATUS
  120. KerbInitNetworkServiceLoopbackDetection(
  121. VOID
  122. );
  123. VOID
  124. KerbFreeNetworkServiceSKeyListAndLock(
  125. VOID
  126. );
  127. VOID
  128. KerbFreeLogonSessionList(
  129. VOID
  130. );
  131. NTSTATUS
  132. KerbAllocateLogonSession(
  133. PKERB_LOGON_SESSION * NewLogonSession
  134. );
  135. NTSTATUS
  136. KerbInsertLogonSession(
  137. IN PKERB_LOGON_SESSION LogonSession
  138. );
  139. PKERB_LOGON_SESSION
  140. KerbReferenceLogonSession(
  141. IN PLUID LogonId,
  142. IN BOOLEAN RemoveFromList
  143. );
  144. VOID
  145. KerbReferenceLogonSessionByPointer(
  146. IN PKERB_LOGON_SESSION LogonSession,
  147. IN BOOLEAN RemoveFromList
  148. );
  149. VOID
  150. KerbDereferenceLogonSession(
  151. IN PKERB_LOGON_SESSION LogonSession
  152. );
  153. NTSTATUS
  154. KerbCreateLogonSession(
  155. IN PLUID LogonId,
  156. IN PUNICODE_STRING AccountName,
  157. IN PUNICODE_STRING DomainName,
  158. IN OPTIONAL PUNICODE_STRING Password,
  159. IN OPTIONAL PUNICODE_STRING OldPassword,
  160. IN ULONG PasswordFlags,
  161. IN SECURITY_LOGON_TYPE LogonType,
  162. OUT PKERB_LOGON_SESSION * NewLogonSession
  163. );
  164. VOID
  165. KerbFreeLogonSession(
  166. IN PKERB_LOGON_SESSION LogonSession
  167. );
  168. NTSTATUS
  169. KerbCreateLogonSessionFromKerbCred(
  170. IN OPTIONAL PLUID LogonId,
  171. IN PKERB_ENCRYPTED_TICKET Ticket,
  172. IN PKERB_CRED KerbCred,
  173. IN PKERB_ENCRYPTED_CRED EncryptedCred,
  174. IN OUT PKERB_LOGON_SESSION *OldLogonSession
  175. );
  176. NTSTATUS
  177. KerbBuildPasswordList(
  178. IN PUNICODE_STRING Password,
  179. IN PUNICODE_STRING UserName,
  180. IN PUNICODE_STRING DomainName,
  181. IN PKERB_ETYPE_INFO SuppliedSalt,
  182. IN PKERB_STORED_CREDENTIAL OldPasswords,
  183. IN OPTIONAL PUNICODE_STRING PrincipalName,
  184. IN KERB_ACCOUNT_TYPE AccountType,
  185. IN ULONG PasswordFlags,
  186. OUT PKERB_STORED_CREDENTIAL * PasswordList
  187. );
  188. VOID
  189. KerbFreeStoredCred(
  190. IN PKERB_STORED_CREDENTIAL StoredCred
  191. );
  192. NTSTATUS
  193. KerbChangeCredentialsPassword(
  194. IN PKERB_PRIMARY_CREDENTIAL PrimaryCredentials,
  195. IN OPTIONAL PUNICODE_STRING NewPassword,
  196. IN OPTIONAL PKERB_ETYPE_INFO EtypeInfo,
  197. IN KERB_ACCOUNT_TYPE AccountType,
  198. IN ULONG PasswordFlags
  199. );
  200. //
  201. // Flags for logon sessions
  202. //
  203. #define KERB_LOGON_DEFERRED 0x1
  204. #define KERB_LOGON_NO_PASSWORD 0x2
  205. #define KERB_LOGON_LOCAL_ONLY 0x4
  206. #define KERB_LOGON_DELEGATED 0x8
  207. #define KERB_LOGON_SMARTCARD 0x10
  208. #define KERB_LOGON_MIT_REALM 0x20
  209. #define KERB_LOGON_S4U_SESSION 0x4000 // make sure we don't collide w/ other flags
  210. #define KERB_LOGON_CREDMAN_INITIALIZED 0x80000000
  211. #endif // __LOGONSES_H__