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.

4478 lines
193 KiB

  1. /*--
  2. Copyright (c) 1987-1993 Microsoft Corporation
  3. Module Name:
  4. aztest.c
  5. Abstract:
  6. Test program for the azroles DLL.
  7. Author:
  8. Cliff Van Dyke (cliffv) 16-Apr-2001
  9. Environment:
  10. User mode only.
  11. Contains NT-specific code.
  12. Requires ANSI C extensions: slash-slash comments, long external names.
  13. Revision History:
  14. --*/
  15. //
  16. // Common include files.
  17. //
  18. #define UNICODE 1
  19. // #define SECURITY_WIN32 1
  20. #include <nt.h>
  21. #include <ntrtl.h>
  22. #include <nturtl.h>
  23. #include <windows.h>
  24. #include "azrolesp.h"
  25. #include <lmcons.h>
  26. #include <lmerr.h>
  27. #include <stdio.h> // printf
  28. #include <sddl.h>
  29. #include <ntstatus.dbg>
  30. #include <winerror.dbg>
  31. //
  32. // Sundry defines to enable optional tests
  33. //
  34. // #define ENABLE_LEAK 1 // Run a test that leaks memory
  35. // #define ENABLE_CAUGHT_AVS 1 // Run a test that AVs in azroles.dll (but the AV is caught)
  36. // #define ENABLE_LOCAL_ACCOUNT 1 // Run tests with user logged onto a local account
  37. // #define ENABLE_NT4_ACCOUNT 1 // Run tests with user logged onto an NT4 domain account
  38. //#define ENABLE_CHAITU_ACCOUNT 1 // Run tests as CHAITU
  39. // #define ENABLE_CLIFFV_ACCOUNT 1 // Run tests as CLIFFV
  40. #define ENABLE_ADMIN_ACCOUNT_XML 1 // Run tests as CLIFFVDOM\Administrator (on XML store)
  41. // #define ENABLE_ADMIN_ACCOUNT_AD 1 // Run tests as CLIFFVDOM\Administrator (on AD store)
  42. // #define ENABLE_DC_DOWN 1 // Run tests where DC cannot be located
  43. #if defined(ENABLE_LOCAL_ACCOUNT) || defined(ENABLE_NT4_ACCOUNT)
  44. #define ENABLE_NON_DS_ACCOUNT 1
  45. #endif
  46. #if defined(ENABLE_ADMIN_ACCOUNT_XML) || defined(ENABLE_ADMIN_ACCOUNT_AD)
  47. #define ENABLE_ADMIN_ACCOUNT 1
  48. #endif
  49. //
  50. // Global parameters to AzInitialize
  51. //
  52. LPWSTR AzGlTestFile;
  53. BOOLEAN NoInitAllTests = FALSE;
  54. BOOLEAN NoUpdateCache = FALSE;
  55. BOOLEAN Silent = FALSE;
  56. //
  57. // Structure to define an operation to preform
  58. //
  59. typedef struct _OPERATION {
  60. // The operation
  61. ULONG Opcode;
  62. // These are generic opcodes that work for all object types
  63. #define AzoGenCreate 0
  64. #define AzoGenOpen 1
  65. #define AzoGenEnum 2
  66. #define AzoGenDelete 3
  67. #define AzoGenMax 50
  68. //
  69. // These are object specific opcodes
  70. //
  71. #define AzoAdm 51
  72. #define AzoAdmDelete (AzoAdm+AzoGenDelete)
  73. #define AzoApp 100
  74. #define AzoAppCreate (AzoApp+AzoGenCreate)
  75. #define AzoAppOpen (AzoApp+AzoGenOpen)
  76. #define AzoAppEnum (AzoApp+AzoGenEnum)
  77. #define AzoAppDelete (AzoApp+AzoGenDelete)
  78. #define AzoOp 200
  79. #define AzoOpCreate (AzoOp+AzoGenCreate)
  80. #define AzoOpOpen (AzoOp+AzoGenOpen)
  81. #define AzoOpEnum (AzoOp+AzoGenEnum)
  82. #define AzoOpDelete (AzoOp+AzoGenDelete)
  83. #define AzoTask 300
  84. #define AzoTaskCreate (AzoTask+AzoGenCreate)
  85. #define AzoTaskOpen (AzoTask+AzoGenOpen)
  86. #define AzoTaskEnum (AzoTask+AzoGenEnum)
  87. #define AzoTaskDelete (AzoTask+AzoGenDelete)
  88. #define AzoScope 400
  89. #define AzoScopeCreate (AzoScope+AzoGenCreate)
  90. #define AzoScopeOpen (AzoScope+AzoGenOpen)
  91. #define AzoScopeEnum (AzoScope+AzoGenEnum)
  92. #define AzoScopeDelete (AzoScope+AzoGenDelete)
  93. #define AzoGroup 500
  94. #define AzoGroupCreate (AzoGroup+AzoGenCreate)
  95. #define AzoGroupOpen (AzoGroup+AzoGenOpen)
  96. #define AzoGroupEnum (AzoGroup+AzoGenEnum)
  97. #define AzoGroupDelete (AzoGroup+AzoGenDelete)
  98. #define AzoRole 600
  99. #define AzoRoleCreate (AzoRole+AzoGenCreate)
  100. #define AzoRoleOpen (AzoRole+AzoGenOpen)
  101. #define AzoRoleEnum (AzoRole+AzoGenEnum)
  102. #define AzoRoleDelete (AzoRole+AzoGenDelete)
  103. #define AzoCC 800
  104. //
  105. // Real APIs that don't map to the generic APIs
  106. #define AzoInit 1000
  107. #define AzoClose 1001
  108. #define AzoInitCFT 1002 // AzInitContextFromToken
  109. #define AzoAccess 1003
  110. #define AzoGetProp 1004
  111. #define AzoSetProp 1005
  112. #define AzoAddProp 1006
  113. #define AzoRemProp 1007
  114. #define AzoAdmDeleteNoInit 1008 // Same as AdmDelete but don't AzInitialize first
  115. #define AzoUpdateCache 1009
  116. //
  117. // Pseudo opcode for TestLink subroutine
  118. //
  119. #define AzoTl 2000
  120. #define AzoTlCreate (AzoTl+AzoGenCreate)
  121. #define AzoTlOpen (AzoTl+AzoGenOpen)
  122. #define AzoTlEnum (AzoTl+AzoGenEnum)
  123. #define AzoTlDelete (AzoTl+AzoGenDelete)
  124. #define AzoTlMax 2999
  125. // Opcodes that aren't really API calls
  126. #define AzoSleep 0x0FFFFFFA
  127. #define AzoTestLink 0x0FFFFFFB
  128. #define AzoGoSub 0x0FFFFFFC
  129. #define AzoEcho 0x0FFFFFFD
  130. #define AzoDupHandle 0x0FFFFFFE
  131. #define AzoEndOfList 0x0FFFFFFF
  132. //
  133. // Bits that can be OR'ed into any opcode
  134. //
  135. #define AzoAbort 0x80000000 // Abort instead of commit
  136. #define AzoNoSubmit 0x40000000 // Neither abort nor commit
  137. #define AzoNoUpdateCache 0x20000000 // Don't call AzUpdateCache
  138. // Input Handle
  139. PAZ_HANDLE InputHandle;
  140. // Input Parameter
  141. LPWSTR Parameter1;
  142. // Output Handle
  143. // For AzoAccess, this is an array of operations
  144. PAZ_HANDLE OutputHandle;
  145. // Expected result status code
  146. ULONG ExpectedStatus;
  147. // List of operations to perform on each enumeration handle
  148. struct _OPERATION *EnumOperations;
  149. // Expected result String parameter
  150. // For AzoAccess, this is an array of results
  151. LPWSTR ExpectedParameter1;
  152. // Property ID of Get/SetPropertyId functions
  153. // For AzoAccess, this is the operation count.
  154. ULONG PropertyId;
  155. } OPERATION, *POPERATION;
  156. //
  157. // Global handles
  158. //
  159. AZ_HANDLE AdminMgrHandle1;
  160. AZ_HANDLE AdminMgrHandle2;
  161. AZ_HANDLE AppHandle1;
  162. AZ_HANDLE AppHandle2;
  163. AZ_HANDLE OpHandle1;
  164. AZ_HANDLE TaskHandleA;
  165. AZ_HANDLE TaskHandle1;
  166. AZ_HANDLE TaskHandle2;
  167. AZ_HANDLE TaskHandleT;
  168. AZ_HANDLE ScopeHandle1;
  169. AZ_HANDLE ScopeHandle2;
  170. AZ_HANDLE GroupHandleA;
  171. AZ_HANDLE GroupHandleB;
  172. AZ_HANDLE GroupHandle1;
  173. AZ_HANDLE GroupHandle2;
  174. AZ_HANDLE GroupHandleT;
  175. AZ_HANDLE RoleHandleA;
  176. AZ_HANDLE RoleHandle1;
  177. AZ_HANDLE RoleHandle2;
  178. AZ_HANDLE GenParentHandle1;
  179. AZ_HANDLE GenHandle1;
  180. AZ_HANDLE GenHandle2;
  181. AZ_HANDLE GenHandleE;
  182. AZ_HANDLE GenHandleE2;
  183. HANDLE TokenHandle;
  184. AZ_HANDLE CCHandle;
  185. AZ_HANDLE CCHandle2;
  186. //
  187. // Constant property values
  188. //
  189. ULONG Zero = 0;
  190. ULONG Eight = 8;
  191. ULONG EightHundred = 800;
  192. ULONG Nine = 9;
  193. ULONG FifteenThousand = 15000;
  194. ULONG FiveThousand = 5000;
  195. ULONG FortyFiveThousand = 45000;
  196. ULONG GtBasic = AZ_GROUPTYPE_BASIC;
  197. ULONG GtLdap = AZ_GROUPTYPE_LDAP_QUERY;
  198. LONG AzGlTrue = TRUE;
  199. #define ValidGuid L"47e348af-ff79-41af-8a67-2835d4c417f4"
  200. //
  201. // Various Sid constants
  202. //
  203. typedef struct _SID8 {
  204. UCHAR Revision;
  205. UCHAR SubAuthorityCount;
  206. SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
  207. ULONG SubAuthority[8];
  208. } SID8, *PISID8;
  209. #define SECURITY_MISC_AUTHORITY {0,0,0,0,3,0xe8}
  210. SID SidWorld = { 1, 1, SECURITY_WORLD_SID_AUTHORITY, SECURITY_WORLD_RID };
  211. SID SidCreatorOwner = { 1, 1, SECURITY_CREATOR_SID_AUTHORITY, SECURITY_CREATOR_OWNER_RID };
  212. SID SidLocal = { 1, 1, SECURITY_LOCAL_SID_AUTHORITY, SECURITY_LOCAL_RID };
  213. SID Sid1 = { 1, 1, SECURITY_MISC_AUTHORITY, 1 };
  214. SID Sid2 = { 1, 1, SECURITY_MISC_AUTHORITY, 2 };
  215. SID Sid3 = { 1, 1, SECURITY_MISC_AUTHORITY, 3 };
  216. SID Sid4 = { 1, 1, SECURITY_MISC_AUTHORITY, 4 };
  217. SID Sid5 = { 1, 1, SECURITY_MISC_AUTHORITY, 5 };
  218. SID Sid6 = { 1, 1, SECURITY_MISC_AUTHORITY, 6 };
  219. #ifdef ENABLE_CLIFFV_ACCOUNT
  220. SID8 SidOwner = { 1, 5, SECURITY_NT_AUTHORITY, SECURITY_NT_NON_UNIQUE, 397955417, 626881126, 188441444, 2908288 };
  221. #endif // ENABLE_CLIFFV_ACCOUNT
  222. #ifdef ENABLE_ADMIN_ACCOUNT_XML
  223. SID8 SidOwner = { 1, 2, SECURITY_NT_AUTHORITY, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS };
  224. #endif // ENABLE_ADMIN_ACCOUNT_XML
  225. #ifdef ENABLE_ADMIN_ACCOUNT_AD
  226. SID8 SidOwner = { 1, 5, SECURITY_NT_AUTHORITY, SECURITY_NT_NON_UNIQUE, 3421389450, 3242236637, 3934022420, 512 };
  227. #endif // ENABLE_ADMIN_ACCOUNT_AD
  228. #ifdef ENABLE_CHAITU_ACCOUNT
  229. SID8 SidOwner = { 1, 5, SECURITY_NT_AUTHORITY, SECURITY_NT_NON_UNIQUE, 397955417, 626881126, 188441444, 3014042 };
  230. #endif // ENABLE_CHAITU_ACCOUNT
  231. PSID SidWorldOwnerx[] = { &SidWorld, (PSID)&SidOwner };
  232. AZ_SID_ARRAY SidWorldOwnerArray = { 2, SidWorldOwnerx };
  233. PSID SidOwnerx[] = { (PSID)&SidOwner };
  234. AZ_SID_ARRAY SidOwnerArray = { 1, SidOwnerx };
  235. PSID SidWorldx[] = { (PSID)&SidWorld };
  236. AZ_SID_ARRAY SidWorldArray = { 1, SidWorldx };
  237. DWORD SidX[100];
  238. PSID Sid2x[] = { &Sid2 };
  239. AZ_SID_ARRAY Sid2Array = { 1, Sid2x };
  240. PSID Sid3x[] = { &Sid3 };
  241. AZ_SID_ARRAY Sid3Array = { 1, Sid3x };
  242. PSID Sid23x[] = { &Sid2, &Sid3 };
  243. AZ_SID_ARRAY Sid23Array = { 2, Sid23x };
  244. PSID Sid123x[] = { &Sid1, &Sid2, &Sid3 };
  245. AZ_SID_ARRAY Sid123Array = { 3, Sid123x };
  246. PSID Sid123456x[] = { &Sid1, &Sid2, &Sid3, &Sid4, &Sid5, &Sid6 };
  247. AZ_SID_ARRAY Sid123456Array = { 6, Sid123456x };
  248. //
  249. // Generic operations valid for all enumerations
  250. //
  251. // Requires GenHandleE to already be set
  252. //
  253. // Test double close of enum handle
  254. OPERATION OpAppChildGenEnum1[] = {
  255. { AzoDupHandle, &GenHandleE, NULL, &GenHandleE2, NO_ERROR },
  256. { AzoClose, &GenHandleE, NULL, NULL, NO_ERROR },
  257. { AzoClose, &GenHandleE, NULL, NULL, ERROR_INVALID_HANDLE },
  258. { AzoClose, &GenHandleE2, NULL, NULL, ERROR_INVALID_HANDLE },
  259. { AzoEndOfList }
  260. };
  261. // General purpose object enum
  262. OPERATION OpAppChildGenEnum2[] = {
  263. { AzoGetProp, &GenHandleE, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  264. { AzoGetProp, &GenHandleE, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_DESCRIPTION },
  265. { AzoClose, &GenHandleE, NULL, NULL, NO_ERROR },
  266. { AzoEndOfList }
  267. };
  268. //
  269. // Generic operations that work on *ALL* objects
  270. //
  271. // Requires GenParentHandle1 to already be set
  272. //
  273. OPERATION OpGen[] = {
  274. { AzoEcho, NULL, L"Gen object test" },
  275. { AzoGenCreate, &GenParentHandle1,L"|", &GenHandle1, ERROR_INVALID_NAME },
  276. { AzoGenCreate, &GenParentHandle1,L"Name1", &GenHandle1, NO_ERROR },
  277. { AzoDupHandle, &GenHandle1, NULL, &GenHandle2, NO_ERROR },
  278. { AzoClose, &GenHandle1, NULL, NULL, NO_ERROR },
  279. { AzoClose, &GenHandle2, NULL, NULL, ERROR_INVALID_HANDLE },
  280. { AzoGenEnum, &GenHandle1, NULL, &GenHandleE, ERROR_INVALID_HANDLE },
  281. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum1 },
  282. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum2 },
  283. { AzoGenCreate, &GenParentHandle1,L"Name2", &GenHandle2, NO_ERROR },
  284. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum2 },
  285. { AzoClose, &GenHandle2, NULL, NULL, NO_ERROR },
  286. { AzoEcho, NULL, L"Delete an object and make sure it doesn't get enumerated" },
  287. { AzoGenCreate, &GenParentHandle1,L"Name3", &GenHandle2, NO_ERROR },
  288. { AzoGenDelete, &GenParentHandle1,L"Name3", NULL, NO_ERROR },
  289. { AzoClose, &GenHandle2, NULL, NULL, NO_ERROR },
  290. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum2 },
  291. { AzoEcho, NULL, L"Create an object whose name equals that of a deleted object" },
  292. { AzoGenCreate, &GenParentHandle1,L"Name3", &GenHandle2, NO_ERROR },
  293. { AzoClose, &GenHandle2, NULL, NULL, NO_ERROR },
  294. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum2 },
  295. { AzoEcho, NULL, L"Delete an object that isn't on the tail end of the enum list" },
  296. { AzoGenDelete, &GenParentHandle1,L"Name2", NULL, NO_ERROR },
  297. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum2 },
  298. { AzoEcho, NULL, L"Basic get/set property tests" },
  299. { AzoGenCreate, &GenParentHandle1,L"Name4", &GenHandle1, NO_ERROR },
  300. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"Name4", AZ_PROP_NAME },
  301. { AzoSetProp, &GenHandle1, L"|", NULL, ERROR_INVALID_NAME, NULL, NULL, AZ_PROP_NAME },
  302. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"Name4", AZ_PROP_NAME },
  303. { AzoSetProp, &GenHandle1, L"Name4", NULL, ERROR_ALREADY_EXISTS, NULL, NULL, AZ_PROP_NAME },
  304. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"Name4", AZ_PROP_NAME },
  305. { AzoSetProp, &GenHandle1, L"Name3", NULL, ERROR_ALREADY_EXISTS, NULL, NULL, AZ_PROP_NAME },
  306. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"Name4", AZ_PROP_NAME },
  307. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_DESCRIPTION },
  308. { AzoSetProp, &GenHandle1, L"WasName4", NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  309. { AzoSetProp, &GenHandle1, L"Nam4 Desc",NULL, NO_ERROR, NULL, NULL, AZ_PROP_DESCRIPTION },
  310. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"WasName4", AZ_PROP_NAME },
  311. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"Nam4 Desc", AZ_PROP_DESCRIPTION },
  312. { AzoGenEnum, &GenParentHandle1,NULL, &GenHandleE, NO_ERROR, OpAppChildGenEnum2 },
  313. { AzoClose, &GenHandle1, NULL, NULL, NO_ERROR },
  314. { AzoEcho, NULL, L"Ensure a newly created object is writable" },
  315. { AzoGenCreate, &GenParentHandle1,L"Name5", &GenHandle2, NO_ERROR },
  316. { AzoGetProp, &GenHandle2, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&AzGlTrue, AZ_PROP_WRITABLE },
  317. { AzoClose, &GenHandle2, NULL, NULL, NO_ERROR },
  318. { AzoEcho, NULL, L"Open test" },
  319. { AzoGenOpen, &GenParentHandle1,L"Name1", &GenHandle1, NO_ERROR },
  320. { AzoGetProp, &GenHandle1, NULL, NULL, NO_ERROR, NULL, L"Name1", AZ_PROP_NAME },
  321. { AzoClose, &GenHandle1, NULL, NULL, NO_ERROR },
  322. { AzoGenOpen, &GenParentHandle1,L"NameBad", &GenHandle1, ERROR_NOT_FOUND },
  323. { AzoEndOfList }
  324. };
  325. //
  326. // Operations specific to admin manager objects
  327. //
  328. OPERATION OpAdm[] = {
  329. { AzoEcho, NULL, L"Admin Manager specific operations" },
  330. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  331. { AzoEcho, NULL, L"Ensure the admin manager object is marked writable" },
  332. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&AzGlTrue, AZ_PROP_WRITABLE },
  333. { AzoEcho, NULL, L"Set description on Admin Manager" },
  334. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_DESCRIPTION },
  335. { AzoSetProp, &AdminMgrHandle1, L"Adm Desc", NULL, NO_ERROR, NULL, NULL, AZ_PROP_DESCRIPTION },
  336. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, L"Adm Desc", AZ_PROP_DESCRIPTION },
  337. { AzoEcho, NULL, L"Set Application Data on AdminManager" },
  338. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_APPLICATION_DATA },
  339. { AzoSetProp, &AdminMgrHandle1, L"Adm Application Data", NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_DATA },
  340. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, L"Adm Application Data", AZ_PROP_APPLICATION_DATA },
  341. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&FifteenThousand, AZ_PROP_ADMIN_DOMAIN_TIMEOUT },
  342. { AzoSetProp, &AdminMgrHandle1, (LPWSTR)&EightHundred,NULL, NO_ERROR, NULL, NULL, AZ_PROP_ADMIN_DOMAIN_TIMEOUT },
  343. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EightHundred, AZ_PROP_ADMIN_DOMAIN_TIMEOUT },
  344. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  345. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  346. { AzoEcho, NULL, L"Test closing admin manager with other handle open" },
  347. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  348. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  349. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  350. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  351. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, 0 },
  352. { AzoEcho, NULL, L"Test Setting the list of admins" },
  353. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&SidOwnerArray, AZ_PROP_POLICY_ADMINS },
  354. { AzoAddProp, &AdminMgrHandle1, (LPWSTR)&SidCreatorOwner, NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_POLICY_ADMINS },
  355. { AzoAddProp, &AdminMgrHandle1, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_POLICY_ADMINS },
  356. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&SidWorldOwnerArray, AZ_PROP_POLICY_ADMINS },
  357. { AzoRemProp, &AdminMgrHandle1, (LPWSTR)&SidOwner, NULL, NO_ERROR, NULL, NULL, AZ_PROP_POLICY_ADMINS },
  358. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&SidWorldArray, AZ_PROP_POLICY_ADMINS },
  359. { AzoRemProp, &AdminMgrHandle1, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_POLICY_ADMINS },
  360. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&SidOwnerArray, AZ_PROP_POLICY_ADMINS },
  361. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  362. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  363. { AzoEndOfList }
  364. };
  365. //
  366. // Generic operations valid for all children of "admin manager"
  367. //
  368. OPERATION OpAdmChildGen[] = {
  369. { AzoEcho, NULL, L"Admin Manager generic Child object test" },
  370. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  371. // Do a bunch of stuff not specific to application children
  372. { AzoDupHandle, &AdminMgrHandle1, NULL, &GenParentHandle1,NO_ERROR },
  373. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGen },
  374. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  375. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  376. { AzoEndOfList }
  377. };
  378. OPERATION OpAdmChildGenDupName[] = {
  379. { AzoEcho, NULL, L"Test creating two objects with the same name" },
  380. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  381. { AzoGenCreate, &AdminMgrHandle1, L"Name1", &GenHandle1, NO_ERROR },
  382. { AzoGenCreate, &AdminMgrHandle1, L"Name1", &GenHandle2, ERROR_ALREADY_EXISTS },
  383. { AzoClose, &GenHandle1, NULL, NULL, NO_ERROR },
  384. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  385. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  386. { AzoEndOfList }
  387. };
  388. //
  389. // Generic operations valid for all children of "application"
  390. //
  391. OPERATION OpAppChildGen[] = {
  392. { AzoEcho, NULL, L"Application generic Child object test" },
  393. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  394. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  395. // Do a bunch of stuff not specific to application children
  396. { AzoDupHandle, &AppHandle1, NULL, &GenParentHandle1,NO_ERROR },
  397. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGen },
  398. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  399. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  400. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  401. { AzoEndOfList }
  402. };
  403. OPERATION OpAppChildGenDupName[] = {
  404. { AzoEcho, NULL, L"Test creating two objects with the same name" },
  405. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  406. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  407. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle2, ERROR_ALREADY_EXISTS },
  408. { AzoGenCreate, &AppHandle1, L"Name1", &GenHandle1, NO_ERROR },
  409. { AzoGenCreate, &AppHandle1, L"Name1", &GenHandle2, ERROR_ALREADY_EXISTS },
  410. { AzoClose, &GenHandle1, NULL, NULL, NO_ERROR },
  411. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  412. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  413. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  414. { AzoEndOfList }
  415. };
  416. OPERATION OpAppChildGenLeak[] = {
  417. { AzoEcho, NULL, L"Test leaking a handle" },
  418. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  419. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  420. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  421. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  422. { AzoEndOfList }
  423. };
  424. //
  425. // Generic operations valid for all children of "scope"
  426. //
  427. OPERATION OpScopeChildGen[] = {
  428. { AzoEcho, NULL, L"Scope generic Child object test" },
  429. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  430. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  431. { AzoScopeCreate,&AppHandle1, L"Scope 1", &ScopeHandle1, NO_ERROR },
  432. // Do a bunch of stuff not specific to scope children
  433. { AzoDupHandle, &ScopeHandle1, NULL, &GenParentHandle1,NO_ERROR },
  434. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGen },
  435. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  436. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  437. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  438. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  439. { AzoEndOfList }
  440. };
  441. OPERATION OpScopeChildGenDupName[] = {
  442. { AzoEcho, NULL, L"Test creating two objects with the same name" },
  443. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  444. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  445. { AzoScopeCreate,&AppHandle1, L"Scope 1", &ScopeHandle1, NO_ERROR },
  446. { AzoGenCreate, &ScopeHandle1, L"Name1", &GenHandle1, NO_ERROR },
  447. { AzoGenCreate, &ScopeHandle1, L"Name1", &GenHandle2, ERROR_ALREADY_EXISTS },
  448. { AzoClose, &GenHandle1, NULL, NULL, NO_ERROR },
  449. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  450. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  451. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  452. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  453. { AzoEndOfList }
  454. };
  455. //
  456. // Specific tests for application objects
  457. //
  458. OPERATION OpApplication[] = {
  459. { AzoEcho, NULL, L"Application object specific tests" },
  460. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  461. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  462. { AzoEcho, NULL, L"Ensure CLSID can be set" },
  463. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID },
  464. { AzoSetProp, &AppHandle1, L"Rule1", NULL, RPC_S_INVALID_STRING_UUID, NULL, NULL, AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID },
  465. { AzoSetProp, &AppHandle1, ValidGuid, NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID },
  466. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, ValidGuid, AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID },
  467. { AzoSetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID },
  468. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID },
  469. { AzoEcho, NULL, L"Ensure app version can be set" },
  470. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_APPLICATION_VERSION },
  471. { AzoSetProp, &AppHandle1, L"2160.5", NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_VERSION },
  472. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, L"2160.5", AZ_PROP_APPLICATION_VERSION },
  473. { AzoEcho, NULL, L"Ensure app data can be set" },
  474. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_APPLICATION_DATA },
  475. { AzoSetProp, &AppHandle1, L"App Application Data", NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_DATA },
  476. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, L"App Application Data", AZ_PROP_APPLICATION_DATA },
  477. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  478. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  479. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  480. { AzoEndOfList }
  481. };
  482. //
  483. // Specific tests for Operation objects
  484. //
  485. OPERATION OpOperation[] = {
  486. { AzoEcho, NULL, L"Operation object specific tests" },
  487. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  488. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  489. { AzoOpCreate, &AppHandle1, L"Oper 1", &OpHandle1, NO_ERROR },
  490. { AzoGetProp, &OpHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Zero, AZ_PROP_OPERATION_ID },
  491. { AzoSetProp, &OpHandle1, (LPWSTR)&Eight, NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  492. { AzoGetProp, &OpHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Eight, AZ_PROP_OPERATION_ID },
  493. { AzoEcho, NULL, L"Ensure operation Application data can be set" },
  494. { AzoGetProp, &OpHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_APPLICATION_DATA },
  495. { AzoSetProp, &OpHandle1, L"Op Application Data", NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_DATA },
  496. { AzoGetProp, &OpHandle1, NULL, NULL, NO_ERROR, NULL, L"Op Application Data", AZ_PROP_APPLICATION_DATA },
  497. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  498. { AzoEcho, NULL, L"Ensure an operation ID cannot be reused" },
  499. { AzoOpCreate, &AppHandle1, L"Oper 2", &OpHandle1, NO_ERROR },
  500. { AzoSetProp, &OpHandle1, (LPWSTR)&Eight, NULL, ERROR_ALREADY_EXISTS, NULL, NULL, AZ_PROP_OPERATION_ID },
  501. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  502. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  503. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  504. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  505. { AzoEndOfList }
  506. };
  507. //
  508. // Generic test of the ability of one object to link to another
  509. // AzoTestLink is the only opcode that can link to this subroutine of commands
  510. //
  511. AZ_STRING_ARRAY EmptyStringArray = { 0, NULL };
  512. ULONG TestLinkOpcodeOffset;
  513. ULONG TestLinkPropId;
  514. AZ_HANDLE TestLinkHandleP;
  515. AZ_HANDLE TestLinkHandleA;
  516. WCHAR TestLinkObjectName[1000];
  517. LPWSTR Op1x[] = { L"Op 1" };
  518. AZ_STRING_ARRAY Op1 = { 1, Op1x };
  519. LPWSTR Op12x[] = { L"Op 1", L"Op 2" };
  520. AZ_STRING_ARRAY Op12 = { 2, Op12x };
  521. LPWSTR Op24x[] = { L"Op 2", L"Op 4" };
  522. AZ_STRING_ARRAY Op24 = { 2, Op24x };
  523. LPWSTR Object2x[] = { L"Object 2" };
  524. AZ_STRING_ARRAY Object2 = { 1, Object2x };
  525. LPWSTR Object3x[] = { L"Object 3" };
  526. AZ_STRING_ARRAY Object3 = { 1, Object3x };
  527. LPWSTR Object23x[] = { L"Object 2", L"Object 3" };
  528. AZ_STRING_ARRAY Object23 = { 2, Object23x };
  529. LPWSTR Object123x[] = { L"Object 1", L"Object 2", L"Object 3" };
  530. AZ_STRING_ARRAY Object123 = { 3, Object123x };
  531. LPWSTR Object123456x[] = { L"Object 1", L"Object 2", L"Object 3", L"Object 4", L"Object 5", L"Object 6" };
  532. AZ_STRING_ARRAY Object123456 = { 6, Object123456x };
  533. OPERATION OpTestLink[] = {
  534. { AzoEcho, NULL, L"Create some objects to link the object to" },
  535. { AzoTlCreate, &TestLinkHandleP, L"Object 1", &OpHandle1, NO_ERROR },
  536. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  537. { AzoTlCreate, &TestLinkHandleP, L"Object 2", &OpHandle1, NO_ERROR },
  538. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  539. { AzoTlCreate, &TestLinkHandleP, L"Object 3", &OpHandle1, NO_ERROR },
  540. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  541. { AzoEcho, NULL, L"Reference an object that doesn't exist" },
  542. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, 1 },
  543. { AzoSetProp, &TestLinkHandleA, L"random", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, 1 },
  544. { AzoAddProp, &TestLinkHandleA, L"random", NULL, ERROR_NOT_FOUND, NULL, NULL, 1 },
  545. { AzoEcho, NULL, L"Add and remove several objects" },
  546. { AzoAddProp, &TestLinkHandleA, L"Object 2", NULL, NO_ERROR, NULL, NULL, 1 },
  547. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object2, 1 },
  548. { AzoAddProp, &TestLinkHandleA, L"Object 3", NULL, NO_ERROR, NULL, NULL, 1 },
  549. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object23, 1 },
  550. { AzoAddProp, &TestLinkHandleA, L"Object 1", NULL, NO_ERROR, NULL, NULL, 1 },
  551. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object123, 1 },
  552. { AzoRemProp, &TestLinkHandleA, L"Object 1", NULL, NO_ERROR, NULL, NULL, 1 },
  553. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object23, 1 },
  554. { AzoRemProp, &TestLinkHandleA, L"Object 2", NULL, NO_ERROR, NULL, NULL, 1 },
  555. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object3, 1 },
  556. #if 0
  557. // This test has a couple problems.
  558. // It assumes that the linked-to and linked-from objects have the same parents
  559. // It assumes that an Open returns the same handle value as a previous close
  560. { AzoEcho, NULL, L"Ensure the reference is still there after a close" },
  561. { AzoClose, &TestLinkHandleA, NULL, NULL, NO_ERROR },
  562. { AzoGenOpen, &TestLinkHandleP, TestLinkObjectName, &TestLinkHandleA, NO_ERROR },
  563. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object3, 1 },
  564. #endif // 0
  565. { AzoEcho, NULL, L"Add an item that already exists" },
  566. { AzoAddProp, &TestLinkHandleA, L"Object 3", NULL, ERROR_ALREADY_EXISTS, NULL, NULL, 1 },
  567. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object3, 1 },
  568. { AzoRemProp, &TestLinkHandleA, L"Object 3", NULL, NO_ERROR, NULL, NULL, 1 },
  569. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, 1 },
  570. { AzoEcho, NULL, L"Try more than 4 since reference buckets come in multiples of 4" },
  571. { AzoTlCreate, &TestLinkHandleP, L"Object 4", &OpHandle1, NO_ERROR },
  572. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  573. { AzoTlCreate, &TestLinkHandleP, L"Object 5", &OpHandle1, NO_ERROR },
  574. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  575. { AzoTlCreate, &TestLinkHandleP, L"Object 6", &OpHandle1, NO_ERROR },
  576. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  577. { AzoAddProp, &TestLinkHandleA, L"Object 1", NULL, NO_ERROR, NULL, NULL, 1 },
  578. { AzoAddProp, &TestLinkHandleA, L"Object 4", NULL, NO_ERROR, NULL, NULL, 1 },
  579. { AzoAddProp, &TestLinkHandleA, L"Object 2", NULL, NO_ERROR, NULL, NULL, 1 },
  580. { AzoAddProp, &TestLinkHandleA, L"Object 5", NULL, NO_ERROR, NULL, NULL, 1 },
  581. { AzoAddProp, &TestLinkHandleA, L"Object 3", NULL, NO_ERROR, NULL, NULL, 1 },
  582. { AzoAddProp, &TestLinkHandleA, L"Object 6", NULL, NO_ERROR, NULL, NULL, 1 },
  583. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Object123456, 1 },
  584. { AzoTlDelete, &TestLinkHandleP, L"Object 1", NULL, NO_ERROR, NULL, NULL, 1 },
  585. { AzoTlDelete|AzoNoUpdateCache, &TestLinkHandleP, L"Object 4", NULL, NO_ERROR, NULL, NULL, 1 },
  586. { AzoTlDelete|AzoNoUpdateCache, &TestLinkHandleP, L"Object 2", NULL, NO_ERROR, NULL, NULL, 1 },
  587. { AzoTlDelete, &TestLinkHandleP, L"Object 5", NULL, NO_ERROR, NULL, NULL, 1 },
  588. { AzoTlDelete, &TestLinkHandleP, L"Object 3", NULL, NO_ERROR, NULL, NULL, 1 },
  589. { AzoTlDelete, &TestLinkHandleP, L"Object 6", NULL, NO_ERROR, NULL, NULL, 1 },
  590. { AzoEndOfList }
  591. };
  592. //
  593. // Generic test of the ability of an object to link to a sid
  594. // AzoTestLink is the only opcode that can link to this subroutine of commands
  595. //
  596. OPERATION OpTestSid[] = {
  597. { AzoEcho, NULL, L"Add and remove several links to sids" },
  598. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid2, NULL, NO_ERROR, NULL, NULL, 1 },
  599. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid2Array, 1 },
  600. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid3, NULL, NO_ERROR, NULL, NULL, 1 },
  601. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid23Array, 1 },
  602. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid1, NULL, NO_ERROR, NULL, NULL, 1 },
  603. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid123Array, 1 },
  604. { AzoRemProp, &TestLinkHandleA, (LPWSTR)&Sid1, NULL, NO_ERROR, NULL, NULL, 1 },
  605. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid23Array, 1 },
  606. { AzoRemProp, &TestLinkHandleA, (LPWSTR)&Sid2, NULL, NO_ERROR, NULL, NULL, 1 },
  607. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid3Array, 1 },
  608. { AzoEcho, NULL, L"Add a link that already exists" },
  609. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid3, NULL, ERROR_ALREADY_EXISTS, NULL, NULL, 1 },
  610. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid3Array, 1 },
  611. { AzoRemProp, &TestLinkHandleA, (LPWSTR)&Sid3, NULL, NO_ERROR, NULL, NULL, 1 },
  612. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, 1 },
  613. { AzoEcho, NULL, L"Try more than 4 since reference buckets come in multiples of 4" },
  614. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid1, NULL, NO_ERROR, NULL, NULL, 1 },
  615. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid4, NULL, NO_ERROR, NULL, NULL, 1 },
  616. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid2, NULL, NO_ERROR, NULL, NULL, 1 },
  617. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid5, NULL, NO_ERROR, NULL, NULL, 1 },
  618. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid3, NULL, NO_ERROR, NULL, NULL, 1 },
  619. { AzoAddProp, &TestLinkHandleA, (LPWSTR)&Sid6, NULL, NO_ERROR, NULL, NULL, 1 },
  620. { AzoGetProp, &TestLinkHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid123456Array, 1 },
  621. { AzoEndOfList }
  622. };
  623. //
  624. // Specific tests for Task objects
  625. //
  626. //
  627. // Task object tests that are agnostic about the parent object
  628. // Requires GenParentHandle1 to already be set
  629. //
  630. OPERATION OpGenTask[] = {
  631. { AzoEcho, NULL, L"Task object specific tests" },
  632. { AzoTaskCreate, &GenParentHandle1, L"Task 1", &TaskHandle1, NO_ERROR },
  633. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE },
  634. { AzoEcho, NULL, L"Set the bizrule before the langauge" },
  635. { AzoSetProp, &TaskHandle1, L"While True\nWend", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  636. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE },
  637. { AzoEcho, NULL, L"Try an invalid language" },
  638. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  639. { AzoSetProp, &TaskHandle1, L"LANG1", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  640. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  641. { AzoEcho, NULL, L"Try the valid languages" },
  642. { AzoSetProp, &TaskHandle1, L"Jscript", NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  643. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"Jscript", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  644. { AzoSetProp, &TaskHandle1, L"VBScript", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  645. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"VBScript", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  646. { AzoEcho, NULL, L"Set a syntactically invalid bizrule" },
  647. { AzoSetProp, &TaskHandle1, L"Rule1,", NULL, OLESCRIPT_E_SYNTAX, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  648. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE },
  649. { AzoEcho, NULL, L"Set a syntactically valid bizrule" },
  650. { AzoSetProp, &TaskHandle1, L"While True\nWend", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  651. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"While True\nWend", AZ_PROP_TASK_BIZRULE },
  652. { AzoEcho, NULL, L"Try bizrule path" },
  653. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE_IMPORTED_PATH },
  654. { AzoSetProp, &TaskHandle1, L"c:\\temp", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_IMPORTED_PATH },
  655. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"c:\\temp", AZ_PROP_TASK_BIZRULE_IMPORTED_PATH },
  656. { AzoEcho, NULL, L"Try Task application data" },
  657. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_APPLICATION_DATA },
  658. { AzoSetProp, &TaskHandle1, L"Task Application Data", NULL, NO_ERROR, NULL, NULL, AZ_PROP_APPLICATION_DATA },
  659. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"Task Application Data", AZ_PROP_APPLICATION_DATA },
  660. { AzoTestLink, &GenParentHandle1, (LPWSTR)"Task", &TaskHandle1, AzoTask, OpTestLink, L"Task 1", AZ_PROP_TASK_TASKS },
  661. { AzoEcho, NULL, L"Reference ourself" },
  662. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, AZ_PROP_TASK_TASKS },
  663. { AzoAddProp, &TaskHandle1, L"Task 1", NULL, ERROR_DS_LOOP_DETECT, NULL, NULL, AZ_PROP_TASK_TASKS },
  664. { AzoEcho, NULL, L"Test loops" },
  665. { AzoTaskCreate, &GenParentHandle1, L"Task 2", &TaskHandle2, NO_ERROR },
  666. { AzoAddProp, &TaskHandle1, L"Task 2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_TASKS },
  667. { AzoAddProp, &TaskHandle2, L"Task 1", NULL, ERROR_DS_LOOP_DETECT, NULL, NULL, AZ_PROP_TASK_TASKS },
  668. { AzoRemProp, &TaskHandle1, L"Task 2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_TASKS },
  669. { AzoClose, &TaskHandle2, NULL, NULL, NO_ERROR },
  670. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  671. { AzoEndOfList }
  672. };
  673. OPERATION OpAppTask[] = {
  674. { AzoEcho, NULL, L"Task object specific tests" },
  675. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  676. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  677. // Do a bunch of stuff not specific to application children
  678. { AzoDupHandle, &AppHandle1, NULL, &GenParentHandle1,NO_ERROR },
  679. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGenTask },
  680. { AzoEcho, NULL, L"Test linking task to operations." },
  681. { AzoTaskCreate, &AppHandle1, L"Task Y", &TaskHandle1, NO_ERROR },
  682. { AzoTestLink, &AppHandle1, (LPWSTR)"Operation", &TaskHandle1, AzoOp, OpTestLink, L"Task Y", AZ_PROP_TASK_OPERATIONS },
  683. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  684. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  685. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  686. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  687. { AzoEndOfList }
  688. };
  689. // Tests for Tasks that are children of a scope
  690. OPERATION OpScopeTask[] = {
  691. { AzoEcho, NULL, L"Task objects that are children of a scope" },
  692. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  693. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  694. { AzoScopeCreate, &AppHandle1, L"Scope 1", &ScopeHandle1, NO_ERROR },
  695. // Do a bunch of stuff not specific to scope children
  696. { AzoDupHandle, &ScopeHandle1, NULL, &GenParentHandle1,NO_ERROR },
  697. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGenTask },
  698. { AzoEcho, NULL, L"Test linking task to operations." },
  699. { AzoTaskCreate, &ScopeHandle1, L"Task X", &TaskHandle1, NO_ERROR },
  700. { AzoTestLink, &AppHandle1, (LPWSTR)"Operation", &TaskHandle1, AzoOp, OpTestLink, L"Task X", AZ_PROP_TASK_OPERATIONS },
  701. { AzoEcho, NULL, L"Test linking scope task to app tasks." },
  702. { AzoTestLink, &AppHandle1, (LPWSTR)"Task", &TaskHandle1, AzoTask, OpTestLink, L"Task X", AZ_PROP_TASK_TASKS },
  703. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  704. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  705. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  706. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  707. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  708. { AzoEndOfList }
  709. };
  710. //
  711. // Specific tests for Group objects
  712. //
  713. //
  714. // Group object tests that are agnostic about the parent object
  715. // Requires GenParentHandle1 to already be set
  716. //
  717. OPERATION OpGenGroup[] = {
  718. { AzoEcho, NULL, L"Group object specific tests" },
  719. { AzoGroupCreate, &GenParentHandle1, L"Group A", &GroupHandleA, NO_ERROR },
  720. { AzoGroupCreate, &GenParentHandle1, L"Group B", &GroupHandleB, NO_ERROR },
  721. { AzoEcho, NULL, L"Create some groups to link the group to" },
  722. { AzoGroupCreate, &GenParentHandle1, L"Group 1", &GroupHandle1, NO_ERROR },
  723. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  724. { AzoGroupCreate, &GenParentHandle1, L"Group 2", &GroupHandle1, NO_ERROR },
  725. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  726. { AzoGroupCreate, &GenParentHandle1, L"Group 3", &GroupHandle1, NO_ERROR },
  727. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  728. { AzoEcho, NULL, L"Set group type to an invalid value" },
  729. { AzoSetProp, &GroupHandleA, (LPWSTR)&Eight,NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_TYPE },
  730. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  731. { AzoEcho, NULL, L"Reference ourself" },
  732. { AzoGetProp, &GroupHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, AZ_PROP_GROUP_APP_MEMBERS },
  733. { AzoGetProp, &GroupHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, AZ_PROP_GROUP_MEMBERS },
  734. { AzoAddProp, &GroupHandleA, L"Group A", NULL, ERROR_DS_LOOP_DETECT, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  735. { AzoTestLink, &GenParentHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_MEMBERS },
  736. { AzoTestLink, &GenParentHandle1, (LPWSTR)"Sid", &GroupHandleA, AzoGroup, OpTestSid, L"Group A", AZ_PROP_GROUP_MEMBERS },
  737. { AzoEcho, NULL, L"Same as above, but for the non-members attribute" },
  738. { AzoGetProp, &GroupHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, AZ_PROP_GROUP_APP_NON_MEMBERS },
  739. { AzoGetProp, &GroupHandleA, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&EmptyStringArray, AZ_PROP_GROUP_NON_MEMBERS },
  740. { AzoAddProp, &GroupHandleA, L"Group A", NULL, ERROR_DS_LOOP_DETECT, NULL, NULL, AZ_PROP_GROUP_APP_NON_MEMBERS },
  741. { AzoTestLink, &GenParentHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_NON_MEMBERS },
  742. { AzoTestLink, &GenParentHandle1, (LPWSTR)"Sid", &GroupHandleA, AzoGroup, OpTestSid, L"Group A", AZ_PROP_GROUP_NON_MEMBERS },
  743. { AzoEcho, NULL, L"Set LdapQuery string on a basic group" },
  744. { AzoGetProp, &GroupHandleA, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_GROUP_LDAP_QUERY },
  745. { AzoSetProp, &GroupHandleA, L"TheQuery", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  746. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtLdap,NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_TYPE },
  747. { AzoSetProp, &GroupHandleA, L"TheQuery", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  748. { AzoGetProp, &GroupHandleA, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_GROUP_LDAP_QUERY },
  749. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  750. { AzoSetProp, &GroupHandleA, L"TheQuery", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  751. { AzoSetProp, &GroupHandleA, L"", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  752. { AzoEcho, NULL, L"Set LdapQuery string on an ldap query group" },
  753. { AzoGetProp, &GroupHandleB, NULL, NULL, NO_ERROR, NULL, L"", AZ_PROP_GROUP_LDAP_QUERY },
  754. { AzoSetProp, &GroupHandleB, L"TheQuery", NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  755. { AzoSetProp, &GroupHandleB, (LPWSTR)&GtLdap,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  756. { AzoSetProp, &GroupHandleB, L"TheQuery", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  757. { AzoGetProp, &GroupHandleB, NULL, NULL, NO_ERROR, NULL, L"TheQuery", AZ_PROP_GROUP_LDAP_QUERY },
  758. { AzoSetProp, &GroupHandleB, (LPWSTR)&GtBasic,NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_GROUP_TYPE },
  759. { AzoGetProp, &GroupHandleB, NULL, NULL, NO_ERROR, NULL, L"TheQuery", AZ_PROP_GROUP_LDAP_QUERY },
  760. { AzoSetProp, &GroupHandleB, L"", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  761. { AzoEcho, NULL, L"Test loops" },
  762. { AzoSetProp, &GroupHandleB, (LPWSTR)&GtBasic,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  763. { AzoAddProp, &GroupHandleA, L"Group B", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  764. { AzoAddProp, &GroupHandleB, L"Group A", NULL, ERROR_DS_LOOP_DETECT, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  765. { AzoAddProp, &GroupHandleA, L"Group B", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_NON_MEMBERS },
  766. { AzoAddProp, &GroupHandleB, L"Group A", NULL, ERROR_DS_LOOP_DETECT, NULL, NULL, AZ_PROP_GROUP_APP_NON_MEMBERS },
  767. { AzoRemProp, &GroupHandleA, L"Group B", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_NON_MEMBERS },
  768. { AzoRemProp, &GroupHandleA, L"Group B", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  769. { AzoClose, &GroupHandleB, NULL, NULL, NO_ERROR },
  770. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  771. { AzoEndOfList }
  772. };
  773. // Tests for groups that are children of an admin manager
  774. OPERATION OpAdmGroup[] = {
  775. { AzoEcho, NULL, L"Group objects that are children of an admin manager" },
  776. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  777. // Do a bunch of stuff not specific to admin manager children
  778. { AzoDupHandle, &AdminMgrHandle1, NULL, &GenParentHandle1,NO_ERROR },
  779. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGenGroup },
  780. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  781. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  782. { AzoEndOfList }
  783. };
  784. // Tests for groups that are children of an application
  785. OPERATION OpAppGroup[] = {
  786. { AzoEcho, NULL, L"Group objects that are children of an application" },
  787. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  788. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  789. // Do a bunch of stuff not specific to application children
  790. { AzoDupHandle, &AppHandle1, NULL, &GenParentHandle1,NO_ERROR },
  791. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGenGroup },
  792. { AzoEcho, NULL, L"Test linking to groups that are children of the same admin manager as this group." },
  793. { AzoGroupOpen, &AppHandle1, L"Group A", &GroupHandleA, NO_ERROR },
  794. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_MEMBERS },
  795. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_NON_MEMBERS },
  796. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  797. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  798. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  799. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  800. { AzoEndOfList }
  801. };
  802. // Tests for groups that are children of a scope
  803. OPERATION OpScopeGroup[] = {
  804. { AzoEcho, NULL, L"Group objects that are children of a scope" },
  805. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  806. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  807. { AzoScopeCreate, &AppHandle1, L"Scope 1", &ScopeHandle1, NO_ERROR },
  808. // Do a bunch of stuff not specific to scope children
  809. { AzoDupHandle, &ScopeHandle1, NULL, &GenParentHandle1,NO_ERROR },
  810. { AzoGoSub, NULL, NULL, NULL, NO_ERROR, OpGenGroup },
  811. { AzoEcho, NULL, L"Test linking to groups that are children of the same admin manager as this group." },
  812. { AzoGroupOpen, &ScopeHandle1, L"Group A", &GroupHandleA, NO_ERROR },
  813. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_MEMBERS },
  814. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_NON_MEMBERS },
  815. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  816. { AzoEcho, NULL, L"Test linking to groups that are children of the same application as this group." },
  817. { AzoGroupOpen, &ScopeHandle1, L"Group A", &GroupHandleA, NO_ERROR },
  818. { AzoTestLink, &AppHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_MEMBERS },
  819. { AzoTestLink, &AppHandle1, (LPWSTR)"Group", &GroupHandleA, AzoGroup, OpTestLink, L"Group A", AZ_PROP_GROUP_APP_NON_MEMBERS },
  820. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  821. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  822. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  823. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  824. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  825. { AzoEndOfList }
  826. };
  827. //
  828. // Specific tests for Role objects
  829. //
  830. // Tests for Roles that are children of an application
  831. OPERATION OpAppRole[] = {
  832. { AzoEcho, NULL, L"Role objects that are children of an application" },
  833. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  834. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  835. { AzoRoleCreate, &AppHandle1, L"Role A", &RoleHandleA, NO_ERROR },
  836. // Test linking roles to groups
  837. { AzoEcho, NULL, L"Test linking to groups that are children of the same admin manager as the role object." },
  838. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Group", &RoleHandleA, AzoGroup, OpTestLink, L"Role A", AZ_PROP_ROLE_APP_MEMBERS },
  839. { AzoEcho, NULL, L"Test linking to groups that are children of the same application as the role object." },
  840. { AzoTestLink, &AppHandle1, (LPWSTR)"Group", &RoleHandleA, AzoGroup, OpTestLink, L"Role A", AZ_PROP_ROLE_APP_MEMBERS },
  841. { AzoEcho, NULL, L"Test linking to SIDs." },
  842. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Sid", &RoleHandleA, AzoGroup, OpTestSid, L"Role A", AZ_PROP_ROLE_MEMBERS },
  843. // Test linking roles to operations
  844. { AzoTestLink, &AppHandle1, (LPWSTR)"Operation", &RoleHandleA, AzoOp, OpTestLink, L"Role A", AZ_PROP_ROLE_OPERATIONS },
  845. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  846. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  847. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  848. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  849. { AzoEndOfList }
  850. };
  851. // Tests for Roles that are children of an scope
  852. OPERATION OpScopeRole[] = {
  853. { AzoEcho, NULL, L"Role objects that are children of a scope" },
  854. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  855. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  856. { AzoScopeCreate, &AppHandle1, L"Scope 1", &ScopeHandle1, NO_ERROR },
  857. { AzoRoleCreate, &ScopeHandle1, L"Role A", &RoleHandleA, NO_ERROR },
  858. // Test linking roles to groups
  859. { AzoEcho, NULL, L"Test linking to groups that are children of the same scope object as the role object." },
  860. { AzoTestLink, &ScopeHandle1, (LPWSTR)"Group", &RoleHandleA, AzoGroup, OpTestLink, L"Role A", AZ_PROP_ROLE_APP_MEMBERS },
  861. { AzoEcho, NULL, L"Test linking to groups that are children of the same application as the role object." },
  862. { AzoTestLink, &AppHandle1, (LPWSTR)"Group", &RoleHandleA, AzoGroup, OpTestLink, L"Role A", AZ_PROP_ROLE_APP_MEMBERS },
  863. { AzoEcho, NULL, L"Test linking to SIDs." },
  864. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Sid", &RoleHandleA, AzoGroup, OpTestSid, L"Role A", AZ_PROP_ROLE_MEMBERS },
  865. { AzoEcho, NULL, L"Test linking to groups that are children of the same admin manager as the role object." },
  866. { AzoTestLink, &AdminMgrHandle1, (LPWSTR)"Group", &RoleHandleA, AzoGroup, OpTestLink, L"Role A", AZ_PROP_ROLE_APP_MEMBERS },
  867. // Test linking roles to operations
  868. { AzoTestLink, &AppHandle1, (LPWSTR)"Operation", &RoleHandleA, AzoOp, OpTestLink, L"Role A", AZ_PROP_ROLE_OPERATIONS },
  869. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  870. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  871. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  872. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  873. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  874. { AzoEndOfList }
  875. };
  876. //
  877. // Ensure certain objects can't share names
  878. //
  879. OPERATION OpShare[] = {
  880. { AzoEcho, NULL, L"Certain objects can't share names" },
  881. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  882. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  883. { AzoAppCreate, &AdminMgrHandle1, L"MyApp2", &AppHandle2, NO_ERROR },
  884. { AzoScopeCreate, &AppHandle1, L"Scope 1", &ScopeHandle1, NO_ERROR },
  885. { AzoScopeCreate, &AppHandle1, L"Scope 2", &ScopeHandle2, NO_ERROR },
  886. { AzoEcho, NULL, L"Create some tasks and ops as a starting point" },
  887. { AzoTaskCreate, &AppHandle1, L"Task 1", &TaskHandle1, NO_ERROR },
  888. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  889. { AzoOpCreate, &AppHandle1, L"Op 1", &OpHandle1, NO_ERROR },
  890. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  891. { AzoEcho, NULL, L"Task and operations can't share names" },
  892. { AzoTaskCreate, &AppHandle1, L"Op 1", &TaskHandle1, ERROR_ALREADY_EXISTS },
  893. { AzoOpCreate, &AppHandle1, L"Task 1", &OpHandle1, ERROR_ALREADY_EXISTS },
  894. { AzoEcho, NULL, L"... Even via rename" },
  895. { AzoOpCreate, &AppHandle1, L"Op 2", &OpHandle1, NO_ERROR },
  896. { AzoSetProp, &OpHandle1, L"Task 1", NULL, ERROR_ALREADY_EXISTS, NULL, NULL, AZ_PROP_NAME },
  897. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  898. { AzoEcho, NULL, L"Create a task as a starting point" },
  899. { AzoTaskCreate, &AppHandle1, L"Task App", &TaskHandle1, NO_ERROR },
  900. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  901. { AzoTaskCreate, &ScopeHandle1, L"Task Scp", &TaskHandle2, NO_ERROR },
  902. { AzoClose, &TaskHandle2, NULL, NULL, NO_ERROR },
  903. { AzoEcho, NULL, L"Ensure scope and app task names conflict" },
  904. { AzoTaskCreate, &AppHandle1, L"Task Scp", &TaskHandle1, ERROR_ALREADY_EXISTS },
  905. { AzoTaskCreate, &ScopeHandle1, L"Task App", &TaskHandle1, ERROR_ALREADY_EXISTS },
  906. { AzoEcho, NULL, L"Ensure task names in different scopes don't conflict" },
  907. { AzoTaskCreate, &ScopeHandle2, L"Task Scp", &TaskHandle1, NO_ERROR },
  908. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  909. { AzoEcho, NULL, L"Scope Tasks and operations can't share names" },
  910. { AzoTaskCreate, &ScopeHandle1, L"Op 1", &TaskHandle1, ERROR_ALREADY_EXISTS },
  911. { AzoOpCreate, &AppHandle1, L"Task Scp", &OpHandle1, ERROR_ALREADY_EXISTS },
  912. { AzoEcho, NULL, L"Create some groups as a starting point" },
  913. { AzoGroupCreate, &AdminMgrHandle1, L"Group Adm",&GroupHandle1, NO_ERROR },
  914. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  915. { AzoGroupCreate, &AppHandle1, L"Group App",&GroupHandle1, NO_ERROR },
  916. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  917. { AzoGroupCreate, &AppHandle2, L"Group App2",&GroupHandle2, NO_ERROR },
  918. { AzoClose, &GroupHandle2, NULL, NULL, NO_ERROR },
  919. { AzoEcho, NULL, L"Create an app group that conflicts with an adm group, etc" },
  920. { AzoGroupCreate, &AppHandle1, L"Group Adm",&GroupHandleA, ERROR_ALREADY_EXISTS },
  921. { AzoGroupCreate, &AdminMgrHandle1, L"Group App",&GroupHandleA, ERROR_ALREADY_EXISTS },
  922. { AzoEcho, NULL, L"Ensure two apps can have a group by the same name" },
  923. { AzoGroupCreate, &AppHandle2, L"Group App",&GroupHandleA, NO_ERROR },
  924. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  925. { AzoEcho, NULL, L"Create a scope group" },
  926. { AzoGroupCreate, &ScopeHandle1, L"Group Scp",&GroupHandle1, NO_ERROR },
  927. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  928. { AzoEcho, NULL, L"Create a scope group that conflicts with an adm group, etc" },
  929. { AzoGroupCreate, &ScopeHandle1, L"Group Adm",&GroupHandleA, ERROR_ALREADY_EXISTS },
  930. { AzoGroupCreate, &ScopeHandle1, L"Group App",&GroupHandleA, ERROR_ALREADY_EXISTS },
  931. { AzoEcho, NULL, L"Create an app/adm group that conflicts with a scope group" },
  932. { AzoGroupCreate, &AppHandle1, L"Group Scp",&GroupHandleA, ERROR_ALREADY_EXISTS },
  933. { AzoGroupCreate, &AdminMgrHandle1, L"Group Scp",&GroupHandleA, ERROR_ALREADY_EXISTS },
  934. { AzoEcho, NULL, L"Ensure two scopes can have a group by the same name" },
  935. { AzoGroupCreate, &ScopeHandle2, L"Group Scp",&GroupHandle2, NO_ERROR },
  936. { AzoClose, &GroupHandle2, NULL, NULL, NO_ERROR },
  937. { AzoEcho, NULL, L"Create a role as a starting point" },
  938. { AzoRoleCreate, &AppHandle1, L"Role App", &RoleHandle1, NO_ERROR },
  939. { AzoClose, &RoleHandle1, NULL, NULL, NO_ERROR },
  940. { AzoRoleCreate, &ScopeHandle1, L"Role Scp", &RoleHandle2, NO_ERROR },
  941. { AzoClose, &RoleHandle2, NULL, NULL, NO_ERROR },
  942. { AzoEcho, NULL, L"Ensure scope and app role names conflict" },
  943. { AzoRoleCreate, &AppHandle1, L"Role Scp", &RoleHandle1, ERROR_ALREADY_EXISTS },
  944. { AzoRoleCreate, &ScopeHandle1, L"Role App", &RoleHandle1, ERROR_ALREADY_EXISTS },
  945. { AzoEcho, NULL, L"Ensure role names in different scopes don't conflict" },
  946. { AzoRoleCreate, &ScopeHandle2, L"Role Scp", &RoleHandle1, NO_ERROR },
  947. { AzoClose, &RoleHandle1, NULL, NULL, NO_ERROR },
  948. { AzoClose, &ScopeHandle2, NULL, NULL, NO_ERROR },
  949. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  950. { AzoClose, &AppHandle2, NULL, NULL, NO_ERROR },
  951. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  952. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  953. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  954. { AzoEndOfList }
  955. };
  956. //
  957. // Ensure peristence works
  958. //
  959. // App object enum
  960. OPERATION OpAppEnum[] = {
  961. { AzoGetProp, &GenHandleE, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  962. { AzoClose, &GenHandleE, NULL, NULL, NO_ERROR },
  963. { AzoEndOfList }
  964. };
  965. // Task object enum
  966. OPERATION OpTaskEnum[] = {
  967. { AzoGetProp, &GenHandleE, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  968. { AzoClose, &GenHandleE, NULL, NULL, NO_ERROR },
  969. { AzoEndOfList }
  970. };
  971. // Operation object enum
  972. OPERATION OpOpEnum[] = {
  973. { AzoGetProp, &GenHandleE, NULL, NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  974. { AzoClose, &GenHandleE, NULL, NULL, NO_ERROR },
  975. { AzoEndOfList }
  976. };
  977. OPERATION OpPersist[] = {
  978. { AzoEcho, NULL, L"Ensure objects persist across a close" },
  979. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  980. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  981. { AzoTaskCreate, &AppHandle1, L"Task 1", &TaskHandle1, NO_ERROR },
  982. { AzoOpCreate, &AppHandle1, L"Op 1", &OpHandle1, NO_ERROR },
  983. { AzoAddProp, &TaskHandle1, L"Op 1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  984. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Op1, AZ_PROP_TASK_OPERATIONS },
  985. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  986. { AzoSetProp, &TaskHandle1, L"Jscript", NULL, NO_ERROR, NULL, L"", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  987. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"Jscript", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  988. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  989. { AzoGroupCreate, &AppHandle1, L"Group 1", &GroupHandle1, NO_ERROR },
  990. { AzoAddProp, &GroupHandle1, (LPWSTR)&Sid2,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_MEMBERS },
  991. { AzoGetProp, &GroupHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid2Array, AZ_PROP_GROUP_MEMBERS },
  992. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  993. { AzoEcho, NULL, L"Abort an object creation and an attribute change" },
  994. { AzoOpCreate|AzoAbort, &AppHandle1, L"Op 2", &OpHandle1, NO_ERROR },
  995. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  996. { AzoOpOpen, &AppHandle1, L"Op 2", &OpHandle1, ERROR_NOT_FOUND },
  997. { AzoOpOpen, &AppHandle1, L"Op 1", &OpHandle1, NO_ERROR },
  998. { AzoSetProp|AzoAbort, &OpHandle1, (LPWSTR)&Eight, NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  999. { AzoGetProp, &OpHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Zero, AZ_PROP_OPERATION_ID },
  1000. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1001. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1002. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1003. { AzoEcho, NULL, L"See if they're still there" },
  1004. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, 0 },
  1005. { AzoAppEnum, &AdminMgrHandle1, NULL, &GenHandleE, NO_ERROR, OpAppEnum },
  1006. { AzoAppOpen, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  1007. { AzoTaskEnum, &AppHandle1, NULL, &GenHandleE, NO_ERROR, OpTaskEnum },
  1008. { AzoTaskOpen, &AppHandle1, L"Task 1", &TaskHandle1, NO_ERROR },
  1009. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Op1, AZ_PROP_TASK_OPERATIONS },
  1010. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, L"Jscript", AZ_PROP_TASK_BIZRULE_LANGUAGE },
  1011. { AzoOpEnum, &AppHandle1, NULL, &GenHandleE, NO_ERROR, OpOpEnum },
  1012. { AzoOpOpen, &AppHandle1, L"Op 1", &OpHandle1, NO_ERROR },
  1013. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1014. { AzoOpOpen, &AppHandle1, L"Op 2", &OpHandle1, ERROR_NOT_FOUND },
  1015. { AzoGroupOpen, &AppHandle1, L"Group 1", &GroupHandle1, NO_ERROR },
  1016. { AzoGetProp, &GroupHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Sid2Array, AZ_PROP_GROUP_MEMBERS },
  1017. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  1018. { AzoEcho, NULL, L"Complain if we try to create a child of non-sumbitted parent" },
  1019. { AzoAppCreate|AzoNoSubmit, &AdminMgrHandle1, L"MyApp2", &AppHandle2, NO_ERROR },
  1020. { AzoTaskCreate, &AppHandle2, L"Task 1", &TaskHandle2, ERROR_DS_NO_PARENT_OBJECT },
  1021. { AzoEcho, NULL, L"Complain if we try to link to a non-sumbitted object" },
  1022. { AzoOpCreate|AzoNoSubmit,&AppHandle1, L"Op 3", &OpHandle1, NO_ERROR },
  1023. { AzoAddProp, &TaskHandle1, L"Op 3", NULL, ERROR_NOT_FOUND, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1024. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1025. { AzoClose, &AppHandle2, NULL, NULL, NO_ERROR },
  1026. { AzoEcho, NULL, L"Ensure links are re-ordered upon rename" },
  1027. { AzoOpCreate, &AppHandle1, L"Op 2", &OpHandle1, NO_ERROR },
  1028. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1029. { AzoAddProp, &TaskHandle1, L"Op 2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1030. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Op12, AZ_PROP_TASK_OPERATIONS },
  1031. { AzoOpOpen, &AppHandle1, L"Op 1", &OpHandle1, NO_ERROR },
  1032. { AzoSetProp, &OpHandle1, L"Op 4", NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  1033. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1034. { AzoGetProp, &TaskHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&Op24, AZ_PROP_TASK_OPERATIONS },
  1035. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1036. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1037. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1038. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1039. { AzoEcho, NULL, L"Ensure the an empty admin manager is persisted" },
  1040. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  1041. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1042. { AzoInit|AzoNoSubmit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, 0 },
  1043. { AzoEcho, NULL, L"Ensure a restored admin manager is writable" },
  1044. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&AzGlTrue, AZ_PROP_WRITABLE },
  1045. { AzoEcho, NULL, L"Ensure we can create an application in the empty restored admin manager" },
  1046. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  1047. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1048. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1049. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1050. { AzoEcho, NULL, L"Ensure changes to admin manager are reflected in store" },
  1051. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  1052. { AzoSetProp, &AdminMgrHandle1, L"Desc", NULL, NO_ERROR, NULL, NULL, AZ_PROP_DESCRIPTION },
  1053. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, L"Desc", AZ_PROP_DESCRIPTION },
  1054. { AzoInit, NULL, NULL, &AdminMgrHandle2, NO_ERROR, NULL, NULL, 0 },
  1055. { AzoGetProp, &AdminMgrHandle2, NULL, NULL, NO_ERROR, NULL, L"Desc", AZ_PROP_DESCRIPTION },
  1056. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1057. { AzoAdmDelete, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1058. { AzoClose, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1059. { AzoEcho, NULL, L"Ensure renames are reflected in updated caches" },
  1060. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  1061. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  1062. { AzoInit, NULL, NULL, &AdminMgrHandle2, NO_ERROR, NULL, NULL, 0 },
  1063. { AzoSetProp, &AppHandle1, L"NewApp", NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  1064. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, L"NewApp", AZ_PROP_NAME },
  1065. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1066. { AzoUpdateCache, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1067. { AzoEcho, NULL, L"Ensure an updated admin manager is writable" },
  1068. { AzoGetProp, &AdminMgrHandle2, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&AzGlTrue, AZ_PROP_WRITABLE },
  1069. { AzoAppOpen, &AdminMgrHandle2, L"MyApp", &AppHandle1, ERROR_NOT_FOUND },
  1070. { AzoAppOpen, &AdminMgrHandle2, L"NewApp", &AppHandle1, NO_ERROR },
  1071. { AzoEcho, NULL, L"Ensure a updated app is writable" },
  1072. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&AzGlTrue, AZ_PROP_WRITABLE },
  1073. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1074. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1075. { AzoAdmDelete, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1076. { AzoClose, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1077. { AzoEcho, NULL, L"Ensure that's true even on name conflict" },
  1078. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  1079. { AzoAppCreate, &AdminMgrHandle1, L"App 1", &AppHandle1, NO_ERROR },
  1080. { AzoAppCreate, &AdminMgrHandle1, L"App 2", &AppHandle2, NO_ERROR },
  1081. { AzoClose, &AppHandle2, NULL, NULL, NO_ERROR },
  1082. { AzoInit, NULL, NULL, &AdminMgrHandle2, NO_ERROR, NULL, NULL, 0 },
  1083. { AzoAppDelete, &AdminMgrHandle1, L"App 2", &AppHandle1, NO_ERROR },
  1084. { AzoSetProp, &AppHandle1, L"App 2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_NAME },
  1085. { AzoGetProp, &AppHandle1, NULL, NULL, NO_ERROR, NULL, L"App 2", AZ_PROP_NAME },
  1086. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1087. { AzoUpdateCache, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1088. { AzoAppEnum, &AdminMgrHandle2, NULL, &GenHandleE, NO_ERROR, OpAppEnum },
  1089. { AzoAppOpen, &AdminMgrHandle2, L"App 2", &AppHandle1, NO_ERROR },
  1090. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1091. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1092. { AzoAdmDelete, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1093. { AzoClose, &AdminMgrHandle2, NULL, NULL, NO_ERROR },
  1094. { AzoEndOfList }
  1095. };
  1096. //
  1097. // Perform access check tests
  1098. //
  1099. #define OP1_NUM 61
  1100. ULONG Op1Num = OP1_NUM;
  1101. #define OP2_NUM 62
  1102. ULONG Op2Num = OP2_NUM;
  1103. #define OP3_NUM 63
  1104. ULONG Op3Num = OP3_NUM;
  1105. #define OP4_NUM 64
  1106. ULONG Op4Num = OP4_NUM;
  1107. ULONG Ops1[] = { OP1_NUM };
  1108. ULONG Ops2[] = { OP2_NUM };
  1109. ULONG Ops3[] = { OP3_NUM };
  1110. ULONG Ops4[] = { OP4_NUM };
  1111. ULONG Ops1234[] = { OP1_NUM, OP2_NUM, OP3_NUM, OP4_NUM };
  1112. ULONG OpsInvalid[] = { 8 };
  1113. ULONG ResS[] = { NO_ERROR };
  1114. ULONG ResF[] = { ERROR_ACCESS_DENIED };
  1115. ULONG ResN[] = { 0xFFFFFFFF };
  1116. ULONG ResSSSS[] = { NO_ERROR, NO_ERROR, NO_ERROR, NO_ERROR };
  1117. ULONG ResFFFF[] = { ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED };
  1118. ULONG ResFSSS[] = { ERROR_ACCESS_DENIED, NO_ERROR, NO_ERROR, NO_ERROR };
  1119. ULONG ResSSFF[] = { NO_ERROR, NO_ERROR, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED };
  1120. OPERATION OpAccess[] = {
  1121. { AzoEcho, NULL, L"Create a complete policy data to perform access checks against" },
  1122. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  1123. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  1124. { AzoEcho, NULL, L"Create some operations" },
  1125. { AzoOpCreate, &AppHandle1, L"Op1", &OpHandle1, NO_ERROR },
  1126. { AzoSetProp, &OpHandle1, (LPWSTR)&Op1Num,NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  1127. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1128. { AzoOpCreate, &AppHandle1, L"Op2", &OpHandle1, NO_ERROR },
  1129. { AzoSetProp, &OpHandle1, (LPWSTR)&Op2Num,NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  1130. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1131. { AzoOpCreate, &AppHandle1, L"Op3", &OpHandle1, NO_ERROR },
  1132. { AzoSetProp, &OpHandle1, (LPWSTR)&Op3Num,NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  1133. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1134. { AzoOpCreate, &AppHandle1, L"Op4", &OpHandle1, NO_ERROR },
  1135. { AzoSetProp, &OpHandle1, (LPWSTR)&Op4Num,NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  1136. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1137. { AzoEcho, NULL, L"Create some tasks" },
  1138. { AzoTaskCreate, &AppHandle1, L"TaskOp1", &TaskHandle1, NO_ERROR },
  1139. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1140. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1141. { AzoTaskCreate, &AppHandle1, L"TaskOp1Op2",&TaskHandle1, NO_ERROR },
  1142. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1143. { AzoAddProp, &TaskHandle1, L"Op2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1144. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1145. { AzoTaskCreate, &AppHandle1, L"TaskOp1WithEmptyBizRule", &TaskHandle1, NO_ERROR },
  1146. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1147. { AzoSetProp, &TaskHandle1, L"VBScript", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  1148. { AzoSetProp, &TaskHandle1, L" ", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  1149. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1150. { AzoTaskCreate, &AppHandle1, L"TaskOp1WithTrivialBizRule", &TaskHandle1, NO_ERROR },
  1151. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1152. { AzoSetProp, &TaskHandle1, L"VBScript", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  1153. { AzoSetProp, &TaskHandle1, L"AccessCheck.BusinessRuleResult = TRUE", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  1154. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1155. { AzoEcho, NULL, L"Create some groups with NT membership" },
  1156. { AzoGroupCreate, &AppHandle1, L"GroupWorld", &GroupHandleA, NO_ERROR },
  1157. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1158. { AzoAddProp, &GroupHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_MEMBERS },
  1159. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1160. { AzoGroupCreate, &AppHandle1, L"GroupNotAMember",&GroupHandleA, NO_ERROR },
  1161. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1162. { AzoAddProp, &GroupHandleA, (LPWSTR)&Sid1, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_MEMBERS },
  1163. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1164. { AzoEcho, NULL, L"Create a group using app group membership" },
  1165. { AzoGroupCreate, &AppHandle1, L"GroupAppMember",&GroupHandleA, NO_ERROR },
  1166. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1167. { AzoAddProp, &GroupHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1168. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1169. { AzoEcho, NULL, L"Create a group using app group non membership - but still member" },
  1170. { AzoGroupCreate, &AppHandle1, L"GroupAppNonMember",&GroupHandleA, NO_ERROR },
  1171. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1172. { AzoAddProp, &GroupHandleA, L"GroupAppMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1173. { AzoAddProp, &GroupHandleA, L"GroupNotAMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_NON_MEMBERS },
  1174. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1175. { AzoEcho, NULL, L"Create a group using app group non membership - but not member" },
  1176. { AzoGroupCreate, &AppHandle1, L"GroupAppReallyNonMember",&GroupHandleA, NO_ERROR },
  1177. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1178. { AzoAddProp, &GroupHandleA, L"GroupAppMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1179. { AzoAddProp, &GroupHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_NON_MEMBERS },
  1180. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1181. { AzoEcho, NULL, L"Create some LdapQuery groups" },
  1182. { AzoGroupCreate, &AppHandle1, L"GroupLdapYes", &GroupHandleA, NO_ERROR },
  1183. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtLdap, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1184. #ifdef ENABLE_CLIFFV_ACCOUNT
  1185. { AzoSetProp, &GroupHandleA, L"(userAccountControl=1049088)", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  1186. #endif // ENABLE_CLIFFV_ACCOUNT
  1187. #ifdef ENABLE_ADMIN_ACCOUNT
  1188. { AzoSetProp, &GroupHandleA, L"(userAccountControl=66048)", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  1189. #endif // ENABLE_ADMIN_ACCOUNT
  1190. #ifdef ENABLE_CHAITU_ACCOUNT
  1191. { AzoSetProp, &GroupHandleA, L"(userAccountControl=512)", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  1192. #endif // ENABLE_CHAITU_ACCOUNT
  1193. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1194. { AzoGroupCreate, &AppHandle1, L"GroupLdapNo", &GroupHandleA, NO_ERROR },
  1195. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtLdap, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1196. { AzoSetProp, &GroupHandleA, L"(userAccountControl=1049089)", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  1197. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1198. { AzoEcho, NULL, L"Create some scopes" },
  1199. { AzoScopeCreate, &AppHandle1, L"MyScope", &ScopeHandle1, NO_ERROR },
  1200. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1201. { AzoScopeCreate, &AppHandle1, L"MyScope2",&ScopeHandle1, NO_ERROR },
  1202. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1203. { AzoScopeCreate, &AppHandle1, L"MyScope3",&ScopeHandle1, NO_ERROR },
  1204. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1205. { AzoScopeCreate, &AppHandle1, L"MyScope4",&ScopeHandle1, NO_ERROR },
  1206. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1207. { AzoScopeCreate, &AppHandle1, L"MyScope5",&ScopeHandle1, NO_ERROR },
  1208. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1209. { AzoScopeCreate, &AppHandle1, L"MyScope6",&ScopeHandle1, NO_ERROR },
  1210. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1211. { AzoScopeCreate, &AppHandle1, L"MyScope7",&ScopeHandle1, NO_ERROR },
  1212. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1213. { AzoScopeCreate, &AppHandle1, L"MyScope8",&ScopeHandle1, NO_ERROR },
  1214. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1215. { AzoScopeCreate, &AppHandle1, L"MyScope9",&ScopeHandle1, NO_ERROR },
  1216. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1217. { AzoScopeCreate, &AppHandle1, L"MyScopeQ1",&ScopeHandle1, NO_ERROR },
  1218. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1219. { AzoScopeCreate, &AppHandle1, L"MyScopeQ2",&ScopeHandle1, NO_ERROR },
  1220. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1221. { AzoScopeCreate, &AppHandle1, L"MyScopeNoRoles",&ScopeHandle1, NO_ERROR },
  1222. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1223. { AzoScopeCreate, &AppHandle1, L"MyScopeP1",&ScopeHandle1, NO_ERROR },
  1224. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1225. { AzoEcho, NULL, L"Build a context" },
  1226. { AzoInitCFT, &AppHandle1, (LPWSTR)&TokenHandle, &CCHandle, NO_ERROR },
  1227. { AzoEcho, NULL, L"Create a role granting op1 access to everyone SID" },
  1228. { AzoScopeOpen, &AppHandle1, L"MyScope", &ScopeHandle1, NO_ERROR },
  1229. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1", &RoleHandleA, NO_ERROR },
  1230. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1231. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1232. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1233. { AzoEcho, NULL, L"Check a SID on a role granting access" },
  1234. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1235. { AzoEcho, NULL, L"Create a role granting op2 access to GroupWorld" },
  1236. { AzoRoleCreate, &ScopeHandle1, L"RoleGroupWorldCanOp2", &RoleHandleA, NO_ERROR },
  1237. { AzoAddProp, &RoleHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1238. { AzoAddProp, &RoleHandleA, L"Op2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1239. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1240. { AzoEcho, NULL, L"Check a app group on a role granting access" },
  1241. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&Ops2, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1242. { AzoEcho, NULL, L"Ask again to check out app group caching" },
  1243. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&Ops2, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1244. { AzoEcho, NULL, L"Create a role not granting op3 access to GroupNotAMember" },
  1245. { AzoRoleCreate, &ScopeHandle1, L"RoleGroupCantOp3", &RoleHandleA, NO_ERROR },
  1246. { AzoAddProp, &RoleHandleA, L"GroupNotAMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1247. { AzoAddProp, &RoleHandleA, L"Op3", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1248. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1249. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1250. { AzoEcho, NULL, L"Check a app group on a role not granting access" },
  1251. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&Ops3, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1252. { AzoEcho, NULL, L"Check a scope with no roles" },
  1253. { AzoAccess, &CCHandle, L"MyScopeNoRoles", (PAZ_HANDLE)&Ops3, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1254. { AzoEcho, NULL, L"Check zero operations" },
  1255. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&Ops3, ERROR_INVALID_PARAMETER, NULL, (LPWSTR) &ResF, 0 },
  1256. { AzoEcho, NULL, L"Check an invalid scope name" },
  1257. { AzoAccess, &CCHandle, L"MyScopeNameInvalid", (PAZ_HANDLE)&Ops3, ERROR_SCOPE_NOT_FOUND, NULL, (LPWSTR) &ResF, 1 },
  1258. { AzoEcho, NULL, L"Check an invalid operation number" },
  1259. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&OpsInvalid, ERROR_INVALID_OPERATION, NULL, (LPWSTR) &ResN, 1 },
  1260. { AzoEcho, NULL, L"Create two roles that both grant access" },
  1261. { AzoScopeOpen, &AppHandle1, L"MyScope2", &ScopeHandle1, NO_ERROR },
  1262. { AzoRoleCreate, &ScopeHandle1, L"Role2GroupWorldCanOp2", &RoleHandleA, NO_ERROR },
  1263. { AzoAddProp, &RoleHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1264. { AzoAddProp, &RoleHandleA, L"Op2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1265. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1266. { AzoRoleCreate, &ScopeHandle1, L"Role2aGroupWorldCanOp2", &RoleHandleA, NO_ERROR },
  1267. { AzoAddProp, &RoleHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1268. { AzoAddProp, &RoleHandleA, L"Op2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1269. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1270. { AzoEcho, NULL, L"Check a app group with two roles granting access" },
  1271. { AzoAccess, &CCHandle, L"MyScope2", (PAZ_HANDLE)&Ops2, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1272. { AzoEcho, NULL, L"Create two roles with one granting and one not granting" },
  1273. { AzoRoleCreate, &ScopeHandle1, L"Role2GroupCantOp3", &RoleHandleA, NO_ERROR },
  1274. { AzoAddProp, &RoleHandleA, L"GroupNotAMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1275. { AzoAddProp, &RoleHandleA, L"Op3", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1276. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1277. { AzoRoleCreate, &ScopeHandle1, L"Role2GroupWorldCanOp3", &RoleHandleA, NO_ERROR },
  1278. { AzoAddProp, &RoleHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1279. { AzoAddProp, &RoleHandleA, L"Op3", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1280. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1281. { AzoEcho, NULL, L"Check a app group with one role granting and the other not" },
  1282. { AzoAccess, &CCHandle, L"MyScope2", (PAZ_HANDLE)&Ops3, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1283. { AzoEcho, NULL, L"... in the other order" },
  1284. { AzoRoleCreate, &ScopeHandle1, L"Role2GroupWorldCanOp4", &RoleHandleA, NO_ERROR },
  1285. { AzoAddProp, &RoleHandleA, L"GroupWorld", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1286. { AzoAddProp, &RoleHandleA, L"Op4", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1287. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1288. { AzoRoleCreate, &ScopeHandle1, L"Role2GroupCantOp4", &RoleHandleA, NO_ERROR },
  1289. { AzoAddProp, &RoleHandleA, L"GroupNotAMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1290. { AzoAddProp, &RoleHandleA, L"Op4", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1291. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1292. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1293. { AzoEcho, NULL, L"...In the other order" },
  1294. { AzoAccess, &CCHandle, L"MyScope2", (PAZ_HANDLE)&Ops4, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1295. { AzoEcho, NULL, L"Try multiple operations" },
  1296. { AzoAccess, &CCHandle, L"MyScope2", (PAZ_HANDLE)&Ops1234, NO_ERROR, NULL, (LPWSTR) &ResFSSS, 4 },
  1297. { AzoEcho, NULL, L"Create a role granting op1 access to AppGroup" },
  1298. { AzoScopeOpen, &AppHandle1, L"MyScope3", &ScopeHandle1, NO_ERROR },
  1299. { AzoRoleCreate, &ScopeHandle1, L"RoleAppGroupCanOp1", &RoleHandleA, NO_ERROR },
  1300. { AzoAddProp, &RoleHandleA, L"GroupAppMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1301. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1302. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1303. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1304. { AzoAccess, &CCHandle, L"MyScope3", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1305. { AzoEcho, NULL, L"Create a role granting op1 access to AppGroup with non member group" },
  1306. { AzoScopeOpen, &AppHandle1, L"MyScope4", &ScopeHandle1, NO_ERROR },
  1307. { AzoRoleCreate, &ScopeHandle1, L"Role2AppGroupCanOp1", &RoleHandleA,NO_ERROR },
  1308. { AzoAddProp, &RoleHandleA, L"GroupAppNonMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1309. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1310. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1311. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1312. { AzoAccess, &CCHandle, L"MyScope4", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1313. { AzoEcho, NULL, L"Create a role granting op1 access to AppGroup with non member group - really not member" },
  1314. { AzoScopeOpen, &AppHandle1, L"MyScope5", &ScopeHandle1, NO_ERROR },
  1315. { AzoRoleCreate, &ScopeHandle1, L"Role3AppGroupCanOp1", &RoleHandleA, NO_ERROR },
  1316. { AzoAddProp, &RoleHandleA, L"GroupAppReallyNonMember", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1317. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1318. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1319. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1320. { AzoAccess, &CCHandle, L"MyScope5", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1321. { AzoEcho, NULL, L"Create a role granting op1 access to everyone SID via a task" },
  1322. { AzoScopeOpen, &AppHandle1, L"MyScope6", &ScopeHandle1, NO_ERROR },
  1323. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1ViaTask1", &RoleHandleA, NO_ERROR },
  1324. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1325. { AzoAddProp, &RoleHandleA, L"TaskOp1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1326. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1327. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1328. { AzoEcho, NULL, L"Check granted access via a task" },
  1329. { AzoAccess, &CCHandle, L"MyScope6", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1330. { AzoEcho, NULL, L"Create a role granting op1 and op2 access to everyone SID via a task" },
  1331. { AzoScopeOpen, &AppHandle1, L"MyScope7", &ScopeHandle1, NO_ERROR },
  1332. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1Op2ViaTask1", &RoleHandleA, NO_ERROR },
  1333. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1334. { AzoAddProp, &RoleHandleA, L"TaskOp1Op2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1335. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1336. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1337. { AzoEcho, NULL, L"Check granted access to two ops via a task" },
  1338. { AzoAccess, &CCHandle, L"MyScope7", (PAZ_HANDLE)&Ops1234, NO_ERROR, NULL, (LPWSTR) &ResSSFF, 4 },
  1339. { AzoEcho, NULL, L"Create a role granting op1 access to an LDAP query group" },
  1340. { AzoScopeOpen, &AppHandle1, L"MyScopeQ1", &ScopeHandle1, NO_ERROR },
  1341. { AzoRoleCreate, &ScopeHandle1, L"RoleLdapCanOp1", &RoleHandleA, NO_ERROR },
  1342. { AzoAddProp, &RoleHandleA, L"GroupLdapYes", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1343. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1344. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1345. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1346. #ifdef ENABLE_DC_DOWN
  1347. { AzoEcho, NULL, L"Check LDAP query groups with the DC down" },
  1348. { AzoAccess, &CCHandle, L"MyScopeQ1", (PAZ_HANDLE)&Ops1, ERROR_NO_SUCH_DOMAIN, NULL, (LPWSTR) &ResF, 1 },
  1349. { AzoAccess, &CCHandle, L"MyScopeQ1", (PAZ_HANDLE)&Ops1, ERROR_NO_SUCH_DOMAIN, NULL, (LPWSTR) &ResF, 1 },
  1350. { AzoSleep, NULL, L"\n\nPlug the DC in now!!!", NULL, NO_ERROR, NULL, NULL, 30 },
  1351. #endif // ENABLE_DC_DOWN
  1352. { AzoEcho, NULL, L"Check granted access via LDAP query group" },
  1353. #ifdef ENABLE_NON_DS_ACCOUNT
  1354. { AzoAccess, &CCHandle, L"MyScopeQ1", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1355. #else // ENABLE_NON_DS_ACCOUNT
  1356. { AzoAccess, &CCHandle, L"MyScopeQ1", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1357. #endif // ENABLE_NON_DS_ACCOUNT
  1358. { AzoEcho, NULL, L"Try again to check the cache" },
  1359. #ifdef ENABLE_NON_DS_ACCOUNT
  1360. { AzoAccess, &CCHandle, L"MyScopeQ1", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1361. #else // ENABLE_NON_DS_ACCOUNT
  1362. { AzoAccess, &CCHandle, L"MyScopeQ1", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1363. #endif // ENABLE_NON_DS_ACCOUNT
  1364. { AzoEcho, NULL, L"Create a role granting op1 access to an LDAP query group" },
  1365. { AzoScopeOpen, &AppHandle1, L"MyScopeQ2", &ScopeHandle1, NO_ERROR },
  1366. { AzoRoleCreate, &ScopeHandle1, L"RoleLdapCannotOp1", &RoleHandleA, NO_ERROR },
  1367. { AzoAddProp, &RoleHandleA, L"GroupLdapNo", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1368. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1369. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1370. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1371. { AzoEcho, NULL, L"Check failed access via LDAP query group" },
  1372. { AzoAccess, &CCHandle, L"MyScopeQ2", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1373. // These tests have to be after the ENABLE_DC_DOWN tests
  1374. { AzoEcho, NULL, L"Test if all the query property opcodes work" },
  1375. #ifdef ENABLE_CLIFFV_ACCOUNT
  1376. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"CN=Cliff Van Dyke,OU=Users,OU=ITG,DC=ntdev,DC=microsoft,DC=com", AZ_PROP_CLIENT_CONTEXT_USER_DN },
  1377. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"NTDEV\\cliffv", AZ_PROP_CLIENT_CONTEXT_USER_SAM_COMPAT },
  1378. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"Cliff Van Dyke", AZ_PROP_CLIENT_CONTEXT_USER_DISPLAY },
  1379. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"{ebff0213-bec7-4c11-bd47-06c80df7f356}", AZ_PROP_CLIENT_CONTEXT_USER_GUID },
  1380. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"ntdev.microsoft.com/ITG/Users/Cliff Van Dyke", AZ_PROP_CLIENT_CONTEXT_USER_CANONICAL },
  1381. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"[email protected]", AZ_PROP_CLIENT_CONTEXT_USER_UPN },
  1382. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"NTDEV.MICROSOFT.COM\\cliffv", AZ_PROP_CLIENT_CONTEXT_USER_DNS_SAM_COMPAT },
  1383. #endif // ENABLE_CLIFFV_ACCOUNT
  1384. #ifdef ENABLE_CHAITU_ACCOUNT
  1385. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"CN=Chaitanya Upadhyay,OU=Users,OU=ITG,DC=ntdev,DC=microsoft,DC=com", AZ_PROP_CLIENT_CONTEXT_USER_DN },
  1386. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"NTDEV\\chaitu", AZ_PROP_CLIENT_CONTEXT_USER_SAM_COMPAT },
  1387. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"Chaitanya Upadhyay", AZ_PROP_CLIENT_CONTEXT_USER_DISPLAY },
  1388. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"{54bd4c43-861e-4b68-9e6c-0b8eec0b4847}", AZ_PROP_CLIENT_CONTEXT_USER_GUID },
  1389. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"ntdev.microsoft.com/ITG/Users/Chaitanya Upadhyay", AZ_PROP_CLIENT_CONTEXT_USER_CANONICAL },
  1390. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"[email protected]", AZ_PROP_CLIENT_CONTEXT_USER_UPN },
  1391. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"NTDEV.MICROSOFT.COM\\chaitu", AZ_PROP_CLIENT_CONTEXT_USER_DNS_SAM_COMPAT },
  1392. #endif // ENABLE_CHAITU_ACCOUNT
  1393. #ifdef ENABLE_NT4_ACCOUNT
  1394. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NO_SUCH_DOMAIN, NULL, L"CN=,OU=Users,OU=ITG,DC=ntdev,DC=microsoft,DC=com", AZ_PROP_CLIENT_CONTEXT_USER_DN },
  1395. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"SECDOMNT4\\Administrator", AZ_PROP_CLIENT_CONTEXT_USER_SAM_COMPAT },
  1396. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NO_SUCH_DOMAIN, NULL, L"Cliff Van Dyke", AZ_PROP_CLIENT_CONTEXT_USER_DISPLAY },
  1397. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NO_SUCH_DOMAIN, NULL, L"{ebff0213-bec7-4c11-bd47-06c80df7f356}", AZ_PROP_CLIENT_CONTEXT_USER_GUID },
  1398. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NO_SUCH_DOMAIN, NULL, L"ntdev.microsoft.com/ITG/Users/Cliff Van Dyke", AZ_PROP_CLIENT_CONTEXT_USER_CANONICAL },
  1399. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NO_SUCH_DOMAIN, NULL, L"[email protected]", AZ_PROP_CLIENT_CONTEXT_USER_UPN },
  1400. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"NTDEV.MICROSOFT.COM\\cliffv", AZ_PROP_CLIENT_CONTEXT_USER_DNS_SAM_COMPAT },
  1401. #endif // ENABLE_NT4_ACCOUNT
  1402. #ifdef ENABLE_LOCAL_ACCOUNT
  1403. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"CN=Cliff Van Dyke,OU=Users,OU=ITG,DC=ntdev,DC=microsoft,DC=com", AZ_PROP_CLIENT_CONTEXT_USER_DN },
  1404. { AzoGetProp, &CCHandle, NULL, NULL, NO_ERROR, NULL, L"CLIFFV5-PRO\\Administrator", AZ_PROP_CLIENT_CONTEXT_USER_SAM_COMPAT },
  1405. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"Cliff Van Dyke", AZ_PROP_CLIENT_CONTEXT_USER_DISPLAY },
  1406. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"{ebff0213-bec7-4c11-bd47-06c80df7f356}", AZ_PROP_CLIENT_CONTEXT_USER_GUID },
  1407. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"ntdev.microsoft.com/ITG/Users/Cliff Van Dyke", AZ_PROP_CLIENT_CONTEXT_USER_CANONICAL },
  1408. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"[email protected]", AZ_PROP_CLIENT_CONTEXT_USER_UPN },
  1409. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_NONE_MAPPED, NULL, L"NTDEV.MICROSOFT.COM\\cliffv", AZ_PROP_CLIENT_CONTEXT_USER_DNS_SAM_COMPAT },
  1410. #endif // ENABLE_LOCAL_ACCOUNT
  1411. { AzoEcho, NULL, L"... except the generic ones" },
  1412. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_NAME },
  1413. { AzoGetProp, &CCHandle, NULL, NULL, ERROR_INVALID_PARAMETER, NULL, NULL, AZ_PROP_DESCRIPTION },
  1414. { AzoEcho, NULL, L"Create a role denying op1 access to everyone SID via a task with a bizrule" },
  1415. { AzoScopeOpen, &AppHandle1, L"MyScope8", &ScopeHandle1, NO_ERROR },
  1416. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCannotOp1ViaTask1WithBizrule", &RoleHandleA, NO_ERROR },
  1417. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1418. { AzoAddProp, &RoleHandleA, L"TaskOp1WithEmptyBizRule", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1419. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1420. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1421. #if 0
  1422. { AzoEcho, NULL, L"Check denied access via a task with bizrule" },
  1423. { AzoAccess, &CCHandle, L"MyScope8", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1424. #endif // 0
  1425. { AzoEcho, NULL, L"Create a role granting op1 access to everyone SID via a task with a bizrule" },
  1426. { AzoScopeOpen, &AppHandle1, L"MyScope9", &ScopeHandle1, NO_ERROR },
  1427. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1ViaTask1WithBizrule", &RoleHandleA, NO_ERROR },
  1428. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1429. { AzoAddProp, &RoleHandleA, L"TaskOp1WithTrivialBizRule", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1430. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1431. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1432. { AzoEcho, NULL, L"Check granted access via a task with bizrule" },
  1433. { AzoAccess, &CCHandle, L"MyScope9", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1434. { AzoAccess, &CCHandle, L"MyScope9", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1435. { AzoEcho, NULL, L"Create a role granting op1 access to everyone SID via a task with a bizrule (using parameters)" },
  1436. { AzoTaskCreate, &AppHandle1, L"TaskOp1WithParameterBizrule", &TaskHandle1, NO_ERROR },
  1437. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1438. { AzoSetProp, &TaskHandle1, L"VBScript", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  1439. { AzoSetProp, &TaskHandle1, L"Dim Amount\nAmount = AccessCheck.GetParameter( \"Amount\" )\nif Amount < 500 then AccessCheckBusinessRuleResult = TRUE", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  1440. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1441. { AzoScopeOpen, &AppHandle1, L"MyScopeP1", &ScopeHandle1, NO_ERROR },
  1442. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1WithParameterBizrule", &RoleHandleA, NO_ERROR },
  1443. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1444. { AzoAddProp, &RoleHandleA, L"TaskOp1WithParameterBizrule", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1445. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1446. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1447. // This fails because I don't pass any parameters to AccessCheck and the Bizrule wants the AmountParameter
  1448. { AzoEcho, NULL, L"Check granted access via a task with bizrule (using parameters)" },
  1449. { AzoAccess, &CCHandle, L"MyScopeP1", (PAZ_HANDLE)&Ops1, ERROR_INVALID_PARAMETER, NULL, (LPWSTR) &ResF, 1 },
  1450. { AzoEcho, NULL, L"Create a role using a task with an infinite loop" },
  1451. { AzoTaskCreate, &AppHandle1, L"TaskInfiniteLoop", &TaskHandle1, NO_ERROR },
  1452. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1453. { AzoSetProp, &TaskHandle1, L"VBScript", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  1454. { AzoSetProp, &TaskHandle1, L"While True\nWend", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  1455. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1456. { AzoScopeCreate, &AppHandle1, L"MyScopeI1", &ScopeHandle1, NO_ERROR },
  1457. { AzoRoleCreate, &ScopeHandle1, L"RoleInfinite", &RoleHandleA, NO_ERROR },
  1458. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1459. { AzoAddProp, &RoleHandleA, L"TaskInfiniteLoop", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1460. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1461. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1462. { AzoEcho, NULL, L"Set the timeout to 5 seconds" },
  1463. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&FortyFiveThousand, AZ_PROP_ADMIN_SCRIPT_ENGINE_TIMEOUT },
  1464. { AzoSetProp, &AdminMgrHandle1, (LPWSTR)&FiveThousand,NULL, NO_ERROR, NULL, NULL, AZ_PROP_ADMIN_SCRIPT_ENGINE_TIMEOUT },
  1465. { AzoGetProp, &AdminMgrHandle1, NULL, NULL, NO_ERROR, NULL, (LPWSTR)&FiveThousand, AZ_PROP_ADMIN_SCRIPT_ENGINE_TIMEOUT },
  1466. { AzoEcho, NULL, L"Check granted access via a task with infinite loop" },
  1467. { AzoAccess, &CCHandle, L"MyScopeI1", (PAZ_HANDLE)&Ops1, ERROR_TIMEOUT, NULL, (LPWSTR) &ResF, 1 },
  1468. { AzoEcho, NULL, L"Create a role under application granting op1 access to everyone SID" },
  1469. { AzoRoleCreate, &AppHandle1, L"AppRoleEveryoneCanOp1", &RoleHandleA, NO_ERROR },
  1470. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1471. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1472. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1473. { AzoEcho, NULL, L"Check a SID on a role granting access with default scope" },
  1474. { AzoAccess, &CCHandle, NULL, (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1475. { AzoEcho, NULL, L"Check access granted with default scope anda role granting op1 access to everyone SID" },
  1476. { AzoRoleCreate, &AppHandle1, L"NoScopeRoleEveryoneCanOp1", &RoleHandleA, NO_ERROR },
  1477. { AzoAddProp, &RoleHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_MEMBERS },
  1478. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1479. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1480. { AzoEcho, NULL, L"Check a SID on a role granting access" },
  1481. { AzoAccess, &CCHandle, NULL, (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1482. { AzoClose, &CCHandle, NULL, NULL, NO_ERROR },
  1483. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1484. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1485. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1486. { AzoEndOfList }
  1487. };
  1488. //
  1489. // Special case access checks
  1490. // These are tests we don't always want to run, but we have an option to run them
  1491. // under some circumstances
  1492. //
  1493. OPERATION OpAccessBegin[] = {
  1494. { AzoEcho, NULL, L"Create a smaller database to do special case access checks" },
  1495. { AzoInit, NULL, NULL, &AdminMgrHandle1, NO_ERROR, NULL, NULL, AZ_ADMIN_FLAG_CREATE },
  1496. { AzoAppCreate, &AdminMgrHandle1, L"MyApp", &AppHandle1, NO_ERROR },
  1497. { AzoOpCreate, &AppHandle1, L"Op1", &OpHandle1, NO_ERROR },
  1498. { AzoSetProp, &OpHandle1, (LPWSTR)&Op1Num,NULL, NO_ERROR, NULL, NULL, AZ_PROP_OPERATION_ID },
  1499. { AzoClose, &OpHandle1, NULL, NULL, NO_ERROR },
  1500. { AzoGroupCreate, &AppHandle1, L"Group1", &GroupHandleA, NO_ERROR },
  1501. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1502. { AzoAddProp, &GroupHandleA, (LPWSTR)&SidWorld, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_MEMBERS },
  1503. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1504. { AzoGroupCreate, &AppHandle1, L"Group2", &GroupHandleA, NO_ERROR },
  1505. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1506. { AzoAddProp, &GroupHandleA, L"Group1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1507. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1508. { AzoGroupCreate, &AppHandle1, L"Group3", &GroupHandleA, NO_ERROR },
  1509. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1510. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1511. { AzoGroupCreate, &AppHandle1, L"Group4", &GroupHandleA, NO_ERROR },
  1512. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic,NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1513. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1514. { AzoGroupCreate, &AppHandle1, L"GroupLdapYes", &GroupHandleA, NO_ERROR },
  1515. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtLdap, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1516. #ifdef ENABLE_CLIFFV_ACCOUNT
  1517. { AzoSetProp, &GroupHandleA, L"(userAccountControl=1049088)", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  1518. #endif // ENABLE_CLIFFV_ACCOUNT
  1519. #ifdef ENABLE_CHAITU_ACCOUNT
  1520. { AzoSetProp, &GroupHandleA, L"(userAccountControl=512)", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_LDAP_QUERY },
  1521. #endif // ENABLE_CHAITU_ACCOUNT
  1522. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1523. { AzoEcho, NULL, L"Create a trivial bizrule" },
  1524. { AzoTaskCreate, &AppHandle1, L"TaskOp1WithTrivialBizRule", &TaskHandle1, NO_ERROR },
  1525. { AzoAddProp, &TaskHandle1, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_OPERATIONS },
  1526. { AzoSetProp, &TaskHandle1, L"VBScript", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE_LANGUAGE },
  1527. { AzoSetProp, &TaskHandle1, L"AccessCheck.BusinessRuleResult = TRUE", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  1528. { AzoClose, &TaskHandle1, NULL, NULL, NO_ERROR },
  1529. { AzoEcho, NULL, L"Create a role granting op1 access to everyone SID via a task with a bizrule" },
  1530. { AzoScopeCreate, &AppHandle1, L"MyScope", &ScopeHandle1, NO_ERROR },
  1531. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1ViaTask1WithBizrule", &RoleHandleA, NO_ERROR },
  1532. { AzoAddProp, &RoleHandleA, L"Group2", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1533. { AzoAddProp, &RoleHandleA, L"TaskOp1WithTrivialBizRule", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1534. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1535. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1536. { AzoEcho, NULL, L".. Another role but using LDAP this time" },
  1537. { AzoScopeCreate, &AppHandle1, L"MyScopeLdap", &ScopeHandle1, NO_ERROR },
  1538. { AzoRoleCreate, &ScopeHandle1, L"RoleEveryoneCanOp1ViaTask1WithBizrule", &RoleHandleA, NO_ERROR },
  1539. { AzoAddProp, &RoleHandleA, L"GroupLdapYes", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1540. { AzoAddProp, &RoleHandleA, L"TaskOp1WithTrivialBizRule", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_TASKS },
  1541. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1542. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1543. { AzoEcho, NULL, L"Build a context" },
  1544. { AzoInitCFT, &AppHandle1, (LPWSTR)&TokenHandle, &CCHandle, NO_ERROR },
  1545. { AzoEndOfList }
  1546. };
  1547. OPERATION OpAccess2[] = {
  1548. { AzoAccess, &CCHandle, L"MyScope", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1549. { AzoEndOfList }
  1550. };
  1551. // Flush group membership cache, too
  1552. OPERATION OpAccess2Ldap[] = {
  1553. { AzoEcho, NULL, L"main" },
  1554. { AzoGroupOpen, &AppHandle1, L"Group2", &GroupHandle1, NO_ERROR },
  1555. { AzoAddProp|AzoNoSubmit, &GroupHandle1, L"Group4", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1556. { AzoClose, &GroupHandle1, NULL, NULL, NO_ERROR },
  1557. { AzoAccess, &CCHandle, L"MyScopeLdap", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1558. { AzoEndOfList }
  1559. };
  1560. //
  1561. // Test a group with lots of sids as members
  1562. //
  1563. OPERATION OpSidxBegin[] = {
  1564. { AzoEcho, NULL, L"Create a group with many sid members" },
  1565. { AzoGroupCreate, &AppHandle1, L"GroupManySid", &GroupHandleA, NO_ERROR },
  1566. { AzoSetProp, &GroupHandleA, (LPWSTR)&GtBasic, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_TYPE },
  1567. { AzoEndOfList }
  1568. };
  1569. OPERATION OpSidx[] = {
  1570. { AzoAddProp| AzoNoSubmit, &GroupHandleA, (LPWSTR)&SidX, NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_MEMBERS },
  1571. { AzoEndOfList }
  1572. };
  1573. OPERATION OpSidxEnd[] = {
  1574. { AzoEcho, NULL, L"Do an access check on the group" },
  1575. { AzoRoleCreate, &AppHandle1, L"RoleManySid", &RoleHandleA, NO_ERROR },
  1576. { AzoAddProp, &RoleHandleA, L"GroupManySid", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_APP_MEMBERS },
  1577. { AzoAddProp, &RoleHandleA, L"Op1", NULL, NO_ERROR, NULL, NULL, AZ_PROP_ROLE_OPERATIONS },
  1578. { AzoClose, &RoleHandleA, NULL, NULL, NO_ERROR },
  1579. { AzoScopeCreate, &AppHandle1, L"ScopeManySid", &ScopeHandle1, NO_ERROR },
  1580. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1581. { AzoAccess, &CCHandle, L"ScopeManySid", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResF, 1 },
  1582. { AzoClose, &GroupHandleA, NULL, NULL, NO_ERROR },
  1583. { AzoEndOfList }
  1584. };
  1585. OPERATION OpAccessEnd[] = {
  1586. { AzoClose, &CCHandle, NULL, NULL, NO_ERROR },
  1587. { AzoClose, &AppHandle1, NULL, NULL, NO_ERROR },
  1588. { AzoAdmDelete, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1589. { AzoClose, &AdminMgrHandle1, NULL, NULL, NO_ERROR },
  1590. { AzoEndOfList }
  1591. };
  1592. OPERATION OpAccess1m[] = {
  1593. { AzoEcho, NULL, L"Second thread" },
  1594. { AzoInitCFT, &AppHandle1, (LPWSTR)&TokenHandle, &CCHandle2, NO_ERROR },
  1595. { AzoEndOfList }
  1596. };
  1597. OPERATION OpAccess2m[] = {
  1598. { AzoEcho, NULL, L"Second thread access" },
  1599. { AzoAccess, &CCHandle2, L"MyScope", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1600. { AzoEndOfList }
  1601. };
  1602. // Flush group membership cache, too
  1603. OPERATION OpAccess2mLdap[] = {
  1604. { AzoEcho, NULL, L"Second thread access" },
  1605. { AzoGroupOpen, &AppHandle1, L"Group2", &GroupHandleT, NO_ERROR },
  1606. { AzoAddProp|AzoNoSubmit, &GroupHandleT, L"Group3", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1607. { AzoClose, &GroupHandleT, NULL, NULL, NO_ERROR },
  1608. { AzoAccess, &CCHandle2, L"MyScopeLdap", (PAZ_HANDLE)&Ops1, NO_ERROR, NULL, (LPWSTR) &ResS, 1 },
  1609. { AzoEndOfList }
  1610. };
  1611. OPERATION OpAccess3m[] = {
  1612. { AzoEcho, NULL, L"Second thread close" },
  1613. { AzoClose, &CCHandle2, NULL, NULL, NO_ERROR },
  1614. { AzoEndOfList }
  1615. };
  1616. OPERATION OpBizruleThread[] = {
  1617. { AzoEcho, NULL, L"BizRule change thread" },
  1618. { AzoTaskOpen, &AppHandle1, L"TaskOp1WithTrivialBizRule", &TaskHandleT, NO_ERROR },
  1619. { AzoSetProp, &TaskHandleT, L"AccessCheck.BusinessRuleResult = TRUE", NULL, NO_ERROR, NULL, NULL, AZ_PROP_TASK_BIZRULE },
  1620. { AzoClose, &TaskHandleT, NULL, NULL, NO_ERROR },
  1621. { AzoEndOfList }
  1622. };
  1623. OPERATION OpGroupThread[] = {
  1624. { AzoEcho, NULL, L"Group change thread" },
  1625. { AzoGroupOpen, &AppHandle1, L"Group2", &GroupHandleT, NO_ERROR },
  1626. { AzoAddProp, &GroupHandleT, L"Group3", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1627. { AzoRemProp, &GroupHandleT, L"Group3", NULL, NO_ERROR, NULL, NULL, AZ_PROP_GROUP_APP_MEMBERS },
  1628. { AzoClose, &GroupHandleT, NULL, NULL, NO_ERROR },
  1629. { AzoEndOfList }
  1630. };
  1631. WCHAR ScopeBillions[64];
  1632. OPERATION OpBillions[] = {
  1633. { AzoScopeCreate, &AppHandle1, ScopeBillions, &ScopeHandle1, NO_ERROR },
  1634. { AzoClose, &ScopeHandle1, NULL, NULL, NO_ERROR },
  1635. { AzoEndOfList }
  1636. };
  1637. VOID
  1638. DumpBuffer(
  1639. PVOID Buffer,
  1640. DWORD BufferSize
  1641. )
  1642. /*++
  1643. Routine Description:
  1644. Dumps the buffer content on to the debugger output.
  1645. Arguments:
  1646. Buffer: buffer pointer.
  1647. BufferSize: size of the buffer.
  1648. Return Value:
  1649. none
  1650. --*/
  1651. {
  1652. #define NUM_CHARS 16
  1653. DWORD i, limit;
  1654. CHAR TextBuffer[NUM_CHARS + 1];
  1655. LPBYTE BufferPtr = Buffer;
  1656. printf("------------------------------------\n");
  1657. //
  1658. // Hex dump of the bytes
  1659. //
  1660. limit = ((BufferSize - 1) / NUM_CHARS + 1) * NUM_CHARS;
  1661. for (i = 0; i < limit; i++) {
  1662. if (i < BufferSize) {
  1663. printf("%02x ", BufferPtr[i]);
  1664. if (BufferPtr[i] < 31 ) {
  1665. TextBuffer[i % NUM_CHARS] = '.';
  1666. } else if (BufferPtr[i] == '\0') {
  1667. TextBuffer[i % NUM_CHARS] = ' ';
  1668. } else {
  1669. TextBuffer[i % NUM_CHARS] = (CHAR) BufferPtr[i];
  1670. }
  1671. } else {
  1672. printf(" ");
  1673. TextBuffer[i % NUM_CHARS] = ' ';
  1674. }
  1675. if ((i + 1) % NUM_CHARS == 0) {
  1676. TextBuffer[NUM_CHARS] = 0;
  1677. printf(" %s\n", TextBuffer);
  1678. }
  1679. }
  1680. printf("------------------------------------\n");
  1681. }
  1682. LPSTR
  1683. FindSymbolicNameForStatus(
  1684. DWORD Id
  1685. )
  1686. {
  1687. ULONG i;
  1688. i = 0;
  1689. if (Id == 0) {
  1690. return "STATUS_SUCCESS";
  1691. }
  1692. if (Id & 0xC0000000) {
  1693. while (ntstatusSymbolicNames[ i ].SymbolicName) {
  1694. if (ntstatusSymbolicNames[ i ].MessageId == (NTSTATUS)Id) {
  1695. return ntstatusSymbolicNames[ i ].SymbolicName;
  1696. } else {
  1697. i += 1;
  1698. }
  1699. }
  1700. }
  1701. while (winerrorSymbolicNames[ i ].SymbolicName) {
  1702. if (winerrorSymbolicNames[ i ].MessageId == Id) {
  1703. return winerrorSymbolicNames[ i ].SymbolicName;
  1704. } else {
  1705. i += 1;
  1706. }
  1707. }
  1708. #ifdef notdef
  1709. while (neteventSymbolicNames[ i ].SymbolicName) {
  1710. if (neteventSymbolicNames[ i ].MessageId == Id) {
  1711. return neteventSymbolicNames[ i ].SymbolicName
  1712. } else {
  1713. i += 1;
  1714. }
  1715. }
  1716. #endif // notdef
  1717. return NULL;
  1718. }
  1719. VOID
  1720. PrintStatus(
  1721. NET_API_STATUS NetStatus
  1722. )
  1723. /*++
  1724. Routine Description:
  1725. Print a net status code.
  1726. Arguments:
  1727. NetStatus - The net status code to print.
  1728. Return Value:
  1729. None
  1730. --*/
  1731. {
  1732. switch (NetStatus) {
  1733. case NO_ERROR:
  1734. printf( "NO_ERROR" );
  1735. break;
  1736. case NERR_DCNotFound:
  1737. printf( "NERR_DCNotFound" );
  1738. break;
  1739. case ERROR_LOGON_FAILURE:
  1740. printf( "ERROR_LOGON_FAILURE" );
  1741. break;
  1742. case ERROR_ACCESS_DENIED:
  1743. printf( "ERROR_ACCESS_DENIED" );
  1744. break;
  1745. case ERROR_NOT_SUPPORTED:
  1746. printf( "ERROR_NOT_SUPPORTED" );
  1747. break;
  1748. case ERROR_NO_LOGON_SERVERS:
  1749. printf( "ERROR_NO_LOGON_SERVERS" );
  1750. break;
  1751. case ERROR_NO_SUCH_DOMAIN:
  1752. printf( "ERROR_NO_SUCH_DOMAIN" );
  1753. break;
  1754. case ERROR_NO_TRUST_LSA_SECRET:
  1755. printf( "ERROR_NO_TRUST_LSA_SECRET" );
  1756. break;
  1757. case ERROR_NO_TRUST_SAM_ACCOUNT:
  1758. printf( "ERROR_NO_TRUST_SAM_ACCOUNT" );
  1759. break;
  1760. case ERROR_DOMAIN_TRUST_INCONSISTENT:
  1761. printf( "ERROR_DOMAIN_TRUST_INCONSISTENT" );
  1762. break;
  1763. case ERROR_BAD_NETPATH:
  1764. printf( "ERROR_BAD_NETPATH" );
  1765. break;
  1766. case ERROR_FILE_NOT_FOUND:
  1767. printf( "ERROR_FILE_NOT_FOUND" );
  1768. break;
  1769. case NERR_NetNotStarted:
  1770. printf( "NERR_NetNotStarted" );
  1771. break;
  1772. case NERR_WkstaNotStarted:
  1773. printf( "NERR_WkstaNotStarted" );
  1774. break;
  1775. case NERR_ServerNotStarted:
  1776. printf( "NERR_ServerNotStarted" );
  1777. break;
  1778. case NERR_BrowserNotStarted:
  1779. printf( "NERR_BrowserNotStarted" );
  1780. break;
  1781. case NERR_ServiceNotInstalled:
  1782. printf( "NERR_ServiceNotInstalled" );
  1783. break;
  1784. case NERR_BadTransactConfig:
  1785. printf( "NERR_BadTransactConfig" );
  1786. break;
  1787. case SEC_E_NO_SPM:
  1788. printf( "SEC_E_NO_SPM" );
  1789. break;
  1790. case SEC_E_BAD_PKGID:
  1791. printf( "SEC_E_BAD_PKGID" ); break;
  1792. case SEC_E_NOT_OWNER:
  1793. printf( "SEC_E_NOT_OWNER" ); break;
  1794. case SEC_E_CANNOT_INSTALL:
  1795. printf( "SEC_E_CANNOT_INSTALL" ); break;
  1796. case SEC_E_INVALID_TOKEN:
  1797. printf( "SEC_E_INVALID_TOKEN" ); break;
  1798. case SEC_E_CANNOT_PACK:
  1799. printf( "SEC_E_CANNOT_PACK" ); break;
  1800. case SEC_E_QOP_NOT_SUPPORTED:
  1801. printf( "SEC_E_QOP_NOT_SUPPORTED" ); break;
  1802. case SEC_E_NO_IMPERSONATION:
  1803. printf( "SEC_E_NO_IMPERSONATION" ); break;
  1804. case SEC_E_LOGON_DENIED:
  1805. printf( "SEC_E_LOGON_DENIED" ); break;
  1806. case SEC_E_UNKNOWN_CREDENTIALS:
  1807. printf( "SEC_E_UNKNOWN_CREDENTIALS" ); break;
  1808. case SEC_E_NO_CREDENTIALS:
  1809. printf( "SEC_E_NO_CREDENTIALS" ); break;
  1810. case SEC_E_MESSAGE_ALTERED:
  1811. printf( "SEC_E_MESSAGE_ALTERED" ); break;
  1812. case SEC_E_OUT_OF_SEQUENCE:
  1813. printf( "SEC_E_OUT_OF_SEQUENCE" ); break;
  1814. case SEC_E_INSUFFICIENT_MEMORY:
  1815. printf( "SEC_E_INSUFFICIENT_MEMORY" ); break;
  1816. case SEC_E_INVALID_HANDLE:
  1817. printf( "SEC_E_INVALID_HANDLE" ); break;
  1818. case SEC_E_NOT_SUPPORTED:
  1819. printf( "SEC_E_NOT_SUPPORTED" ); break;
  1820. #define OLESCRIPT_E_SYNTAX _HRESULT_TYPEDEF_(0x80020101L)
  1821. case OLESCRIPT_E_SYNTAX:
  1822. printf( "OLESCRIPT_E_SYNTAX" ); break;
  1823. default: {
  1824. LPSTR Name = FindSymbolicNameForStatus( NetStatus );
  1825. if ( Name == NULL ) {
  1826. if ( NetStatus & 0x80000000 ) {
  1827. HRESULT hr = NetStatus;
  1828. if ((HRESULT_FACILITY(hr) == FACILITY_WIN32) && (FAILED(hr))) {
  1829. DWORD TempStatus;
  1830. TempStatus = HRESULT_CODE(hr);
  1831. if ( TempStatus == ERROR_SUCCESS ) {
  1832. TempStatus = ERROR_INTERNAL_ERROR;
  1833. }
  1834. printf( "(0x%lx is ", hr );
  1835. PrintStatus( TempStatus );
  1836. printf( ")" );
  1837. } else {
  1838. printf( "(0x%lx)", NetStatus );
  1839. }
  1840. } else {
  1841. printf( "(%lu)", NetStatus );
  1842. }
  1843. } else {
  1844. printf( "%s", Name );
  1845. }
  1846. break;
  1847. }
  1848. }
  1849. }
  1850. VOID
  1851. PrintIndent(
  1852. IN ULONG Indentation,
  1853. IN BOOLEAN Error
  1854. )
  1855. /*++
  1856. Routine Description:
  1857. Print line prefix for log file
  1858. Arguments:
  1859. Indentation - Number of spaces to indent text by.
  1860. Error - True if this is a program failure.
  1861. Return Value:
  1862. None.
  1863. --*/
  1864. {
  1865. static LPSTR Blanks = " ";
  1866. printf( "%*.*s", Indentation, Indentation, Blanks );
  1867. if ( Error ) {
  1868. printf("[ERR] ");
  1869. }
  1870. }
  1871. //return type IDs
  1872. typedef enum _ENUM_AZ_DATATYPE
  1873. {
  1874. ENUM_AZ_NONE = 0,
  1875. ENUM_AZ_BSTR,
  1876. ENUM_AZ_LONG,
  1877. ENUM_AZ_BSTR_ARRAY,
  1878. ENUM_AZ_SID_ARRAY,
  1879. ENUM_AZ_BOOL,
  1880. } ENUM_AZ_DATATYPE, *PENUM_AZ_DATATYPE;
  1881. HRESULT
  1882. myAzGetPropertyDataType(
  1883. IN LONG lPropId,
  1884. OUT ENUM_AZ_DATATYPE *pDataType)
  1885. /*+++
  1886. Description:
  1887. a routine to map property ID to a data type
  1888. Arguments:
  1889. lPropId - property ID
  1890. pDataType - pointer to hold data type
  1891. Return:
  1892. ---*/
  1893. {
  1894. HRESULT hr;
  1895. ENUM_AZ_DATATYPE dataType;
  1896. // check property ID and assign data type
  1897. switch (lPropId)
  1898. {
  1899. case AZ_PROP_NAME:
  1900. case AZ_PROP_DESCRIPTION:
  1901. case AZ_PROP_APPLICATION_DATA:
  1902. case AZ_PROP_APPLICATION_AUTHZ_INTERFACE_CLSID:
  1903. case AZ_PROP_APPLICATION_VERSION:
  1904. case AZ_PROP_TASK_BIZRULE:
  1905. case AZ_PROP_TASK_BIZRULE_LANGUAGE:
  1906. case AZ_PROP_TASK_BIZRULE_IMPORTED_PATH:
  1907. case AZ_PROP_GROUP_LDAP_QUERY:
  1908. case AZ_PROP_CLIENT_CONTEXT_USER_DN:
  1909. case AZ_PROP_CLIENT_CONTEXT_USER_SAM_COMPAT:
  1910. case AZ_PROP_CLIENT_CONTEXT_USER_DISPLAY:
  1911. case AZ_PROP_CLIENT_CONTEXT_USER_GUID:
  1912. case AZ_PROP_CLIENT_CONTEXT_USER_CANONICAL:
  1913. case AZ_PROP_CLIENT_CONTEXT_USER_UPN:
  1914. case AZ_PROP_CLIENT_CONTEXT_USER_DNS_SAM_COMPAT:
  1915. case AZ_PROP_ADMIN_TARGET_MACHINE:
  1916. case AZ_PROP_CLIENT_CONTEXT_ROLE_FOR_ACCESS_CHECK:
  1917. dataType = ENUM_AZ_BSTR;
  1918. break;
  1919. case AZ_PROP_ADMIN_DOMAIN_TIMEOUT:
  1920. case AZ_PROP_ADMIN_SCRIPT_ENGINE_TIMEOUT:
  1921. case AZ_PROP_ADMIN_MAX_SCRIPT_ENGINES:
  1922. case AZ_PROP_OPERATION_ID:
  1923. case AZ_PROP_GROUP_TYPE:
  1924. case AZ_PROP_APPLY_STORE_SACL:
  1925. case AZ_PROP_GENERATE_AUDITS:
  1926. //case AZ_PROP_ADMIN_MAJOR_VERSION: make it invisible to clients
  1927. //case AZ_PROP_ADMIN_MINOR_VERSION: make it invisible to clients
  1928. dataType = ENUM_AZ_LONG;
  1929. break;
  1930. case AZ_PROP_TASK_OPERATIONS:
  1931. case AZ_PROP_TASK_TASKS:
  1932. case AZ_PROP_GROUP_APP_MEMBERS:
  1933. case AZ_PROP_GROUP_APP_NON_MEMBERS:
  1934. case AZ_PROP_ROLE_APP_MEMBERS:
  1935. case AZ_PROP_ROLE_OPERATIONS:
  1936. case AZ_PROP_ROLE_TASKS:
  1937. dataType = ENUM_AZ_BSTR_ARRAY;
  1938. break;
  1939. case AZ_PROP_GROUP_MEMBERS:
  1940. case AZ_PROP_GROUP_NON_MEMBERS:
  1941. case AZ_PROP_ROLE_MEMBERS:
  1942. case AZ_PROP_POLICY_ADMINS:
  1943. case AZ_PROP_POLICY_READERS:
  1944. case AZ_PROP_DELEGATED_POLICY_USERS:
  1945. dataType = ENUM_AZ_SID_ARRAY;
  1946. break;
  1947. case AZ_PROP_TASK_IS_ROLE_DEFINITION:
  1948. case AZ_PROP_WRITABLE:
  1949. dataType = ENUM_AZ_BOOL;
  1950. break;
  1951. default:
  1952. hr = E_INVALIDARG;
  1953. goto error;
  1954. break;
  1955. }
  1956. *pDataType = dataType;
  1957. hr = S_OK;
  1958. error:
  1959. return hr;
  1960. }
  1961. BOOL
  1962. DoOperations(
  1963. IN POPERATION OperationsToDo,
  1964. IN ULONG Indentation,
  1965. IN ULONG SpecificOpcodeOffset,
  1966. IN LPSTR EchoPrefix
  1967. )
  1968. /*++
  1969. Routine Description:
  1970. Do a set of operations
  1971. Arguments:
  1972. OperationsToDo - a list of operations to do
  1973. Indentation - Number of spaces to indent text by.
  1974. This value increases on recursive calls.
  1975. SpecificOpcodeOffset - Specifies an amount to add to a generic opcode to map
  1976. it to a specific opcode.
  1977. EchoPrefix - Specifies a string to print before all AzoEcho strings
  1978. Return Value:
  1979. TRUE - tests completed successfully
  1980. FALSE - tests failed
  1981. --*/
  1982. {
  1983. BOOL RetVal = TRUE;
  1984. POPERATION Operation;
  1985. LPSTR OpName;
  1986. ULONG Opcode;
  1987. PVOID PropertyValue = NULL;
  1988. ENUM_AZ_DATATYPE PropType;
  1989. ULONG PropertyId;
  1990. BOOLEAN WasGetProperty;
  1991. HANDLE SubmitHandle;
  1992. ULONG SubmitFlags;
  1993. BOOLEAN SubmitOk;
  1994. BOOLEAN UpdateCache;
  1995. BOOLEAN InitUponDelete;
  1996. ULONG SleepTime;
  1997. ULONG EnumerationContext = 0;
  1998. BOOLEAN FirstIteration = TRUE;
  1999. DWORD WinStatus;
  2000. DWORD RealWinStatus;
  2001. DWORD TempWinStatus;
  2002. HRESULT hr;
  2003. CHAR BigBuffer[1000];
  2004. PAZ_STRING_ARRAY StringArray1;
  2005. PAZ_STRING_ARRAY StringArray2;
  2006. PAZ_SID_ARRAY SidArray1;
  2007. PAZ_SID_ARRAY SidArray2;
  2008. LPWSTR ScopeNames[8];
  2009. ULONG Results[50];
  2010. static AZ_HANDLE GlobalAdminManagerHandle = NULL;
  2011. static AZ_HANDLE SavedGlobalAdminManagerHandle = NULL;
  2012. ULONG i;
  2013. //
  2014. // Leave room between tests
  2015. //
  2016. if ( Indentation == 0 ) {
  2017. if ( !Silent ) {
  2018. printf( "\n\n" );
  2019. }
  2020. }
  2021. //
  2022. // Loop through each of the operations
  2023. //
  2024. for ( Operation=OperationsToDo; Operation->Opcode != AzoEndOfList && RetVal; ) {
  2025. //
  2026. // Mark that this change doesn't need to be submitted (by default)
  2027. //
  2028. SubmitHandle = INVALID_HANDLE_VALUE;
  2029. //
  2030. // Compute the flags to pass to submit if a submit turns out to be needed
  2031. //
  2032. Opcode = Operation->Opcode;
  2033. SubmitFlags = 0;
  2034. if ( Opcode & AzoAbort ) {
  2035. SubmitFlags |= AZ_SUBMIT_FLAG_ABORT;
  2036. Opcode &= ~AzoAbort;
  2037. }
  2038. SubmitOk = TRUE;
  2039. if ( Opcode & AzoNoSubmit ) {
  2040. SubmitOk = FALSE;
  2041. Opcode &= ~AzoNoSubmit;
  2042. }
  2043. UpdateCache = TRUE;
  2044. if ( Opcode & AzoNoUpdateCache ) {
  2045. UpdateCache = FALSE;
  2046. Opcode &= ~AzoNoUpdateCache;
  2047. }
  2048. InitUponDelete = FALSE;
  2049. //
  2050. // Compute the mapped property ID
  2051. //
  2052. if ( TestLinkPropId != 0 && Operation->PropertyId != 0 ) {
  2053. PropertyId = TestLinkPropId;
  2054. } else {
  2055. PropertyId = Operation->PropertyId;
  2056. }
  2057. //
  2058. // Setup for get/set property
  2059. //
  2060. PropertyValue = NULL;
  2061. //
  2062. // Convert property id to type
  2063. //
  2064. hr = myAzGetPropertyDataType( PropertyId, &PropType );
  2065. if ( FAILED(hr) ) {
  2066. PropType = ENUM_AZ_NONE;
  2067. }
  2068. WasGetProperty = FALSE;
  2069. SleepTime = 0;
  2070. //
  2071. // Map generic opcodes to a specific opcode
  2072. //
  2073. if ( Opcode < AzoGenMax ) {
  2074. ASSERT( SpecificOpcodeOffset != 0 );
  2075. Opcode += SpecificOpcodeOffset;
  2076. } else if ( Opcode >= AzoTl && Opcode < AzoTlMax ) {
  2077. ASSERT( TestLinkOpcodeOffset != 0 );
  2078. Opcode = Opcode - AzoTl + TestLinkOpcodeOffset;
  2079. }
  2080. //
  2081. // Perform the requested operation
  2082. //
  2083. //
  2084. // Admin Manager APIs
  2085. //
  2086. switch ( Opcode ) {
  2087. case AzoInit:
  2088. OpName = "AzInitialize";
  2089. WinStatus = AzInitialize(
  2090. AzGlTestFile,
  2091. PropertyId, // Flags
  2092. 0, // reserved
  2093. Operation->OutputHandle );
  2094. SubmitHandle = *Operation->OutputHandle;
  2095. UpdateCache = FALSE;
  2096. //
  2097. // Initialize another copy for refresh testing
  2098. //
  2099. if ( !NoUpdateCache && WinStatus == NO_ERROR && GlobalAdminManagerHandle == NULL ) {
  2100. SavedGlobalAdminManagerHandle = *Operation->OutputHandle;
  2101. TempWinStatus = AzInitialize(
  2102. AzGlTestFile,
  2103. PropertyId, // Flags
  2104. 0, // reserved
  2105. &GlobalAdminManagerHandle );
  2106. if ( TempWinStatus != NO_ERROR ) {
  2107. PrintIndent( Indentation+4, TRUE );
  2108. RetVal = FALSE;
  2109. printf( "Cannot AzInitialize new database. %ld\n", TempWinStatus );
  2110. }
  2111. }
  2112. break;
  2113. case AzoUpdateCache:
  2114. OpName = "AzUpdateCache";
  2115. WinStatus = AzUpdateCache(
  2116. *Operation->InputHandle );
  2117. break;
  2118. case AzoGetProp:
  2119. OpName = "AzGetProperty";
  2120. WinStatus = AzGetProperty(
  2121. *Operation->InputHandle,
  2122. PropertyId,
  2123. 0, // reserved
  2124. &PropertyValue );
  2125. WasGetProperty = TRUE;
  2126. break;
  2127. case AzoSetProp:
  2128. OpName = "AzSetProperty";
  2129. WinStatus = AzSetProperty(
  2130. *Operation->InputHandle,
  2131. PropertyId,
  2132. 0, // reserved
  2133. Operation->Parameter1 );
  2134. SubmitHandle = *Operation->InputHandle;
  2135. break;
  2136. case AzoAddProp:
  2137. OpName = "AzAddProperty";
  2138. WinStatus = AzAddPropertyItem(
  2139. *Operation->InputHandle,
  2140. PropertyId,
  2141. 0, // reserved
  2142. Operation->Parameter1 );
  2143. SubmitHandle = *Operation->InputHandle;
  2144. break;
  2145. case AzoRemProp:
  2146. OpName = "AzRemProperty";
  2147. WinStatus = AzRemovePropertyItem(
  2148. *Operation->InputHandle,
  2149. PropertyId,
  2150. 0, // reserved
  2151. Operation->Parameter1 );
  2152. SubmitHandle = *Operation->InputHandle;
  2153. break;
  2154. case AzoAdmDelete:
  2155. InitUponDelete = TRUE;
  2156. /* Drop through */
  2157. case AzoAdmDeleteNoInit:
  2158. //
  2159. // Take this oportunity to ensure we can initialize from this store
  2160. //
  2161. WinStatus = NO_ERROR;
  2162. if ( InitUponDelete && !NoInitAllTests ) {
  2163. AZ_HANDLE AdminManagerHandle;
  2164. WinStatus = AzInitialize(
  2165. AzGlTestFile,
  2166. 0, // No flags
  2167. 0, // reserved
  2168. &AdminManagerHandle );
  2169. if ( WinStatus != NO_ERROR ) {
  2170. PrintIndent( Indentation+4, TRUE );
  2171. RetVal = FALSE;
  2172. printf( "Cannot AzInitialize existing database.\n" );
  2173. } else {
  2174. AzCloseHandle( AdminManagerHandle, 0 );
  2175. }
  2176. }
  2177. OpName = "AzAdminManagerDelete";
  2178. if ( RetVal ) {
  2179. WinStatus = AzAdminManagerDelete(
  2180. *Operation->InputHandle,
  2181. 0 ); // reserved
  2182. }
  2183. UpdateCache = FALSE;
  2184. break;
  2185. //
  2186. // Application APIs
  2187. //
  2188. case AzoAppCreate:
  2189. OpName = "AzApplicationCreate";
  2190. WinStatus = AzApplicationCreate(
  2191. *Operation->InputHandle,
  2192. Operation->Parameter1,
  2193. 0, // reserved
  2194. Operation->OutputHandle );
  2195. SubmitHandle = *Operation->OutputHandle;
  2196. break;
  2197. case AzoAppOpen:
  2198. OpName = "AzApplicationOpen";
  2199. WinStatus = AzApplicationOpen(
  2200. *Operation->InputHandle,
  2201. Operation->Parameter1,
  2202. 0, // reserved
  2203. Operation->OutputHandle );
  2204. break;
  2205. case AzoAppEnum:
  2206. OpName = "AzApplicationEnum";
  2207. WinStatus = AzApplicationEnum(
  2208. *Operation->InputHandle,
  2209. 0, // reserved
  2210. &EnumerationContext,
  2211. Operation->OutputHandle );
  2212. break;
  2213. case AzoAppDelete:
  2214. OpName = "AzApplicationDelete";
  2215. WinStatus = AzApplicationDelete(
  2216. *Operation->InputHandle,
  2217. Operation->Parameter1,
  2218. 0 ); // reserved
  2219. SubmitHandle = *Operation->InputHandle;
  2220. break;
  2221. //
  2222. // Operation APIs
  2223. //
  2224. case AzoOpCreate:
  2225. OpName = "AzOperationCreate";
  2226. WinStatus = AzOperationCreate(
  2227. *Operation->InputHandle,
  2228. Operation->Parameter1,
  2229. 0, // reserved
  2230. Operation->OutputHandle );
  2231. SubmitHandle = *Operation->OutputHandle;
  2232. break;
  2233. case AzoOpOpen:
  2234. OpName = "AzOperationOpen";
  2235. WinStatus = AzOperationOpen(
  2236. *Operation->InputHandle,
  2237. Operation->Parameter1,
  2238. 0, // reserved
  2239. Operation->OutputHandle );
  2240. break;
  2241. case AzoOpEnum:
  2242. OpName = "AzOperationEnum";
  2243. WinStatus = AzOperationEnum(
  2244. *Operation->InputHandle,
  2245. 0, // reserved
  2246. &EnumerationContext,
  2247. Operation->OutputHandle );
  2248. break;
  2249. case AzoOpDelete:
  2250. OpName = "AzOperationDelete";
  2251. WinStatus = AzOperationDelete(
  2252. *Operation->InputHandle,
  2253. Operation->Parameter1,
  2254. 0 ); // reserved
  2255. SubmitHandle = *Operation->InputHandle;
  2256. break;
  2257. //
  2258. // Task APIs
  2259. //
  2260. case AzoTaskCreate:
  2261. OpName = "AzTaskCreate";
  2262. WinStatus = AzTaskCreate(
  2263. *Operation->InputHandle,
  2264. Operation->Parameter1,
  2265. 0, // reserved
  2266. Operation->OutputHandle );
  2267. SubmitHandle = *Operation->OutputHandle;
  2268. break;
  2269. case AzoTaskOpen:
  2270. OpName = "AzTaskOpen";
  2271. WinStatus = AzTaskOpen(
  2272. *Operation->InputHandle,
  2273. Operation->Parameter1,
  2274. 0, // reserved
  2275. Operation->OutputHandle );
  2276. break;
  2277. case AzoTaskEnum:
  2278. OpName = "AzTaskEnum";
  2279. WinStatus = AzTaskEnum(
  2280. *Operation->InputHandle,
  2281. 0, // reserved
  2282. &EnumerationContext,
  2283. Operation->OutputHandle );
  2284. break;
  2285. case AzoTaskDelete:
  2286. OpName = "AzTaskDelete";
  2287. WinStatus = AzTaskDelete(
  2288. *Operation->InputHandle,
  2289. Operation->Parameter1,
  2290. 0 ); // reserved
  2291. SubmitHandle = *Operation->InputHandle;
  2292. break;
  2293. //
  2294. // Scope APIs
  2295. //
  2296. case AzoScopeCreate:
  2297. OpName = "AzScopeCreate";
  2298. WinStatus = AzScopeCreate(
  2299. *Operation->InputHandle,
  2300. Operation->Parameter1,
  2301. 0, // reserved
  2302. Operation->OutputHandle );
  2303. SubmitHandle = *Operation->OutputHandle;
  2304. break;
  2305. case AzoScopeOpen:
  2306. OpName = "AzScopeOpen";
  2307. WinStatus = AzScopeOpen(
  2308. *Operation->InputHandle,
  2309. Operation->Parameter1,
  2310. 0, // reserved
  2311. Operation->OutputHandle );
  2312. break;
  2313. case AzoScopeEnum:
  2314. OpName = "AzScopeEnum";
  2315. WinStatus = AzScopeEnum(
  2316. *Operation->InputHandle,
  2317. 0, // reserved
  2318. &EnumerationContext,
  2319. Operation->OutputHandle );
  2320. break;
  2321. case AzoScopeDelete:
  2322. OpName = "AzScopeDelete";
  2323. WinStatus = AzScopeDelete(
  2324. *Operation->InputHandle,
  2325. Operation->Parameter1,
  2326. 0 ); // reserved
  2327. SubmitHandle = *Operation->InputHandle;
  2328. break;
  2329. //
  2330. // Group APIs
  2331. //
  2332. case AzoGroupCreate:
  2333. OpName = "AzGroupCreate";
  2334. WinStatus = AzGroupCreate(
  2335. *Operation->InputHandle,
  2336. Operation->Parameter1,
  2337. 0, // reserved
  2338. Operation->OutputHandle );
  2339. SubmitHandle = *Operation->OutputHandle;
  2340. break;
  2341. case AzoGroupOpen:
  2342. OpName = "AzGroupOpen";
  2343. WinStatus = AzGroupOpen(
  2344. *Operation->InputHandle,
  2345. Operation->Parameter1,
  2346. 0, // reserved
  2347. Operation->OutputHandle );
  2348. break;
  2349. case AzoGroupEnum:
  2350. OpName = "AzGroupEnum";
  2351. WinStatus = AzGroupEnum(
  2352. *Operation->InputHandle,
  2353. 0, // reserved
  2354. &EnumerationContext,
  2355. Operation->OutputHandle );
  2356. break;
  2357. case AzoGroupDelete:
  2358. OpName = "AzGroupDelete";
  2359. WinStatus = AzGroupDelete(
  2360. *Operation->InputHandle,
  2361. Operation->Parameter1,
  2362. 0 ); // reserved
  2363. SubmitHandle = *Operation->InputHandle;
  2364. break;
  2365. //
  2366. // Role APIs
  2367. //
  2368. case AzoRoleCreate:
  2369. OpName = "AzRoleCreate";
  2370. WinStatus = AzRoleCreate(
  2371. *Operation->InputHandle,
  2372. Operation->Parameter1,
  2373. 0, // reserved
  2374. Operation->OutputHandle );
  2375. SubmitHandle = *Operation->OutputHandle;
  2376. break;
  2377. case AzoRoleOpen:
  2378. OpName = "AzRoleOpen";
  2379. WinStatus = AzRoleOpen(
  2380. *Operation->InputHandle,
  2381. Operation->Parameter1,
  2382. 0, // reserved
  2383. Operation->OutputHandle );
  2384. break;
  2385. case AzoRoleEnum:
  2386. OpName = "AzRoleEnum";
  2387. WinStatus = AzRoleEnum(
  2388. *Operation->InputHandle,
  2389. 0, // reserved
  2390. &EnumerationContext,
  2391. Operation->OutputHandle );
  2392. break;
  2393. case AzoRoleDelete:
  2394. OpName = "AzRoleDelete";
  2395. WinStatus = AzRoleDelete(
  2396. *Operation->InputHandle,
  2397. Operation->Parameter1,
  2398. 0 ); // reserved
  2399. SubmitHandle = *Operation->InputHandle;
  2400. break;
  2401. //
  2402. // ClientContext APIs
  2403. //
  2404. case AzoInitCFT:
  2405. OpName = "AzInitializeContextFromToken";
  2406. WinStatus = AzInitializeContextFromToken(
  2407. *Operation->InputHandle,
  2408. (HANDLE)*Operation->Parameter1,
  2409. 0, // reserved
  2410. Operation->OutputHandle );
  2411. break;
  2412. case AzoAccess:
  2413. OpName = "AzContextAccessCheck";
  2414. ScopeNames[0] = Operation->Parameter1;
  2415. WinStatus = AzContextAccessCheck(
  2416. *Operation->InputHandle,
  2417. L"FredObject",
  2418. (*ScopeNames == NULL)?0:1, // ScopeCount
  2419. (*ScopeNames == NULL)? NULL : ScopeNames,
  2420. Operation->PropertyId, // OperationCount
  2421. (PULONG)Operation->OutputHandle,// Operations
  2422. Results,
  2423. NULL,
  2424. NULL,
  2425. NULL,
  2426. NULL,
  2427. NULL,
  2428. NULL );
  2429. break;
  2430. case AzoClose:
  2431. //
  2432. // If this is the close of the admin manager object,
  2433. // close my corresponding handle, too
  2434. //
  2435. if ( SavedGlobalAdminManagerHandle != NULL &&
  2436. *Operation->InputHandle == SavedGlobalAdminManagerHandle ) {
  2437. TempWinStatus = AzCloseHandle( GlobalAdminManagerHandle, 0 );
  2438. if (TempWinStatus != NO_ERROR ) {
  2439. PrintIndent( Indentation+4, TRUE );
  2440. RetVal = FALSE;
  2441. printf( "Cannot AzCloseHandle on refresh database. %ld\n", TempWinStatus );
  2442. }
  2443. GlobalAdminManagerHandle = NULL;
  2444. SavedGlobalAdminManagerHandle = NULL;
  2445. }
  2446. OpName = "AzCloseHandle";
  2447. WinStatus = AzCloseHandle(
  2448. *Operation->InputHandle,
  2449. 0 ); // reserved
  2450. break;
  2451. // Pseudo function test links between objects
  2452. case AzoTestLink:
  2453. OpName = "TestLink";
  2454. // Handle to the parent of the object being linked from
  2455. TestLinkHandleP = *Operation->InputHandle;
  2456. // Handle to the object being linked from
  2457. TestLinkHandleA = *Operation->OutputHandle;
  2458. // PropId to use for all set/get property
  2459. TestLinkPropId = PropertyId;
  2460. // Opcode offset to use for linked-to objects
  2461. TestLinkOpcodeOffset = Operation->ExpectedStatus;
  2462. // Name of the object being linked from
  2463. wcscpy(TestLinkObjectName, Operation->ExpectedParameter1);
  2464. WinStatus = Operation->ExpectedStatus;
  2465. //
  2466. // Build a new echo prefix
  2467. //
  2468. strcpy( BigBuffer, EchoPrefix );
  2469. strcat( BigBuffer, "->" );
  2470. strcat( BigBuffer, (LPSTR)Operation->Parameter1 );
  2471. //
  2472. // Print a description of the operation
  2473. //
  2474. if ( !Silent ) {
  2475. PrintIndent( Indentation, FALSE );
  2476. printf( "\n%s - Test linking '%s' objects to the object named '%ws' using propid '%ld'.\n",
  2477. BigBuffer,
  2478. Operation->Parameter1,
  2479. TestLinkObjectName,
  2480. TestLinkPropId );
  2481. }
  2482. UpdateCache = FALSE;
  2483. break;
  2484. // Pseudo function to duplicate a handle
  2485. case AzoDupHandle:
  2486. OpName = "DupHandle";
  2487. *Operation->OutputHandle = *Operation->InputHandle;
  2488. WinStatus = NO_ERROR;
  2489. UpdateCache = FALSE;
  2490. break;
  2491. // Pseudo function to execute a "subroutine" of operations
  2492. case AzoGoSub:
  2493. OpName = "GoSub";
  2494. WinStatus = NO_ERROR;
  2495. UpdateCache = FALSE;
  2496. break;
  2497. // Pseudo function to echo text to stdout
  2498. case AzoSleep:
  2499. SleepTime = Operation->PropertyId;
  2500. /* Drop through */
  2501. case AzoEcho:
  2502. OpName = BigBuffer;
  2503. strcpy( OpName, "\n");
  2504. if ( EchoPrefix ) {
  2505. strcat( OpName, EchoPrefix );
  2506. strcat( OpName, " -" );
  2507. }
  2508. WinStatus = NO_ERROR;
  2509. UpdateCache = FALSE;
  2510. break;
  2511. default:
  2512. OpName = "<Unknown>";
  2513. PrintIndent( Indentation+4, TRUE );
  2514. RetVal = FALSE;
  2515. printf( "Need to fix test app to handle a new opcode: %ld\n", Opcode );
  2516. WinStatus = Operation->ExpectedStatus;
  2517. break;
  2518. }
  2519. //
  2520. // Print the operation
  2521. //
  2522. if ( FirstIteration ) {
  2523. if ( Opcode != AzoTestLink ) {
  2524. if ( !Silent ) {
  2525. PrintIndent( Indentation, FALSE );
  2526. printf( "%s ", OpName );
  2527. }
  2528. if ( Operation->Parameter1 != NULL ) {
  2529. LPWSTR TempString;
  2530. switch ( PropType ) {
  2531. case ENUM_AZ_NONE:
  2532. case ENUM_AZ_BSTR:
  2533. case ENUM_AZ_BSTR_ARRAY:
  2534. if ( !Silent ) {
  2535. printf( "'%ws' ", Operation->Parameter1 );
  2536. }
  2537. break;
  2538. case ENUM_AZ_LONG:
  2539. case ENUM_AZ_BOOL:
  2540. if ( !Silent ) {
  2541. printf( "'%ld' ", *(PULONG)Operation->Parameter1 );
  2542. }
  2543. break;
  2544. case ENUM_AZ_SID_ARRAY:
  2545. if ( !ConvertSidToStringSidW( (PSID)Operation->Parameter1,
  2546. &TempString ) ) {
  2547. PrintIndent( Indentation+4, TRUE );
  2548. RetVal = FALSE;
  2549. printf( "Cannot convert sid.\n" );
  2550. } else {
  2551. if ( !Silent ) {
  2552. printf( "'%ws'", TempString );
  2553. }
  2554. }
  2555. break;
  2556. default:
  2557. if ( !Silent ) {
  2558. printf( "%ld '%ws' ", PropType, Operation->Parameter1 );
  2559. }
  2560. ASSERT(FALSE);
  2561. }
  2562. }
  2563. if ( PropertyId != 0 ) {
  2564. if ( !Silent ) {
  2565. printf( "(%ld) ", PropertyId );
  2566. }
  2567. }
  2568. if ( Operation->ExpectedStatus != NO_ERROR ) {
  2569. if ( !Silent ) {
  2570. printf("(");
  2571. PrintStatus( Operation->ExpectedStatus );
  2572. printf(") ");
  2573. }
  2574. }
  2575. if ( !Silent ) {
  2576. printf( "\n" );
  2577. }
  2578. if ( SleepTime != 0 ) {
  2579. ULONG t;
  2580. PrintIndent( Indentation, FALSE );
  2581. printf( "Sleeping %ld seconds", SleepTime );
  2582. for ( t=0;t<SleepTime;t++) {
  2583. printf(".");
  2584. Sleep(1000);
  2585. }
  2586. printf("\n");
  2587. }
  2588. }
  2589. }
  2590. FirstIteration = FALSE;
  2591. //
  2592. // Handle ERROR_NO_MORE_ITEMS/NO_ERROR mapping
  2593. //
  2594. RealWinStatus = WinStatus;
  2595. if ( Operation->EnumOperations != NULL ) {
  2596. if ( WinStatus == ERROR_NO_MORE_ITEMS ) {
  2597. WinStatus = NO_ERROR;
  2598. }
  2599. }
  2600. //
  2601. // Ensure we got the right status code
  2602. //
  2603. if ( WinStatus != Operation->ExpectedStatus ) {
  2604. PrintIndent( Indentation+4, TRUE );
  2605. RetVal = FALSE;
  2606. printf( "Returned '" );
  2607. PrintStatus( WinStatus );
  2608. printf( "' instead of '");
  2609. PrintStatus( Operation->ExpectedStatus );
  2610. printf( "'");
  2611. printf( "\n" );
  2612. break;
  2613. }
  2614. //
  2615. // Do GetProperty specific code
  2616. //
  2617. if ( WinStatus == NO_ERROR && WasGetProperty ) {
  2618. //
  2619. // Print the property
  2620. //
  2621. switch ( PropType ) {
  2622. case ENUM_AZ_BSTR:
  2623. if ( PropertyValue == NULL ) {
  2624. PrintIndent( Indentation+4, TRUE );
  2625. RetVal = FALSE;
  2626. printf( "<NULL>\n", PropertyValue );
  2627. } else {
  2628. if ( !Silent ) {
  2629. PrintIndent( Indentation+4, FALSE );
  2630. printf( "'%ws'\n", PropertyValue );
  2631. }
  2632. }
  2633. //
  2634. // Check if that value is expected
  2635. //
  2636. if ( Operation->ExpectedParameter1 != NULL &&
  2637. (PropertyValue == NULL ||
  2638. _wcsicmp( Operation->ExpectedParameter1, PropertyValue) != 0 )) {
  2639. PrintIndent( Indentation+4, TRUE );
  2640. RetVal = FALSE;
  2641. printf( "Expected '%ws' instead of '%ws'\n", Operation->ExpectedParameter1, PropertyValue );
  2642. }
  2643. break;
  2644. case ENUM_AZ_BSTR_ARRAY:
  2645. StringArray1 = (PAZ_STRING_ARRAY) PropertyValue;;
  2646. if ( PropertyValue == NULL ) {
  2647. PrintIndent( Indentation+4, TRUE );
  2648. RetVal = FALSE;
  2649. printf( "<NULL>\n", PropertyValue );
  2650. } else {
  2651. for ( i=0; i<StringArray1->StringCount; i++ ) {
  2652. if ( !Silent ) {
  2653. PrintIndent( Indentation+4, FALSE );
  2654. printf( "'%ws'\n", StringArray1->Strings[i] );
  2655. }
  2656. }
  2657. }
  2658. //
  2659. // Check if that value is expected
  2660. //
  2661. if ( Operation->ExpectedParameter1 != NULL ) {
  2662. StringArray2 = (PAZ_STRING_ARRAY)Operation->ExpectedParameter1;
  2663. if ( StringArray1->StringCount != StringArray2->StringCount ) {
  2664. PrintIndent( Indentation+4, TRUE );
  2665. RetVal = FALSE;
  2666. printf( "Expected '%ld' strings instead of '%ld' strings\n", StringArray2->StringCount, StringArray1->StringCount );
  2667. } else {
  2668. for ( i=0; i<StringArray1->StringCount; i++ ) {
  2669. if ( wcscmp( StringArray1->Strings[i], StringArray2->Strings[i]) != 0 ) {
  2670. PrintIndent( Indentation+4, TRUE );
  2671. RetVal = FALSE;
  2672. printf( "Expected string %ld to be '%ws' instead of '%ws'\n",
  2673. i,
  2674. StringArray2->Strings[i],
  2675. StringArray1->Strings[i] );
  2676. }
  2677. }
  2678. }
  2679. }
  2680. break;
  2681. case ENUM_AZ_LONG:
  2682. case ENUM_AZ_BOOL:
  2683. if ( PropertyValue == NULL ) {
  2684. PrintIndent( Indentation+4, TRUE );
  2685. RetVal = FALSE;
  2686. printf( "<NULL>\n", PropertyValue );
  2687. } else {
  2688. if ( !Silent ) {
  2689. PrintIndent( Indentation+4, FALSE );
  2690. printf( "'%ld'\n", *(PULONG)PropertyValue );
  2691. }
  2692. }
  2693. //
  2694. // Check if that value is expected
  2695. //
  2696. if ( *(PULONG)(Operation->ExpectedParameter1) != *(PULONG)PropertyValue ) {
  2697. PrintIndent( Indentation+4, TRUE );
  2698. RetVal = FALSE;
  2699. printf( "Expected '%ld' instead of '%ld'\n",
  2700. *(PULONG)(Operation->ExpectedParameter1),
  2701. *(PULONG)PropertyValue );
  2702. }
  2703. break;
  2704. case ENUM_AZ_SID_ARRAY:
  2705. SidArray1 = (PAZ_SID_ARRAY) PropertyValue;;
  2706. if ( PropertyValue == NULL ) {
  2707. PrintIndent( Indentation+4, TRUE );
  2708. RetVal = FALSE;
  2709. printf( "<NULL>\n" );
  2710. } else {
  2711. LPWSTR TempString;
  2712. for ( i=0; i<SidArray1->SidCount; i++ ) {
  2713. if ( !Silent ) {
  2714. PrintIndent( Indentation+4, FALSE );
  2715. }
  2716. if ( !ConvertSidToStringSidW( SidArray1->Sids[i],
  2717. &TempString ) ) {
  2718. PrintIndent( Indentation+4, TRUE );
  2719. RetVal = FALSE;
  2720. printf( "Cannot convert sid.\n" );
  2721. } else {
  2722. if ( !Silent ) {
  2723. printf( "'%ws'\n", TempString );
  2724. }
  2725. }
  2726. }
  2727. }
  2728. //
  2729. // Check if that value is expected
  2730. //
  2731. if ( Operation->ExpectedParameter1 != NULL ) {
  2732. SidArray2 = (PAZ_SID_ARRAY)Operation->ExpectedParameter1;
  2733. if ( SidArray1->SidCount != SidArray2->SidCount ) {
  2734. PrintIndent( Indentation+4, TRUE );
  2735. RetVal = FALSE;
  2736. printf( "Expected '%ld' sids instead of '%ld' sids\n", SidArray2->SidCount, SidArray1->SidCount );
  2737. } else {
  2738. for ( i=0; i<SidArray1->SidCount; i++ ) {
  2739. if ( !EqualSid( SidArray1->Sids[i], SidArray2->Sids[i]) ) {
  2740. LPWSTR TempString1;
  2741. LPWSTR TempString2;
  2742. if ( !ConvertSidToStringSidW( SidArray1->Sids[i],
  2743. &TempString1 ) ) {
  2744. PrintIndent( Indentation+4, TRUE );
  2745. RetVal = FALSE;
  2746. printf( "Cannot convert sid.\n" );
  2747. continue;
  2748. }
  2749. if ( !ConvertSidToStringSidW( SidArray2->Sids[i],
  2750. &TempString2 ) ) {
  2751. PrintIndent( Indentation+4, TRUE );
  2752. RetVal = FALSE;
  2753. printf( "Cannot convert sid.\n" );
  2754. continue;
  2755. }
  2756. PrintIndent( Indentation+4, TRUE );
  2757. RetVal = FALSE;
  2758. printf( "Expected string %ld to be '%ws' instead of '%ws'\n",
  2759. i,
  2760. TempString2,
  2761. TempString1 );
  2762. }
  2763. }
  2764. }
  2765. }
  2766. break;
  2767. default:
  2768. ASSERT(FALSE);
  2769. }
  2770. //
  2771. // Free the returned buffer
  2772. //
  2773. AzFreeMemory( PropertyValue );
  2774. }
  2775. //
  2776. // Submit the changes to the database
  2777. //
  2778. if ( WinStatus == NO_ERROR &&
  2779. SubmitHandle != INVALID_HANDLE_VALUE &&
  2780. SubmitOk ) {
  2781. WinStatus = AzSubmit( SubmitHandle,
  2782. SubmitFlags,
  2783. 0); // reserved
  2784. if ( WinStatus != NO_ERROR ) {
  2785. PrintIndent( Indentation+4, TRUE );
  2786. RetVal = FALSE;
  2787. printf( "AzSubmit failed: " );
  2788. PrintStatus( WinStatus );
  2789. printf( "\n" );
  2790. }
  2791. }
  2792. //
  2793. // Update the cache on our parallel admin manager handle
  2794. //
  2795. if ( UpdateCache && GlobalAdminManagerHandle != NULL ) {
  2796. TempWinStatus = AzUpdateCache( GlobalAdminManagerHandle );
  2797. if ( TempWinStatus != NO_ERROR ) {
  2798. PrintIndent( Indentation+4, TRUE );
  2799. RetVal = FALSE;
  2800. printf( "AzUpdateCache failed: " );
  2801. PrintStatus( TempWinStatus );
  2802. printf( "\n" );
  2803. }
  2804. }
  2805. //
  2806. // Execute a "subroutine" of operations
  2807. //
  2808. if ( Opcode == AzoGoSub ) {
  2809. if (!DoOperations( Operation->EnumOperations, Indentation + 4, SpecificOpcodeOffset, EchoPrefix ) ) {
  2810. RetVal = FALSE;
  2811. }
  2812. //
  2813. // Execute a the special TestLink "subroutine" of operations
  2814. //
  2815. } else if ( Opcode == AzoTestLink ) {
  2816. if (!DoOperations( Operation->EnumOperations, Indentation + 4, SpecificOpcodeOffset, BigBuffer ) ) {
  2817. RetVal = FALSE;
  2818. }
  2819. TestLinkPropId = 0;
  2820. //
  2821. // Check the results of an access check
  2822. //
  2823. } else if ( Opcode == AzoAccess && WinStatus == NO_ERROR ) {
  2824. for ( i=0; i<Operation->PropertyId; i++ ) {
  2825. if ( ((PULONG)(Operation->ExpectedParameter1))[i] != Results[i] ) {
  2826. PrintIndent( Indentation+4, TRUE );
  2827. RetVal = FALSE;
  2828. printf("Operation %ld: Expected '",
  2829. ((PULONG)(Operation->OutputHandle))[i] );
  2830. PrintStatus( ((PULONG)(Operation->ExpectedParameter1))[i] );
  2831. printf("' instead of '" );
  2832. PrintStatus( Results[i] );
  2833. printf("'\n");
  2834. }
  2835. }
  2836. //
  2837. // Do enumeration specific code
  2838. //
  2839. } else if ( Operation->EnumOperations != NULL && RealWinStatus == NO_ERROR ) {
  2840. if ( !Silent ) {
  2841. PrintIndent( Indentation+4, FALSE );
  2842. printf( "%ld:\n", EnumerationContext );
  2843. }
  2844. if (!DoOperations( Operation->EnumOperations, Indentation + 8, SpecificOpcodeOffset, EchoPrefix ) ) {
  2845. RetVal = FALSE;
  2846. break;
  2847. }
  2848. continue;
  2849. }
  2850. //
  2851. // Do the next operation
  2852. //
  2853. EnumerationContext = 0;
  2854. FirstIteration = TRUE;
  2855. Operation++;
  2856. }
  2857. return RetVal;
  2858. }
  2859. DWORD
  2860. AzComInitialize(
  2861. OUT PBOOL ComState
  2862. )
  2863. /*++
  2864. Routine Description:
  2865. This routine initializes COM. If the caller uses the "C" api, the caller must initialize COM
  2866. in each thread before calling any other AZ api.
  2867. The calling must free all AZ handles before uninitializing COM.
  2868. Arguments:
  2869. State - State to pass to AzComUninitialize
  2870. Return Value:
  2871. NO_ERROR - The operation was successful.
  2872. The caller should call AzComUninitialize on this thread.
  2873. --*/
  2874. {
  2875. DWORD WinStatus = NO_ERROR;
  2876. HRESULT hr;
  2877. //
  2878. // Initialize COM
  2879. //
  2880. *ComState = FALSE;
  2881. hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  2882. if (hr == S_OK || hr == S_FALSE) {
  2883. *ComState = TRUE;
  2884. } else if (hr != RPC_E_CHANGED_MODE) {
  2885. WinStatus = hr;
  2886. }
  2887. return WinStatus;
  2888. }
  2889. VOID
  2890. AzComUninitialize(
  2891. IN BOOL ComState
  2892. )
  2893. /*++
  2894. Routine Description:
  2895. This routine un-initializes COM. It should be called once for each thread that successfully
  2896. calls AzComInitialize.
  2897. Arguments:
  2898. State - State returned from AzComInitialize
  2899. Return Value:
  2900. NO_ERROR - The operation was successful.
  2901. --*/
  2902. {
  2903. if ( ComState) {
  2904. CoUninitialize();
  2905. }
  2906. }
  2907. DWORD
  2908. AccessCheckThread(
  2909. LPVOID lpThreadParameter
  2910. )
  2911. /*++
  2912. Routine Description:
  2913. This routine implements a second thread to do access checks in.
  2914. The purpose of the thread is to test bizrules which behave differently if more than one thread is
  2915. executing the bizrule.
  2916. Arguments:
  2917. Not used.
  2918. Return Value:
  2919. NO_ERROR - The operation was successful.
  2920. --*/
  2921. {
  2922. DWORD WinStatus;
  2923. DWORD ComState;
  2924. BOOLEAN UseLdap = (BOOLEAN) lpThreadParameter;
  2925. Sleep( 60 );
  2926. WinStatus = AzComInitialize( &ComState );
  2927. if ( WinStatus != NO_ERROR ) {
  2928. printf( "Cannot cominitialize %ld\n", WinStatus );
  2929. goto Cleanup;
  2930. }
  2931. //
  2932. // Do AccessCheck specific tests
  2933. //
  2934. if ( !DoOperations( OpAccess1m, 0, 0, "Access1m" ) ) {
  2935. goto Cleanup;
  2936. }
  2937. {
  2938. DWORD Ticks;
  2939. ULONG i;
  2940. Ticks = GetTickCount();
  2941. for ( i=0; i<900; i++ ) {
  2942. if ( UseLdap ) {
  2943. if ( !DoOperations( OpAccess2mLdap, 0, 0, "Access2mLdap" ) ) {
  2944. goto Cleanup;
  2945. }
  2946. } else {
  2947. if ( !DoOperations( OpAccess2m, 0, 0, "Access2m" ) ) {
  2948. goto Cleanup;
  2949. }
  2950. }
  2951. // Sleep a bit to allow other thread a change to use our cached script
  2952. Sleep(10);
  2953. }
  2954. Ticks = GetTickCount() - Ticks;
  2955. printf( "%ld milliseconds\n", Ticks );
  2956. }
  2957. if ( !DoOperations( OpAccess3m, 0, 0, "Access3m" ) ) {
  2958. goto Cleanup;
  2959. }
  2960. Cleanup:
  2961. AzComUninitialize( ComState );
  2962. return NO_ERROR;
  2963. }
  2964. DWORD
  2965. BizRuleChangeThread(
  2966. LPVOID lpThreadParameter
  2967. )
  2968. /*++
  2969. Routine Description:
  2970. This routine implements a second thread to change the bizrule while access check is using it.
  2971. Arguments:
  2972. Not used.
  2973. Return Value:
  2974. NO_ERROR - The operation was successful.
  2975. --*/
  2976. {
  2977. DWORD WinStatus;
  2978. DWORD ComState;
  2979. ULONG i;
  2980. WinStatus = AzComInitialize( &ComState );
  2981. if ( WinStatus != NO_ERROR ) {
  2982. printf( "Cannot cominitialize %ld\n", WinStatus );
  2983. goto Cleanup;
  2984. }
  2985. //
  2986. // Do this several times to allow it to interfere with the main thread in several places
  2987. //
  2988. for ( i=0; i<100; i++ ) {
  2989. Sleep( 60 );
  2990. //
  2991. // Do Change bizrule specific tests
  2992. //
  2993. if ( !DoOperations( OpBizruleThread, 0, 0, "BizRuleThread" ) ) {
  2994. goto Cleanup;
  2995. }
  2996. }
  2997. Cleanup:
  2998. AzComUninitialize( ComState );
  2999. return NO_ERROR;
  3000. }
  3001. DWORD
  3002. GroupChangeThread(
  3003. LPVOID lpThreadParameter
  3004. )
  3005. /*++
  3006. Routine Description:
  3007. This routine implements a second thread to change a group membership while access check is using it.
  3008. Arguments:
  3009. Not used.
  3010. Return Value:
  3011. NO_ERROR - The operation was successful.
  3012. --*/
  3013. {
  3014. DWORD WinStatus;
  3015. DWORD ComState;
  3016. ULONG i;
  3017. WinStatus = AzComInitialize( &ComState );
  3018. if ( WinStatus != NO_ERROR ) {
  3019. printf( "Cannot cominitialize %ld\n", WinStatus );
  3020. goto Cleanup;
  3021. }
  3022. //
  3023. // Do this several times to allow it to interfere with the main thread in several places
  3024. //
  3025. for ( i=0; i<100; i++ ) {
  3026. Sleep( 60 );
  3027. //
  3028. // Do Change bizrule specific tests
  3029. //
  3030. if ( !DoOperations( OpGroupThread, 0, 0, "GroupThread" ) ) {
  3031. goto Cleanup;
  3032. }
  3033. }
  3034. Cleanup:
  3035. AzComUninitialize( ComState );
  3036. return NO_ERROR;
  3037. }
  3038. int __cdecl
  3039. main(
  3040. IN int argc,
  3041. IN char ** argv
  3042. )
  3043. /*++
  3044. Routine Description:
  3045. Test azroles.dll
  3046. Arguments:
  3047. argc - the number of command-line arguments.
  3048. argv - an array of pointers to the arguments.
  3049. Return Value:
  3050. Exit status
  3051. --*/
  3052. {
  3053. BOOL RetVal = TRUE;
  3054. DWORD WinStatus;
  3055. DWORD ComState;
  3056. ULONG TestNum;
  3057. ULONG Index;
  3058. ULONG Index2;
  3059. CHAR EchoPrefix[1024];
  3060. BOOLEAN TestFound;
  3061. BOOLEAN ObjectTests;
  3062. BOOLEAN ShareTests;
  3063. BOOLEAN PersistTests;
  3064. BOOLEAN AccessTests;
  3065. BOOLEAN SidxTests;
  3066. BOOLEAN CommonInit;
  3067. BOOLEAN ManyScopes;
  3068. BOOLEAN MultiAccessCheck;
  3069. BOOLEAN MultiThread;
  3070. BOOLEAN MultiLdap;
  3071. BOOLEAN BizruleMod;
  3072. BOOLEAN GroupMod;
  3073. BOOLEAN UseThreadToken;
  3074. BOOLEAN fPrintUsage = FALSE;
  3075. BOOLEAN AvoidDefaults;
  3076. LPSTR Argument;
  3077. ULONG TestIndex;
  3078. int ArgIndex;
  3079. struct {
  3080. LPSTR TestName;
  3081. BOOLEAN *EnableIt;
  3082. BOOLEAN IsDefault;
  3083. BOOLEAN AvoidDefaults;
  3084. LPSTR Description;
  3085. } Tests[] = {
  3086. { "/Object", &ObjectTests, TRUE, TRUE, "Run lots of tests on all objects" },
  3087. { "/Share", &ShareTests, TRUE, TRUE, "Test name sharing" },
  3088. { "/Persist", &PersistTests, TRUE, TRUE, "Test persistence" },
  3089. { "/Access", &AccessTests, TRUE, TRUE, "Test AccessCheck" },
  3090. { "/Sidx", &SidxTests, FALSE, TRUE, "Test a group with *lots* of Sids" },
  3091. { "/ManyScopes", &ManyScopes, FALSE, TRUE, "Test creating *lots* of scopes" },
  3092. { "/MultiAccess", &MultiAccessCheck, FALSE, TRUE, "Test many AccessChecks in a loop" },
  3093. { "/MultiThread", &MultiThread, FALSE, TRUE, "Test AccessCheck in multiple threads" },
  3094. { "/MultiLdap", &MultiLdap, FALSE, TRUE, "Test AccessCheck in multiple threads using LDAP query" },
  3095. { "/BizruleMod", &BizruleMod, FALSE, TRUE, "Test modifying a bizrule during AccessCheck" },
  3096. { "/GroupMod", &GroupMod, FALSE, TRUE, "Test modifying a group membership during AccessCheck" },
  3097. { "/ThreadToken", &UseThreadToken, FALSE, FALSE, "Use thread token for all access tests" },
  3098. { "/NoInitAll", &NoInitAllTests, FALSE, FALSE, "Skip AzInitialize before AzDelete" },
  3099. { "/NoUpdateCache", &NoUpdateCache, FALSE, FALSE, "Skip AzUpdateCache on every operation" },
  3100. { "/Silent", &Silent, FALSE, FALSE, "Be quieter to avoid affecting timing" },
  3101. };
  3102. #define TEST_COUNT (sizeof(Tests)/sizeof(Tests[0]))
  3103. //
  3104. // Objects that are children of "AdminManager"
  3105. //
  3106. DWORD GenAdmChildTests[] = { AzoApp, AzoGroup };
  3107. LPSTR GenAdmChildTestName[] = { "Application", "Group" };
  3108. POPERATION SpeAdmChildTestOps[] = { OpApplication, OpAdmGroup };
  3109. POPERATION GenAdmChildTestOps[] = { OpAdmChildGen, OpAdmChildGenDupName
  3110. #ifdef ENABLE_LEAK
  3111. , OpAdmChildGenLeak
  3112. #endif // ENABLE_LEAK
  3113. };
  3114. //
  3115. // Objects that are children of "Application"
  3116. //
  3117. DWORD GenAppChildTests[] = { AzoOp, AzoTask, AzoScope, AzoGroup, AzoRole };
  3118. LPSTR GenAppChildTestName[] = { "Operation", "Task", "Scope", "Group", "Role" };
  3119. POPERATION SpeAppChildTestOps[] = { OpOperation, OpAppTask, NULL, OpAppGroup, OpAppRole };
  3120. POPERATION GenAppChildTestOps[] = { OpAppChildGen, OpAppChildGenDupName };
  3121. //
  3122. // Objects that are children of "Scope"
  3123. //
  3124. DWORD GenScopeChildTests[] = { AzoGroup, AzoRole, AzoTask };
  3125. LPSTR GenScopeChildTestName[] = { "Group", "Role", "Task" };
  3126. POPERATION SpeScopeChildTestOps[] = { OpScopeGroup, OpScopeRole, OpScopeTask };
  3127. POPERATION GenScopeChildTestOps[] = { OpScopeChildGen, OpScopeChildGenDupName };
  3128. struct {
  3129. //
  3130. // Name of the parent object
  3131. LPSTR ParentName;
  3132. //
  3133. // List of children to test for this parent
  3134. DWORD ChildCount;
  3135. DWORD *ChildOpcodeOffsets;
  3136. LPSTR *ChildTestNames;
  3137. // Operation to perform that is specific to the child type
  3138. POPERATION *ChildOperations;
  3139. //
  3140. // List of tests to perform for each child type
  3141. //
  3142. DWORD OperationCount;
  3143. POPERATION *Operations;
  3144. } ParentChildTests[] = {
  3145. { "AdminManager",
  3146. sizeof(GenAdmChildTestName)/sizeof(GenAdmChildTestName[0]),
  3147. GenAdmChildTests,
  3148. GenAdmChildTestName,
  3149. SpeAdmChildTestOps,
  3150. sizeof(GenAdmChildTestOps)/sizeof(GenAdmChildTestOps[0]),
  3151. GenAdmChildTestOps },
  3152. { "Application",
  3153. sizeof(GenAppChildTestName)/sizeof(GenAppChildTestName[0]),
  3154. GenAppChildTests,
  3155. GenAppChildTestName,
  3156. SpeAppChildTestOps,
  3157. sizeof(GenAppChildTestOps)/sizeof(GenAppChildTestOps[0]),
  3158. GenAppChildTestOps },
  3159. { "Scope",
  3160. sizeof(GenScopeChildTestName)/sizeof(GenScopeChildTestName[0]),
  3161. GenScopeChildTests,
  3162. GenScopeChildTestName,
  3163. SpeScopeChildTestOps,
  3164. sizeof(GenScopeChildTestOps)/sizeof(GenScopeChildTestOps[0]),
  3165. GenScopeChildTestOps },
  3166. };
  3167. WinStatus = AzComInitialize( &ComState );
  3168. if ( WinStatus != NO_ERROR ) {
  3169. printf( "Cannot cominitialize %ld\n", WinStatus );
  3170. RetVal = FALSE;
  3171. goto Cleanup;
  3172. }
  3173. //
  3174. // Assume no tests should be run
  3175. //
  3176. for ( TestIndex=0; TestIndex<TEST_COUNT; TestIndex++ ) {
  3177. *(Tests[TestIndex].EnableIt) = FALSE;
  3178. }
  3179. if ( argc > 1 ) {
  3180. Argument = argv[1];
  3181. //
  3182. // Is this XML or AD store testing?
  3183. //
  3184. if ( !_strcmpi( Argument, "-ad" ) ) {
  3185. #ifdef ENABLE_ADMIN_ACCOUNT_AD
  3186. AzGlTestFile = L"msldap://CN=CliffV,OU=AzRoles,DC=cliffvdom,DC=nttest,DC=microsoft,DC=com";
  3187. #else // ENABLE_ADMIN_ACCOUNT_AD
  3188. AzGlTestFile = L"msldap://CN=Chaitu,OU=AzRoles,DC=chaitu-dom3602,DC=nttest,DC=microsoft,DC=com";
  3189. #endif // ENABLE_ADMIN_ACCOUNT_AD
  3190. } else if ( !_strcmpi( Argument, "-xml" ) ) {
  3191. AzGlTestFile = L"msxml://.//TestFile.xml";
  3192. // Delete the testfile
  3193. DeleteFileW( L".\\TestFile.xml" );
  3194. } else {
  3195. fPrintUsage = TRUE;
  3196. goto Usage;
  3197. }
  3198. } else {
  3199. fPrintUsage = TRUE;
  3200. goto Usage;
  3201. }
  3202. //
  3203. // Parse the command line options
  3204. //
  3205. AvoidDefaults = FALSE;
  3206. for ( ArgIndex=2; ArgIndex<argc; ArgIndex++ ) {
  3207. Argument = argv[ArgIndex];
  3208. //
  3209. // Loop through the list of valid values
  3210. //
  3211. for ( TestIndex=0; TestIndex<TEST_COUNT; TestIndex++ ) {
  3212. //
  3213. // If found, set the boolean
  3214. //
  3215. if ( _strcmpi( Argument, Tests[TestIndex].TestName) == 0 ) {
  3216. *(Tests[TestIndex].EnableIt) = TRUE;
  3217. if ( Tests[TestIndex].AvoidDefaults ) {
  3218. AvoidDefaults = TRUE;
  3219. }
  3220. break;
  3221. }
  3222. }
  3223. //
  3224. // If typo,
  3225. // complain
  3226. //
  3227. if ( TestIndex >= TEST_COUNT ) {
  3228. fPrintUsage = TRUE;
  3229. goto Usage;
  3230. }
  3231. }
  3232. //
  3233. // If no options were specified,
  3234. // use the defaults.
  3235. //
  3236. if ( !AvoidDefaults ) {
  3237. for ( TestIndex=0; TestIndex<TEST_COUNT; TestIndex++ ) {
  3238. if ( Tests[TestIndex].IsDefault) {
  3239. *(Tests[TestIndex].EnableIt) = TRUE;
  3240. }
  3241. }
  3242. }
  3243. //
  3244. // Run the generic object tests
  3245. //
  3246. if ( ObjectTests ) {
  3247. //
  3248. // Do admin manager specific tests
  3249. //
  3250. if ( !DoOperations( OpAdm, 0, 0, "AdminManager" ) ) {
  3251. RetVal = FALSE;
  3252. goto Cleanup;
  3253. }
  3254. //
  3255. // Loop for each object that can be the parent of another object
  3256. //
  3257. for ( TestNum=0; TestNum < sizeof(ParentChildTests)/sizeof(ParentChildTests[0]); TestNum++ ) {
  3258. //
  3259. // Loop for each child of the parent object
  3260. //
  3261. for ( Index=0; Index < ParentChildTests[TestNum].ChildCount; Index ++ ) {
  3262. //
  3263. // output the test name
  3264. //
  3265. strcpy( EchoPrefix, ParentChildTests[TestNum].ParentName );
  3266. strcat( EchoPrefix, "->" );
  3267. strcat( EchoPrefix, ParentChildTests[TestNum].ChildTestNames[Index] );
  3268. if ( !Silent ) {
  3269. printf("\n%s - Perform tests of '%s' objects that are children of '%s' objects\n",
  3270. EchoPrefix,
  3271. ParentChildTests[TestNum].ChildTestNames[Index],
  3272. ParentChildTests[TestNum].ParentName );
  3273. }
  3274. //
  3275. // Do the various generic tests that apply to all objects
  3276. //
  3277. for ( Index2=0; Index2 < ParentChildTests[TestNum].OperationCount; Index2 ++ ) {
  3278. if ( !DoOperations(
  3279. ParentChildTests[TestNum].Operations[Index2],
  3280. 0,
  3281. ParentChildTests[TestNum].ChildOpcodeOffsets[Index],
  3282. EchoPrefix ) ) {
  3283. RetVal = FALSE;
  3284. goto Cleanup;
  3285. }
  3286. }
  3287. //
  3288. // Do the one test that is specific to this parent/child relationship
  3289. //
  3290. if ( ParentChildTests[TestNum].ChildOperations[Index] == NULL ) {
  3291. // ??? Should complain here. Test is missing
  3292. } else {
  3293. if ( !DoOperations(
  3294. ParentChildTests[TestNum].ChildOperations[Index],
  3295. 0,
  3296. ParentChildTests[TestNum].ChildOpcodeOffsets[Index],
  3297. EchoPrefix ) ) {
  3298. RetVal = FALSE;
  3299. goto Cleanup;
  3300. }
  3301. }
  3302. }
  3303. }
  3304. }
  3305. //
  3306. // Do name sharing specific tests
  3307. //
  3308. if ( ShareTests ) {
  3309. if ( !DoOperations( OpShare, 0, 0, "NameShare" ) ) {
  3310. RetVal = FALSE;
  3311. goto Cleanup;
  3312. }
  3313. }
  3314. //
  3315. // Do peristence specific tests
  3316. //
  3317. if ( PersistTests ) {
  3318. if ( !DoOperations( OpPersist, 0, 0, "Persist" ) ) {
  3319. RetVal = FALSE;
  3320. goto Cleanup;
  3321. }
  3322. }
  3323. //
  3324. // Grab my token
  3325. //
  3326. if ( UseThreadToken ) {
  3327. if ( !OpenProcessToken( GetCurrentProcess(),
  3328. TOKEN_QUERY | TOKEN_IMPERSONATE | TOKEN_DUPLICATE,
  3329. &TokenHandle ) ) {
  3330. printf( "Cannot OpenProcessToken %ld\n", GetLastError() );
  3331. RetVal = FALSE;
  3332. goto Cleanup;
  3333. }
  3334. }
  3335. //
  3336. // Do AccessCheck specific tests
  3337. //
  3338. if ( AccessTests ) {
  3339. if ( !DoOperations( OpAccess, 0, 0, "Access" ) ) {
  3340. RetVal = FALSE;
  3341. goto Cleanup;
  3342. }
  3343. }
  3344. //
  3345. // Is this one of the tests that need common initialization?
  3346. //
  3347. CommonInit = FALSE;
  3348. if ( SidxTests || ManyScopes || MultiAccessCheck || MultiThread || MultiLdap || BizruleMod || GroupMod ) {
  3349. CommonInit = TRUE;
  3350. }
  3351. if ( CommonInit ) {
  3352. if ( !DoOperations( OpAccessBegin, 0, 0, "AccessBegin" ) ) {
  3353. RetVal = FALSE;
  3354. goto Cleanup;
  3355. }
  3356. }
  3357. //
  3358. // Create oodles of scope objects
  3359. //
  3360. if ( ManyScopes ) {
  3361. DWORD OrigTicks;
  3362. DWORD PrevTicks;
  3363. DWORD Ticks;
  3364. ULONG i;
  3365. OrigTicks = GetTickCount();
  3366. PrevTicks = OrigTicks;
  3367. for ( i=0; i<10000; i++) {
  3368. swprintf( ScopeBillions, L"Multi-Scope %ld", i );
  3369. if ( !DoOperations( OpBillions, 0, 0, "Billions" ) ) {
  3370. RetVal = FALSE;
  3371. goto Cleanup;
  3372. }
  3373. Ticks = GetTickCount();
  3374. printf( "%ld milliseconds\n", Ticks - PrevTicks );
  3375. PrevTicks = Ticks;
  3376. }
  3377. printf( "%ld milliseconds\n", GetTickCount() - OrigTicks );
  3378. }
  3379. //
  3380. // Test running access check in multiple threads
  3381. //
  3382. if ( MultiThread || MultiLdap ) {
  3383. // Fire off another thread
  3384. if ( !QueueUserWorkItem( AccessCheckThread, (PVOID)MultiLdap, 0 ) ) {
  3385. RetVal = FALSE;
  3386. goto Cleanup;
  3387. }
  3388. }
  3389. //
  3390. // Fire off a thread to change the bizrule on a task being used to access check
  3391. //
  3392. if ( BizruleMod ) {
  3393. if ( !QueueUserWorkItem( BizRuleChangeThread, NULL, 0 ) ) {
  3394. RetVal = FALSE;
  3395. goto Cleanup;
  3396. }
  3397. }
  3398. //
  3399. // Fire off a thread to change a group being used to access check
  3400. //
  3401. if ( GroupMod ) {
  3402. if ( !QueueUserWorkItem( GroupChangeThread, NULL, 0 ) ) {
  3403. RetVal = FALSE;
  3404. goto Cleanup;
  3405. }
  3406. }
  3407. //
  3408. // Do the tests the are designed to conflict with the above ASYNC operations
  3409. //
  3410. if ( MultiAccessCheck || MultiThread || MultiLdap || BizruleMod || GroupMod ) {
  3411. DWORD Ticks;
  3412. ULONG i;
  3413. Ticks = GetTickCount();
  3414. for ( i=0; i<1000; i++ ) {
  3415. if ( MultiLdap ) {
  3416. if ( !DoOperations( OpAccess2Ldap, 0, 0, "Access2Ldap" ) ) {
  3417. RetVal = FALSE;
  3418. goto Cleanup;
  3419. }
  3420. } else {
  3421. if ( !DoOperations( OpAccess2, 0, 0, "Access2" ) ) {
  3422. RetVal = FALSE;
  3423. goto Cleanup;
  3424. }
  3425. }
  3426. // Sleep a bit to allow other thread a chance to run
  3427. if ( !MultiAccessCheck ) {
  3428. Sleep(20);
  3429. }
  3430. }
  3431. Ticks = GetTickCount() - Ticks;
  3432. printf( "%ld milliseconds\n", Ticks );
  3433. }
  3434. //
  3435. // Create a group with a *lot* of sids
  3436. //
  3437. if ( SidxTests ) {
  3438. ULONG i;
  3439. PSID Sid = (PSID)SidX;
  3440. SID_IDENTIFIER_AUTHORITY Ia = SECURITY_WORLD_SID_AUTHORITY;
  3441. if ( !DoOperations( OpSidxBegin, 0, 0, "SidxBegin" ) ) {
  3442. RetVal = FALSE;
  3443. goto Cleanup;
  3444. }
  3445. for ( i=0; i<1000; i++ ) {
  3446. //
  3447. // Add the everyone sid at an opportune spot
  3448. //
  3449. if ( i == 9999 ) {
  3450. #if 0
  3451. RtlCopyMemory( Sid, &SidWorld, GetLengthSid( &SidWorld ) );
  3452. #else // 0
  3453. RtlCopyMemory( Sid, &SidLocal, GetLengthSid( &SidLocal ) );
  3454. #endif // 0
  3455. } else {
  3456. DWORD j;
  3457. //
  3458. // Build a huge sid that no-one has
  3459. //
  3460. #define AuthorityCount SID_MAX_SUB_AUTHORITIES
  3461. if ( !InitializeSid( Sid, &Ia, AuthorityCount )) {
  3462. RetVal = FALSE;
  3463. goto Cleanup;
  3464. }
  3465. for ( j=0; j<AuthorityCount; j++ ) {
  3466. *GetSidSubAuthority( Sid, j ) = j+1;
  3467. }
  3468. // Set a different sid each time
  3469. *GetSidSubAuthority( Sid, AuthorityCount-1) = i;
  3470. }
  3471. if ( !DoOperations( OpSidx, 0, 0, "Sidx" ) ) {
  3472. RetVal = FALSE;
  3473. goto Cleanup;
  3474. }
  3475. }
  3476. if ( !DoOperations( OpSidxEnd, 0, 0, "SidxEnd" ) ) {
  3477. RetVal = FALSE;
  3478. goto Cleanup;
  3479. }
  3480. }
  3481. //
  3482. // The common initialization requires common rundown
  3483. //
  3484. if ( CommonInit ) {
  3485. if ( !DoOperations( OpAccessEnd, 0, 0, "AccessEnd" ) ) {
  3486. RetVal = FALSE;
  3487. goto Cleanup;
  3488. }
  3489. }
  3490. //
  3491. // print usage
  3492. //
  3493. Usage:
  3494. if ( fPrintUsage ) {
  3495. fprintf( stderr, "Usage: aztest <store> [<options>]\n" );
  3496. fprintf( stderr, "\nWhere <store> is:\n\n" );
  3497. fprintf( stderr, " -xml: Do XML provider testing\n" );
  3498. fprintf( stderr, " -ad : Do Active directory provider testing\n");
  3499. fprintf( stderr, "\nAnd where <options> are:\n\n" );
  3500. for ( TestIndex=0; TestIndex<TEST_COUNT; TestIndex++ ) {
  3501. fprintf( stderr, " %s - %s\n", Tests[TestIndex].TestName, Tests[TestIndex].Description );
  3502. }
  3503. fprintf( stderr, "\nIf no options are specified, the following are implied:\n\n " );
  3504. for ( TestIndex=0; TestIndex<TEST_COUNT; TestIndex++ ) {
  3505. if ( Tests[TestIndex].IsDefault) {
  3506. fprintf( stderr, "%s ", Tests[TestIndex].TestName );
  3507. }
  3508. }
  3509. fprintf( stderr, "\n" );
  3510. return 1;
  3511. }
  3512. //
  3513. // Done
  3514. //
  3515. Cleanup:
  3516. AzComUninitialize( ComState );
  3517. printf( "\n\n" );
  3518. if ( RetVal ) {
  3519. printf( "Tests completed successfully!\n");
  3520. return 0;
  3521. } else {
  3522. printf( "One or more tests failed.\n");
  3523. return 1;
  3524. }
  3525. }