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.

106 lines
4.7 KiB

  1. --
  2. -- Create a list of all cards in the database
  3. -- The list will be a string like card1;card2;
  4. --
  5. CREATE PROCEDURE #GetCardList
  6. @stCardList nvarchar(256) OUTPUT
  7. AS
  8. DECLARE @stCard nvarchar(64)
  9. SET @stCardList = ""
  10. DECLARE CardCursor CURSOR FOR
  11. SELECT DISTINCT CARD
  12. FROM Winlogon.dbo.AuthMonitor
  13. WHERE CARD <> ""
  14. ORDER BY CARD DESC
  15. OPEN CardCursor
  16. FETCH NEXT FROM CardCursor
  17. INTO @stCard
  18. WHILE @@FETCH_STATUS = 0
  19. BEGIN
  20. SET @stCardList = RTRIM(@stCard) + ";" + @stCardList
  21. FETCH NEXT FROM CardCursor
  22. INTO @stCard
  23. END
  24. CLOSE CardCursor
  25. DEALLOCATE CardCursor
  26. GO
  27. --
  28. -- Create a list of all readers
  29. -- Like the card list this will look like reader1;reader2
  30. --
  31. CREATE PROCEDURE #GetReaderList
  32. @stReaderList nvarchar(256) OUTPUT
  33. AS
  34. SET @stReaderList = ""
  35. DECLARE ReaderCursor CURSOR FOR
  36. SELECT DISTINCT READER
  37. FROM Winlogon.dbo.AuthMonitor
  38. WHERE READER <> ""
  39. ORDER BY READER DESC
  40. DECLARE @stReader nvarchar(64)
  41. OPEN ReaderCursor
  42. FETCH NEXT FROM ReaderCursor
  43. INTO @stReader
  44. WHILE @@FETCH_STATUS = 0
  45. BEGIN
  46. DECLARE @iLen int
  47. SET @stReader = RTRIM(@stReader)
  48. SET @iLen = LEN(@stReader)
  49. IF RIGHT(@stReader, 1) = "0"
  50. SET @stReaderList = LEFT(@stReader, @iLen - 2) + ";" + @stReaderList
  51. FETCH NEXT FROM ReaderCursor
  52. INTO @stReader
  53. END
  54. CLOSE ReaderCursor
  55. DEALLOCATE ReaderCursor
  56. GO
  57. CREATE PROCEDURE #GetCard
  58. @stCard nvarchar(64) OUTPUT,
  59. @iStart int OUTPUT
  60. AS
  61. DECLARE @stCardList nvarchar(256), @iPos int
  62. EXEC #GetCardList @stCardList OUTPUT
  63. SET @iPos = CHARINDEX ( ";", @stCardList, @iStart)
  64. IF @iPos = 0
  65. SET @stCard = ""
  66. ELSE
  67. SET @stCard = SUBSTRING(@stCardList, @iStart, @iPos - @iStart)
  68. SET @iStart = @iPos + 1
  69. GO
  70. CREATE PROCEDURE #GetReader
  71. @stReader nvarchar(64) OUTPUT,
  72. @iStart int OUTPUT
  73. AS
  74. DECLARE @stReaderList nvarchar(256), @iPos int
  75. EXEC #GetReaderList @stReaderList OUTPUT
  76. SET @iPos = CHARINDEX ( ";", @stReaderList, @iStart)
  77. IF @iPos = 0
  78. SET @stReader = ""
  79. ELSE
  80. SET @stReader = SUBSTRING(@stReaderList, @iStart, @iPos - @iStart)
  81. SET @iStart = @iPos + 1
  82. GO