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.

94 lines
4.6 KiB

  1. USE Winlogon
  2. DECLARE @bSendmail bit
  3. SET @bSendmail = 1
  4. DECLARE @SCARD_W_WRONG_CHV bigint
  5. SET @SCARD_W_WRONG_CHV = -2146434965
  6. DECLARE @crlf nvarchar(2)
  7. SET @crlf = CHAR(13) + CHAR(10)
  8. DECLARE @MessageBody nvarchar(4000)
  9. SET @MessageBody = ""
  10. DECLARE @Buffer nvarchar(256), @Number nvarchar(5), @Percent nvarchar(3)
  11. DECLARE @Checkdate datetime
  12. SET @Checkdate = DATEADD(day, -8, GETDATE())
  13. -- SET @Checkdate = DATEADD(day, -1, GETDATE())
  14. --
  15. -- Get number of deployed readers
  16. --
  17. DECLARE @ReaderNumbers nvarchar(1000)
  18. SET @ReaderNumbers = "Deployed readers" + @crlf +
  19. REPLICATE("-", 45) + @crlf
  20. DECLARE @iReaderHandle int, @stReader nvarchar(64)
  21. SET @iReaderHandle = 0
  22. EXEC #GetReader @stReader OUTPUT, @iReaderHandle OUTPUT
  23. WHILE @stReader <> ""
  24. BEGIN
  25. SELECT DISTINCT READER, MACHINENAME
  26. FROM AuthMonitor
  27. WHERE TIMESTAMP > @Checkdate
  28. AND READER LIKE @stReader + "%"
  29. SET @Number = CAST(@@ROWCOUNT AS nvarchar(5))
  30. IF @Number <> 0
  31. BEGIN
  32. EXEC master.dbo.xp_sprintf @Buffer OUTPUT, "� %-34s%5s", @stReader, @Number
  33. SET @ReaderNumbers =
  34. @ReaderNumbers + @Buffer + @crlf
  35. END
  36. EXEC #GetReader @stReader OUTPUT, @iReaderHandle OUTPUT
  37. END
  38. --
  39. -- Get number of deployed cards
  40. --
  41. DECLARE @CardNumbers nvarchar(1000)
  42. SET @CardNumbers = "Deployed smart cards" + @crlf +
  43. REPLICATE("-", 45) + @crlf
  44. DECLARE @iCardHandle int, @stCard nvarchar(64)
  45. SET @iCardHandle = 0
  46. EXEC #GetCard @stCard OUTPUT, @iCardHandle OUTPUT
  47. WHILE @stCard <> ""
  48. BEGIN
  49. SELECT DISTINCT CARD, USERNAME
  50. FROM AuthMonitor
  51. WHERE TIMESTAMP > @Checkdate
  52. AND CARD = @stCard
  53. SET @Number = CAST(@@ROWCOUNT AS nvarchar(5))
  54. IF @Number <> 0
  55. BEGIN
  56. EXEC master.dbo.xp_sprintf @Buffer OUTPUT, "� %-34s%5s", @stCard, @Number
  57. SET @CardNumbers =
  58. @CardNumbers + @Buffer + @crlf
  59. END
  60. EXEC #GetCard @stCard OUTPUT, @iCardHandle OUTPUT
  61. END
  62. --
  63. -- Send mail
  64. --
  65. SET @MessageBody = @ReaderNumbers + @crlf +
  66. @CardNumbers
  67. IF @bSendmail <> 0
  68. EXEC master.dbo.xp_sendmail
  69. @recipients = 'smcaft',
  70. @message = @MessageBody,
  71. @subject = 'Smart card self host report - deployment data'
  72. ELSE
  73. PRINT @MessageBody
  74. GO