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.

185 lines
6.5 KiB

  1. Sub DeleteAFile(filespec)
  2. Dim fso
  3. Set fso = CreateObject("Scripting.FileSystemObject")
  4. fso.DeleteFile(filespec)
  5. End Sub
  6. rem DeleteAFile("abc.xml")
  7. Dim pAdminManager
  8. Set pAdminManager=CreateObject("AzRoles.AzAdminManager")
  9. pAdminManager.Initialize 1, "msxml://abc.xml"
  10. pAdminManager.Submit
  11. Dim AppHandle1
  12. Set AppHandle1=pAdminManager.CreateApplication("MyApp", 0)
  13. AppHandle1.Submit
  14. Dim OpHandle1
  15. Set OpHandle1=AppHandle1.CreateOperation("Op1", 0)
  16. OpHandle1.Submit
  17. OpHandle1.SetProperty 200, CLng(61)
  18. OpHandle1.Submit
  19. Set OpHandle1=AppHandle1.CreateOperation("Op2", 0)
  20. OpHandle1.Submit
  21. OpHandle1.SetProperty 200, CLng(62)
  22. OpHandle1.Submit
  23. Set OpHandle1=AppHandle1.CreateOperation("Op3", 0)
  24. OpHandle1.Submit
  25. OpHandle1.SetProperty 200, CLng(63)
  26. OpHandle1.Submit
  27. Set OpHandle1=AppHandle1.CreateOperation("Op4", 0)
  28. OpHandle1.Submit
  29. OpHandle1.SetProperty 200, CLng(64)
  30. OpHandle1.Submit
  31. Dim GroupHandleA
  32. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupWorld", 0)
  33. GroupHandleA.SetProperty 400, CLng(2)
  34. GroupHandleA.AddPropertyItem 404, CStr("s-1-1-0")
  35. GroupHandleA.Submit
  36. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupNotAMember", 0)
  37. GroupHandleA.SetProperty 400, CLng(2)
  38. GroupHandleA.AddPropertyItem 404, CStr("S-1-1000-1")
  39. GroupHandleA.Submit
  40. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupAppMember", 0)
  41. GroupHandleA.SetProperty 400, CLng(2)
  42. GroupHandleA.AddPropertyItem 401, CStr("GroupWorld")
  43. GroupHandleA.Submit
  44. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupAppNonMember", 0)
  45. GroupHandleA.SetProperty 400, CLng(2)
  46. GroupHandleA.AddPropertyItem 401, CStr("GroupAppMember")
  47. GroupHandleA.AddPropertyItem 402, CStr("GroupNotAMember")
  48. GroupHandleA.Submit
  49. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupAppReallyNonMember", 0)
  50. GroupHandleA.SetProperty 400, CLng(2)
  51. GroupHandleA.AddPropertyItem 401, CStr("GroupAppMember")
  52. GroupHandleA.AddPropertyItem 402, CStr("GroupWorld")
  53. GroupHandleA.Submit
  54. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupLdapYes", 0)
  55. GroupHandleA.SetProperty 400, CLng(1)
  56. GroupHandleA.SetProperty 403, CStr("(userAccountControl=1049088)")
  57. GroupHandleA.Submit
  58. Set GroupHandleA=AppHandle1.CreateApplicationGroup("GroupLdapNo", 0)
  59. GroupHandleA.SetProperty 400, CLng(1)
  60. GroupHandleA.SetProperty 403, CStr("(userAccountControl=1049089)")
  61. GroupHandleA.Submit
  62. Dim ScopeHandle1
  63. Set ScopeHandle1=AppHandle1.CreateScope("MyScopeNoRoles", 0)
  64. ScopeHandle1.Submit
  65. Set ScopeHandle1=AppHandle1.CreateScope("MyScope", 0)
  66. ScopeHandle1.Submit
  67. Dim CCHandle
  68. Set CCHandle=AppHandle1.InitializeClientContextFromToken(0, 0)
  69. Dim RoleHandleA
  70. Set RoleHandleA=ScopeHandle1.CreateRole("RoleEveryoneCanOp1", 0)
  71. RoleHandleA.Submit
  72. Dim Groups
  73. RoleHandleA.AddPropertyItem 501, CStr("s-1-1-0")
  74. Groups = RoleHandleA.GetProperty( 501, 0 )
  75. rem MsgBox( Groups(0) )
  76. RoleHandleA.AddPropertyItem 502, CStr("Op1")
  77. Set RoleHandleA=ScopeHandle1.CreateRole("RoleGroupWorldCanOp2", 0)
  78. RoleHandleA.AddPropertyItem 500, CStr("GroupWorld")
  79. Groups = RoleHandleA.GetProperty( 500, 0 )
  80. rem MsgBox( Groups(0) )
  81. RoleHandleA.AddPropertyItem 502, CStr("Op2")
  82. Set RoleHandleA=ScopeHandle1.CreateRole("RoleGroupCantOp3", 0)
  83. RoleHandleA.AddPropertyItem 500, CStr("GroupNotAMember")
  84. RoleHandleA.AddPropertyItem 502, CStr("Op3")
  85. RoleHandleA.Submit
  86. Set ScopeHandle1=AppHandle1.CreateScope("MyScope2", 0)
  87. ScopeHandle1.Submit
  88. Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupWorldCanOp2", 0)
  89. RoleHandleA.AddPropertyItem 500, CStr("GroupWorld")
  90. RoleHandleA.AddPropertyItem 502, CStr("Op2")
  91. RoleHandleA.Submit
  92. Set RoleHandleA=ScopeHandle1.CreateRole("Role2aGroupWorldCanOp2", 0)
  93. RoleHandleA.AddPropertyItem 500, CStr("GroupWorld")
  94. RoleHandleA.AddPropertyItem 502, CStr("Op2")
  95. RoleHandleA.Submit
  96. Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupCantOp3", 0)
  97. RoleHandleA.AddPropertyItem 500, CStr("GroupNotAMember")
  98. RoleHandleA.AddPropertyItem 502, CStr("Op3")
  99. RoleHandleA.Submit
  100. Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupWorldCanOp3", 0)
  101. RoleHandleA.AddPropertyItem 500, CStr("GroupWorld")
  102. RoleHandleA.AddPropertyItem 502, CStr("Op3")
  103. RoleHandleA.Submit
  104. Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupWorldCanOp4", 0)
  105. RoleHandleA.AddPropertyItem 500, CStr("GroupWorld")
  106. RoleHandleA.AddPropertyItem 502, CStr("Op4")
  107. RoleHandleA.Submit
  108. Set RoleHandleA=ScopeHandle1.CreateRole("Role2GroupCantOp4", 0)
  109. RoleHandleA.AddPropertyItem 500, CStr("GroupNotAMember")
  110. RoleHandleA.AddPropertyItem 502, CStr("Op4")
  111. RoleHandleA.Submit
  112. Dim TaskHandle1
  113. Set TaskHandle1=AppHandle1.CreateTask("TaskOp1", 0)
  114. TaskHandle1.AddPropertyItem 300, CStr("Op1")
  115. TaskHandle1.SetProperty 302, CStr("VBScript")
  116. TaskHandle1.SetProperty 301, CStr("Dim Amount" & vbCr & "Amount = AccessCheck.GetParameter( " & Chr(34) & "Amount" & Chr(34) & ")" & vbCr & "if Amount < 500 then AccessCheck.BusinessRuleResult = TRUE")
  117. TaskHandle1.Submit
  118. Set ScopeHandle1=AppHandle1.CreateScope("MyScope6", 0)
  119. ScopeHandle1.Submit
  120. Set RoleHandleA=ScopeHandle1.CreateRole("RoleEveryoneCanOp1ViaTask1", 0)
  121. RoleHandleA.AddPropertyItem 501, CStr("s-1-1-0")
  122. RoleHandleA.AddPropertyItem 504, CStr("TaskOp1")
  123. Set ScopeHandle1=AppHandle1.CreateScope("MyScopeQ1", 0)
  124. ScopeHandle1.Submit
  125. Set RoleHandleA=ScopeHandle1.CreateRole("RoleLdapCanOp1", 0)
  126. RoleHandleA.AddPropertyItem 500, CStr("GroupLdapYes")
  127. RoleHandleA.AddPropertyItem 504, CStr("TaskOp1")
  128. Dim Results
  129. Dim Names(5)
  130. Dim Values(5)
  131. Dim Scopes(5)
  132. Dim Operations(10)
  133. Names(0) = "Amount"
  134. Values(0) = 50
  135. Names(1) = "Name"
  136. Values(1) = "Bob"
  137. Scopes(0) = "MyScopeQ1"
  138. Operations(0) = 61
  139. Results=CCHandle.AccessCheck("MyObject", Scopes, Operations, Names, Values )
  140. If Results(0) = 5 Then
  141. MsgBox("Broken 1")
  142. Else
  143. MsgBox("Is OK 1")
  144. End if
  145. TaskHandle1.SetProperty 301, CStr("AccessCheck.BusinessRuleString = " & Chr(34) & "Fred" & Chr(34) & vbCr & "if AccessCheck.BusinessRuleString = " & Chr(34) & "Fred" & Chr(34) & "then AccessCheck.BusinessRuleResult = TRUE")
  146. Results=CCHandle.AccessCheck("MyObject", Scopes, Operations, Names, Values )
  147. If Results(0) = 5 Then
  148. MsgBox("Broken 2")
  149. Else
  150. MsgBox("Is OK 2")
  151. End if
  152. MsgBox( "Should be fred: " & CCHandle.GetBusinessRuleString )
  153. TaskHandle1.SetProperty 301, CStr("if AccessCheck.BusinessRuleString = " & Chr(34) & Chr(34) & "then AccessCheck.BusinessRuleResult = TRUE")
  154. Results=CCHandle.AccessCheck("MyObject", Scopes, Operations, Names, Values )
  155. If Results(0) = 5 Then
  156. MsgBox("Broken 3")
  157. Else
  158. MsgBox("Is OK 3")
  159. End if
  160. MsgBox( "Should be NULL: " & CCHandle.GetBusinessRuleString )