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.

114 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. logonsess.cxx
  5. Abstract:
  6. logonsess
  7. Author:
  8. Larry Zhu (LZhu) January 1, 2002 Created
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include "precomp.hxx"
  14. #pragma hdrstop
  15. #include "logonsess.hxx"
  16. VOID
  17. Usage(
  18. IN PCSTR pszApp
  19. )
  20. {
  21. DebugPrintf(SSPI_ERROR, "\n\nUsage: %s -l<LogonId.LowPart> -h<LogonId.HighPart>\n\n", pszApp);
  22. exit(-1);
  23. }
  24. VOID __cdecl
  25. main(
  26. IN INT argc,
  27. IN PSTR argv[]
  28. )
  29. {
  30. TNtStatus Status = STATUS_SUCCESS;
  31. HANDLE LogonHandle = NULL;
  32. ULONG PackageId = -1;
  33. LUID LogonId = {0};
  34. LUID* pLogonSessionList = &LogonId;
  35. ULONG cLogonSessionCount = 0;
  36. DebugLogOpen("logonsess.exe", SSPI_LOG | SSPI_WARN | SSPI_ERROR);
  37. for (INT i = 1; NT_SUCCESS(Status) && (i < argc); i++)
  38. {
  39. if ((*argv[i] == '-') || (*argv[i] == '/'))
  40. {
  41. switch (argv[i][1])
  42. {
  43. case 'l':
  44. cLogonSessionCount = 1;
  45. LogonId.LowPart = strtol(argv[i] + 2, NULL, 0);
  46. break;
  47. case 'h':
  48. cLogonSessionCount = 1;
  49. LogonId.HighPart = strtol(argv[i] + 2, NULL, 0);
  50. break;
  51. case '?':
  52. default:
  53. Usage(argv[0]);
  54. break;
  55. }
  56. }
  57. else
  58. {
  59. Usage(argv[0]);
  60. }
  61. }
  62. if (cLogonSessionCount == 0)
  63. {
  64. Status DBGCHK = LsaEnumerateLogonSessions(&cLogonSessionCount, &pLogonSessionList);
  65. }
  66. for (UINT i = 0; (i < cLogonSessionCount) && NT_SUCCESS(Status); i++)
  67. {
  68. PSECURITY_LOGON_SESSION_DATA pLogonSessionData = NULL;
  69. DebugPrintf(SSPI_LOG, "*********Getting Logonsession data for %#x:%#x**********\n", pLogonSessionList[i].HighPart, pLogonSessionList[i].LowPart);
  70. Status DBGCHK = LsaGetLogonSessionData(pLogonSessionList + i, &pLogonSessionData);
  71. if (NT_SUCCESS(Status))
  72. {
  73. DebugPrintLogonSessionData(SSPI_LOG, pLogonSessionData);
  74. }
  75. if (pLogonSessionData)
  76. {
  77. LsaFreeReturnBuffer(pLogonSessionData);
  78. }
  79. }
  80. if (pLogonSessionList != &LogonId)
  81. {
  82. LsaFreeReturnBuffer(pLogonSessionList);
  83. }
  84. DebugLogClose();
  85. }