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.

347 lines
9.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: lkp.cxx
  8. //
  9. //--------------------------------------------------------------------------
  10. // drt that tries to lookup the various things.
  11. #include "drt.hxx"
  12. RPC_STATUS LookupCountAndPrint(RPC_NS_HANDLE NsHandle, int exp)
  13. {
  14. int i=0;
  15. RPC_STATUS status = 0;
  16. RPC_BINDING_VECTOR * pBindingVec;
  17. WCHAR * szBinding;
  18. for (;!status;) {
  19. status = RpcNsBindingLookupNext(
  20. NsHandle,
  21. &pBindingVec
  22. );
  23. printf("RpcNsBindingLookupNext returned 0x%x\n", status);
  24. if (!status) {
  25. status = RpcBindingToStringBinding(pBindingVec->BindingH[0], &szBinding);
  26. i++;
  27. printf("%d. Binding = \"%S\"\n", i, szBinding);
  28. }
  29. }
  30. if (i != exp)
  31. return 1;
  32. return 0;
  33. }
  34. void __cdecl main(int argc, char **argv)
  35. {
  36. RPC_STATUS status;
  37. RPC_NS_HANDLE NsHandle;
  38. WCHAR * Annotation, *MemberName;
  39. UUID_VECTOR * objuuid = NULL;
  40. RPC_IF_HANDLE IfSpec;
  41. RPC_IF_ID ifidgot;
  42. DWORD Priority;
  43. int fFailed = 0;
  44. UUID uuidfound;
  45. FormObjUuid(objid, 1, &objuuid);
  46. FormIfHandle(ifid[0], &IfSpec);
  47. status = RpcNsMgmtSetExpAge(1);
  48. printf("RpcNsMgmtSetExpAge returned 0x%x\n", status);
  49. if (status)
  50. fFailed = 1;
  51. // no interface, no objuuid
  52. printf("**Test: Entry Name, No intf, No objuuid\n");
  53. status = RpcNsBindingLookupBegin(
  54. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  55. szSrvEntryName[0], // nsi entry name
  56. NULL,
  57. NULL,
  58. 1,
  59. &NsHandle);
  60. printf("RpcNsBindingLookupBegin returned 0x%x\n", status);
  61. if (status)
  62. fFailed = 1;
  63. status = LookupCountAndPrint(NsHandle, 2);
  64. if (status)
  65. fFailed = 1;
  66. status = RpcNsBindingLookupDone(
  67. &NsHandle
  68. );
  69. printf("RpcNsBindingLookupDone returned 0x%x\n\n", status);
  70. if (status)
  71. fFailed = 1;
  72. // 1 obj uuid
  73. printf("**Test: Entry Name, No intf, 1 objuuid\n");
  74. status = RpcNsBindingLookupBegin(
  75. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  76. szSrvEntryName[0], // nsi entry name
  77. NULL,
  78. objid,
  79. 1,
  80. &NsHandle);
  81. printf("RpcNsBindingLookupBegin returned 0x%x\n", status);
  82. if (status)
  83. fFailed = 1;
  84. status = LookupCountAndPrint(NsHandle, 1);
  85. if (status)
  86. fFailed = 1;
  87. status = RpcNsBindingLookupDone(
  88. &NsHandle
  89. );
  90. printf("RpcNsBindingLookupDone returned 0x%x\n\n", status);
  91. if (status)
  92. fFailed = 1;
  93. printf("**Test: No Entry Name, 1 intf, No objuuid\n");
  94. // Null entry name, 1 intf, no obj uuid
  95. status = RpcNsBindingLookupBegin(
  96. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  97. NULL, // nsi entry name
  98. IfSpec,
  99. NULL,
  100. 1,
  101. &NsHandle);
  102. printf("RpcNsBindingLookupBegin returned 0x%x\n", status);
  103. if (status)
  104. fFailed = 1;
  105. status = LookupCountAndPrint(NsHandle, 2);
  106. if (status)
  107. fFailed = 1;
  108. status = RpcNsBindingLookupDone(
  109. &NsHandle
  110. );
  111. printf("RpcNsBindingLookupDone returned 0x%x\n\n", status);
  112. if (status)
  113. fFailed = 1;
  114. printf("**Test: Enumerating Profiles\n");
  115. status = RpcNsProfileEltInqBegin(
  116. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  117. szPrfEntryName[0],
  118. RPC_C_PROFILE_ALL_ELTS,
  119. NULL,
  120. RPC_C_VERS_ALL,
  121. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  122. NULL,
  123. &NsHandle);
  124. printf("RpcNsProfileEltInqBegin returned 0x%x\n\n", status);
  125. if (status)
  126. fFailed = 1;
  127. status = RpcNsProfileEltInqNext(
  128. NsHandle,
  129. &ifidgot,
  130. &MemberName,
  131. &Priority,
  132. &Annotation);
  133. printf("RpcNsProfileEltInqNext returned 0x%x\n\n", status);
  134. printf("MemberName = \"%S\", Priority = %d, Annotation = \"%S\"\n", MemberName, Priority,
  135. Annotation);
  136. if (status)
  137. fFailed = 1;
  138. status = RpcNsProfileEltInqNext(
  139. NsHandle,
  140. &ifidgot,
  141. &MemberName,
  142. &Priority,
  143. &Annotation);
  144. printf("RpcNsProfileEltInqNext returned 0x%x\n\n", status);
  145. printf("MemberName = \"%S\", Priority = %d, Annotation = \"%S\"\n", MemberName, Priority,
  146. Annotation);
  147. if (status)
  148. fFailed = 1;
  149. status = RpcNsProfileEltInqNext(
  150. NsHandle,
  151. &ifidgot,
  152. &MemberName,
  153. &Priority,
  154. &Annotation);
  155. printf("RpcNsProfileEltInqNext returned 0x%x\n", status);
  156. if (!status)
  157. fFailed = 1;
  158. status = RpcNsProfileEltInqDone(&NsHandle);
  159. printf("RpcNsProfileEltInqDone returned 0x%x\n\n", status);
  160. if (status)
  161. fFailed = 1;
  162. printf("**Test: Enumerating Groups\n");
  163. status = RpcNsGroupMbrInqBegin(
  164. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  165. szGrpEntryName[0],
  166. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  167. &NsHandle);
  168. printf("RpcNsProfileEltInqBegin returned 0x%x\n\n", status);
  169. if (status)
  170. fFailed = 1;
  171. status = RpcNsGroupMbrInqNext(
  172. NsHandle,
  173. &MemberName
  174. );
  175. printf("RpcNsProfileEltInqNext returned 0x%x\n\n", status);
  176. printf("MemberName = \"%S\"\n", MemberName);
  177. if (status)
  178. fFailed = 1;
  179. status = RpcNsGroupMbrInqNext(
  180. NsHandle,
  181. &MemberName
  182. );
  183. printf("RpcNsProfileEltInqNext returned 0x%x\n\n", status);
  184. printf("MemberName = \"%S\"\n", MemberName);
  185. if (status)
  186. fFailed = 1;
  187. status = RpcNsGroupMbrInqNext(
  188. NsHandle,
  189. &MemberName
  190. );
  191. printf("RpcNsProfileEltInqNext returned 0x%x\n\n", status);
  192. if (!status)
  193. fFailed = 1;
  194. status = RpcNsGroupMbrInqDone(&NsHandle);
  195. printf("RpcNsProfileEltInqDone returned 0x%x\n\n", status);
  196. if (status)
  197. fFailed = 1;
  198. printf("**Test: Lookup using Groups\n");
  199. printf("**Test: Entry Name, No intf, No objuuid\n");
  200. status = RpcNsBindingLookupBegin(
  201. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  202. szGrpEntryName[0], // nsi entry name
  203. NULL,
  204. NULL,
  205. 1,
  206. &NsHandle);
  207. printf("RpcNsBindingLookupBegin returned 0x%x\n", status);
  208. if (status)
  209. fFailed = 1;
  210. status = LookupCountAndPrint(NsHandle, 2);
  211. if (status)
  212. fFailed = 1;
  213. status = RpcNsBindingLookupDone(
  214. &NsHandle
  215. );
  216. printf("RpcNsBindingLookupDone returned 0x%x\n\n", status);
  217. if (status)
  218. fFailed = 1;
  219. printf("**Test: Lookup using Profiles\n");
  220. printf("**Test: Entry Name, No intf, No objuuid\n");
  221. status = RpcNsBindingLookupBegin(
  222. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  223. szPrfEntryName[0], // nsi entry name
  224. NULL,
  225. NULL,
  226. 1,
  227. &NsHandle);
  228. printf("RpcNsBindingLookupBegin returned 0x%x\n", status);
  229. if (status)
  230. fFailed = 1;
  231. status = LookupCountAndPrint(NsHandle, 2);
  232. if (status)
  233. fFailed = 1;
  234. status = RpcNsBindingLookupDone(
  235. &NsHandle
  236. );
  237. printf("RpcNsBindingLookupDone returned 0x%x\n\n", status);
  238. if (status)
  239. fFailed = 1;
  240. printf("**Test: Object Inquiry\n");
  241. printf("**Test: Entry Name\n");
  242. status = RpcNsEntryObjectInqBegin(
  243. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  244. szSrvEntryName[0], // nsi entry name
  245. &NsHandle);
  246. printf("RpcNsEntryObjectInqBegin returned 0x%x\n", status);
  247. if (status)
  248. fFailed = 1;
  249. status = RpcNsEntryObjectInqNext(NsHandle, &uuidfound);
  250. printf("RpcNsEntryObjectInqNext returned 0x%x\n", status);
  251. if (status)
  252. fFailed = 1;
  253. status = RpcNsEntryObjectInqNext(NsHandle, &uuidfound);
  254. printf("RpcNsEntryObjectInqNext returned 0x%x\n", status);
  255. if (status)
  256. fFailed = 1;
  257. status = RpcNsEntryObjectInqNext(NsHandle, &uuidfound);
  258. printf("RpcNsEntryObjectInqNext returned 0x%x\n", status);
  259. if (!status)
  260. fFailed = 1;
  261. status = RpcNsEntryObjectInqDone(&NsHandle);
  262. printf("RpcNsEntryObjectInqDone returned 0x%x\n\n", status);
  263. if (status)
  264. fFailed = 1;
  265. // getting the dynamic endpoint
  266. printf("**Test: Dyn Entry Name, No intf, No objuuid\n");
  267. status = RpcNsBindingLookupBegin(
  268. RPC_C_NS_SYNTAX_DEFAULT, // name syntax type
  269. szDynSrvEntryName, // nsi entry name
  270. NULL,
  271. NULL,
  272. 1,
  273. &NsHandle);
  274. printf("RpcNsBindingLookupBegin returned 0x%x\n", status);
  275. if (status)
  276. fFailed = 1;
  277. status = LookupCountAndPrint(NsHandle, 1);
  278. if (status)
  279. fFailed = 1;
  280. status = RpcNsBindingLookupDone(
  281. &NsHandle
  282. );
  283. printf("RpcNsBindingLookupDone returned 0x%x\n\n", status);
  284. if (status)
  285. fFailed = 1;
  286. if (fFailed)
  287. printf("Lookup tests FAILED!!\n");
  288. else
  289. printf("Lookup tests PASSED!!\n");
  290. }