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.

162 lines
4.1 KiB

  1. # Test #1 - This test exercises all the basic functionalities of the
  2. # COM implementation of IAccessControl.
  3. # Init a new COM IAccessControl object by passing a NULL IStream pointer
  4. # into IPersistStream::Load
  5. Exec InitNewACL
  6. # I'll add 4 DENY_ACCESS ACEs and 5 GRANT_ACCESS ACEs to the ACL
  7. # First, I'll add the GRANT_ACCESS entries to the ACL but before doing that,
  8. # I have to set up an access request list locally
  9. ToggleAccessPerm COM_RIGHTS_EXECUTE
  10. Set TrusteeName RAYLAND\ACTEST1
  11. AddTrustee AccessRequestList
  12. Set TrusteeName RAYLAND\ACTEST2
  13. AddTrustee AccessRequestList
  14. Set TrusteeName RAYLAND\ACTEST3
  15. AddTrustee AccessRequestList
  16. Set TrusteeName RAYLAND\ACTEST4
  17. AddTrustee AccessRequestList
  18. Set TrusteeName RAYLAND\ADMINISTRATOR
  19. AddTrustee AccessRequestList
  20. # Add the GRANT_ACCESS ACEs
  21. Exec GrantAccessRights
  22. #Take a peek at the ACL
  23. Exec GetExplicitAccessRights
  24. # Goes through the same procedure for DENY_ACCESS ACEs but removes the local access request list first
  25. Destroy AccessRequestList
  26. Set TrusteeName RAYLAND\ACTEST5
  27. AddTrustee AccessRequestList
  28. Set TrusteeName RAYLAND\ACTEST6
  29. AddTrustee AccessRequestList
  30. Set TrusteeName RAYLAND\ACTEST7
  31. AddTrustee AccessRequestList
  32. Set TrusteeName RAYLAND\ACTEST8
  33. AddTrustee AccessRequestList
  34. # Add the DENY_ACCESS ACEs
  35. Exec DenyAccessRights
  36. # Call GetExplicitAccessRights to see if the ACL has been set up properly
  37. Exec GetExplicitAccessRights
  38. # Set current trustee to RAYLAND\ADMINISTRATOR and perform access
  39. Set TrusteeName RAYLAND\Administrator
  40. # RAYLAND\Administrator should be granted COM_RIGHTS_EXECUTE access
  41. Exec IsAccessPermitted
  42. # Change the client security context to that of RAYLAND\ACTEST2 so I can preform some
  43. # access checking
  44. SwitchClientCtx
  45. ACTEST2
  46. RAYLAND
  47. # Set the current trustee to RAYLAND\ACTEST2
  48. Set TrusteeName RAYLAND\ACTEST2
  49. # Call IsAccessPermitted to perform acces checking. ACTEST2 should be granted access
  50. # to the object.
  51. Exec IsAccessPermitted
  52. # Revoke some trustees from the ACL and see what happens....
  53. Set TrusteeName RAYLAND\ACTEST4
  54. AddTrustee TrusteeList
  55. Exec RevokeExplicitAccessRights
  56. Exec GetExplicitAccessRights
  57. Destroy TrusteeList
  58. Set Trusteename RAYLAND\ACTEST2
  59. AddTrustee TrusteeList
  60. Exec RevokeExplicitAccessRights
  61. Exec GetExplicitAccessRights
  62. # Call GetSizeMax to get the number of bytes required to dsave the ACL
  63. Exec GetSizeMax
  64. # Save the ACL to a file
  65. Exec SaveACL c:\actests\data1
  66. # Init a new ACL
  67. Exec InitNewACL
  68. # Take a look at the current ACL, it should be empty
  69. Exec GetExplicitAccessRights
  70. # Load the ACL back from the same file
  71. Exec LoadACL c:\actests\data1
  72. # Take a look at the ACL, it should look the same as before it was saved
  73. Exec GetExplicitAccessRights
  74. # Revoke two grant ACEs to see what happens
  75. Set TrusteeName RAYLAND\ACTEST4
  76. AddTrustee TrusteeList
  77. Exec RevokeAccessRights
  78. # Take a look at the resulting ACL
  79. Exec GetExplicitAccessRights
  80. Destroy TrusteeList
  81. Set TrusteeName RAYLAND\ACTEST2
  82. AddTrustee TrusteeList
  83. Exec RevokeAccessRights
  84. # Take another peek a the resulting ACL
  85. Exec GetExplicitAccessRights
  86. # Perform access check for RAYLAND\ACTEST2 to check
  87. # if the revoking really works. RAYLAND\ACTEST2 should
  88. # be denied access to the object.
  89. Set TrusteeName RAYLAND\ACTEST2
  90. Exec IsAccessPermitted
  91. # Replace the ACL with a new one
  92. Set TrusteeName A
  93. Set AccessMode GRANT_ACCESS
  94. AddTrustee ExplicitAccessList
  95. Set TrusteeName B
  96. Set AccessMode DENY_ACCESS
  97. AddTrustee ExplicitAccessList
  98. Set TrusteeName G
  99. Set AccessMode GRANT_ACCESS
  100. AddTrustee ExplicitAccessList
  101. Set TrusteeName H
  102. Set AccessMode DENY_ACCESS
  103. AddTrustee ExplicitAccessList
  104. Set TrusteeName E
  105. Set AccessMode GRANT_ACCESS
  106. AddTrustee ExplicitAccessList
  107. Set TrusteeName K
  108. Set AccessMode DENY_ACCESS
  109. AddTrustee ExplicitAccessList
  110. Set TrusteeName F
  111. Set AccessMode GRANT_ACCESS
  112. AddTrustee ExplicitAccessList
  113. Set TrusteeName L
  114. Set AccessMode DENY_ACCESS
  115. AddTrustee ExplicitAccessList
  116. Set TrusteeName A
  117. Set AccessMode GRANT_ACCESS
  118. AddTrustee ExplicitAccessList
  119. Exec ReplaceAllAccessRights
  120. Exec GetExplicitAccessRights
  121. # Kill server and quit
  122. Quit
  123. # End of Test #1