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.

135 lines
4.0 KiB

  1. // Session.h : This file contains the
  2. // Created: Feb '98
  3. // Author : a-rakeba
  4. // History:
  5. // Copyright (C) 1998 Microsoft Corporation
  6. // All rights reserved.
  7. // Microsoft Confidential
  8. #if !defined( _SESSION_H_ )
  9. #define _SESSION_H_
  10. #include <cmnhdr.h>
  11. #include <TChar.h>
  12. #include <ntlsapi.h>
  13. #include <IoHandlr.h>
  14. #include <RfcProto.h>
  15. #include <Shell.h>
  16. #include <Scraper.h>
  17. #ifdef WHISTLER_BUILD
  18. #include <ws2tcpip.h>
  19. #else
  20. #include "..\tlntsvr\ws2tcpip.h"
  21. #endif
  22. #include <IpTypes.h>
  23. #define MAX_HANDLES 4
  24. typedef enum { LOGOFF, LOGON } LOGEVENT;
  25. typedef enum { FAIL = 0, SUCCESS } LOGEVENT_RESULT;
  26. typedef enum { ADMIN = 0, NON_ADMIN, DONT_KNOW };
  27. #define DEFAULT_COLS 80
  28. #define DEFAULT_ROWS 25
  29. #define BLANK " "
  30. #define FROM "from"
  31. #define ADMINISTRATOR "Administrator "
  32. #define LOGGED "logged"
  33. #define FAILED_TO_LOG "failed to log"
  34. #define ON "on"
  35. #define OFF "off"
  36. // Logon auditing is not internationalized. So we do not intend to do that now.
  37. #define NTLM_LOGON_FAILED "An attempt to logon to Telnet Server through NTLM Authentication from the computer %s (%s) failed. To see the details of the user, turn on Logon Auditing and view the details in the Security Log."
  38. class CSession : private CIoHandler, private CRFCProtocol, private CShell,
  39. private CScraper
  40. {
  41. friend class CShell;
  42. friend class CIoHandler;
  43. friend struct CRFCProtocol;
  44. friend class CScraper;
  45. enum { PIPE_READ = WAIT_OBJECT_0, SOCKET_READ, CMD_KILLED, READ_FROM_CMD };
  46. struct sockaddr_storage m_ssPeerAddress;
  47. CHAR m_szMachineName[ MAX_PATH + 1 ];
  48. CHAR m_szPeerHostName[ MAX_PATH + 1 ];
  49. CHAR m_pszUserName[ MAX_PATH + 1 ];
  50. CHAR m_pszPassword[ MAX_PATH + 1 ];
  51. CHAR m_pszDomain[ MAX_PATH + 1 ];
  52. WCHAR m_szUser[MAX_PATH+1];
  53. WCHAR m_szDomain[MAX_DOMAIN_NAME_LEN+1];
  54. LUID m_AuthenticationId;
  55. CHAR m_pszTermType[ MAX_PATH + 1 ];
  56. bool m_bNegotiatedTermType;
  57. bool m_bIsTelnetClientsGroupMember;
  58. WORD m_wCols;
  59. WORD m_wRows;
  60. bool m_bNtVersionGTE5;
  61. DWORD m_dwTickCountAtLogon;
  62. WORD m_wNumFailedLogins;
  63. bool m_bContinueSession;
  64. DWORD m_dwHandleCount;
  65. WORD m_wIsAnAdmin;
  66. bool m_bIsStreamMode;
  67. bool m_bIsTelnetVersion2;
  68. //1. Read pipe event 2. Socket Read event 3. cmd
  69. HANDLE m_rghHandlestoWaitOn[ MAX_HANDLES ];
  70. HANDLE m_hToken;
  71. DWORD m_dwAltKeyMapping;
  72. DWORD m_dwIdleSessionTimeOut;
  73. DWORD m_dwAllowTrustedDomain;
  74. LPWSTR m_pszDifferentShell;
  75. LPWSTR m_pszDefaultDomain;
  76. LPWSTR m_pszDefaultShell;
  77. LPWSTR m_pszSwitchToKeepShellRunning;
  78. LPWSTR m_pszSwitchForOneTimeUseOfShell;
  79. LPWSTR m_pszLoginScript;
  80. DWORD m_dwNTLMSetting;
  81. DWORD m_dwMaxFailedLogins;
  82. DWORD m_dwLogToFile;
  83. DWORD m_dwSysAuditing;
  84. DWORD m_dwLogEvents;
  85. DWORD m_dwLogAdmin;
  86. DWORD m_dwLogFailures;
  87. PSID administrators;
  88. PSID pTelnetClientsSid;
  89. #ifdef LOGGING_ENABLED
  90. void LogIfOpted( BOOL result, LOGEVENT logon, BOOL bNTLMAuth = false );
  91. #endif
  92. void CollectPeerInfo();
  93. bool GetRegistryValues();
  94. bool IsAnAdminstratorOrMember();
  95. bool CheckGroupMembership( bool*, bool* );
  96. void FreeInitialVariables();
  97. //Just to get rid of warnings
  98. CSession( const CSession& );
  99. CSession& operator=( const CSession& );
  100. public:
  101. CSession();
  102. virtual ~CSession();
  103. bool Init();
  104. void WaitForIo();
  105. void Shutdown();
  106. void AddHandleToWaitOn( HANDLE );
  107. HANDLE m_hLogHandle;
  108. };
  109. void LogEvent( WORD wType, DWORD dwEventID, LPCTSTR pFormat, ... );
  110. #endif // _SESSION_H_