home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxldp021.zip / testrxldap.cmd < prev   
OS/2 REXX Batch file  |  2001-11-26  |  19KB  |  749 lines

  1. /**/                       
  2. signal on novalue name error
  3. signal on halt name error
  4.  
  5. parse arg traceon ',' host ',' port ',' userid ',' password ',' basedn
  6.  
  7. if host = '' then exit 8
  8. if port = '' then exit 8
  9. if userid = '' then exit 8
  10. if password = '' then exit 8
  11. if basedn = '' then exit 8
  12.  
  13. host = strip(host)
  14. port = strip(port)
  15. userid = strip(userid)
  16. password = strip(password)
  17. basedn = strip(basedn)
  18.  
  19. if translate(traceon) = 'YES' then trace r
  20.  
  21. call RxFuncDrop "RXLDAPLOADFUNCS"
  22. call RxFuncAdd "RXLDAPLOADFUNCS", "RXLDAP", "RXLDAPLOADFUNCS"
  23. call RxldapLoadFuncs
  24. call RxldapLoadFuncs
  25.  
  26. call RxldapVersion
  27. call say result
  28.  
  29. call Rxldap_version 'v.'
  30. call say result
  31. call say v.!sdk_version
  32. call say v.!protocol_version
  33.  
  34. url = "ldap://" || host || '/' || basedn || "?o,ou,cn,objectclass,sn?sub?(objectclass=*)"
  35.  
  36. cn1 = 'P' || random()
  37. cn2 = 'P' || random()
  38.  
  39. dn1 = 'cn=' || cn1 || ',' || basedn
  40. dn2 = 'cn=' || cn2 || ',' || basedn
  41.  
  42. call say dn1
  43. call say dn2
  44.  
  45. call Rxldap_url_parse url, 'desc.'
  46. call say desc.!lud_host
  47. call say desc.!lud_port
  48. call say desc.!lud_scope
  49. call say desc.!lud_filter
  50. do i = 1 to desc.!lud_attrs.0
  51.    call say desc.!lud_attrs.i
  52. end /* do */
  53.  
  54. call say Rxldap_is_ldap_url( url )
  55.  
  56. ld = Rxldap_init(host)
  57. if ld = 0 then signal error
  58.  
  59. call Rxldap_simple_bind ld, userid, password
  60.  
  61. call getasyncresults ld, result
  62.  
  63. call Rxldap_get_option ld, 'LDAP_OPT_TIMELIMIT', 'val'
  64. call say val
  65.  
  66. call Rxldap_set_option ld, 'LDAP_OPT_TIMELIMIT', 10
  67.  
  68. call Rxldap_get_option ld, 'LDAP_OPT_TIMELIMIT', 'val'
  69. call say val
  70.  
  71. call Rxldap_get_option ld, 'LDAP_OPT_SIZELIMIT', 'val'
  72. call say val
  73.  
  74. call Rxldap_set_option ld, 'LDAP_OPT_SIZELIMIT', 1000
  75.  
  76. call Rxldap_get_option ld, 'LDAP_OPT_SIZELIMIT', 'val'
  77. call say val
  78.  
  79. call Rxldap_get_option ld, 'LDAP_OPT_HOST_NAME', 'val'
  80. call say val
  81.  
  82. call Rxldap_get_option ld, 'LDAP_OPT_PROTOCOL_VERSION', 'val'
  83. call say val
  84.  
  85. call Rxldap_get_option ld, 'LDAP_OPT_API_INFO', 'val'
  86. call say val.!ldapai_api_version
  87. call say val.!ldapai_protocol_version
  88. call say val.!ldapai_vendor_name
  89. call say val.!ldapai_vendor_version
  90. do i = 1 to val.!ldapai_extensions.0
  91.    call say val.!ldapai_extensions.i
  92. end /* do */
  93.  
  94. call Rxldap_get_option ld, 'LDAP_OPT_API_FEATURE_INFO', 'val'
  95. call say val.!ldapaif_version
  96. call say val.!ldapaif_name
  97.  
  98. call Rxldap_unbind ld
  99.  
  100. ld = Rxldap_init(host, port)
  101. if ld = 0 then signal error
  102.  
  103. call Rxldap_simple_bind_s ld, userid, password
  104. if result <> 'LDAP_SUCCESS' then signal error
  105. call say Rxldap_err2string(result)
  106.  
  107. call Rxldap_url_search ld, url, 1
  108. if result = -1 then signal error
  109.  
  110. call Rxldap_abandon ld, result
  111. if result <> 0 then signal error
  112.  
  113. mods.0 = 3
  114. mods.1.!mod_op = 0
  115. mods.1.!mod_type = 'cn'
  116. mods.1.!modv.0 = 1
  117. mods.1.!modv.1 = cn1
  118. mods.2.!mod_op = 0
  119. mods.2.!mod_type = 'objectclass'
  120. mods.2.!modv.0 = 1
  121. mods.2.!modv.1 = 'person'
  122. mods.3.!mod_op = 0
  123. mods.3.!mod_type = 'sn'
  124. mods.3.!modv.0 = 1
  125. mods.3.!modv.1 = cn1
  126. call Rxldap_add_s ld, dn1, 'mods.'
  127. if result <> 'LDAP_SUCCESS' then signal error
  128.  
  129. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  130. if result <> 'LDAP_SUCCESS' then signal error
  131.  
  132. call getvalues ld, msg
  133.  
  134. call Rxldap_rename ld, dn1, 'cn=' || cn2, , 1, , , 'msgid'
  135. if result <> 'LDAP_SUCCESS' then signal error
  136.  
  137. call getasyncresults ld, msgid
  138.  
  139. call Rxldap_search_s ld, dn2, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  140. if result <> 'LDAP_SUCCESS' then signal error
  141.  
  142. call getvalues ld, msg
  143.  
  144. call Rxldap_delete_s ld, dn2
  145. if result <> 'LDAP_SUCCESS' then signal error
  146.  
  147. mods.0 = 3
  148. mods.1.!mod_op = 0
  149. mods.1.!mod_type = 'cn'
  150. mods.1.!modv.0 = 1
  151. mods.1.!modv.1 = cn1
  152. mods.2.!mod_op = 0
  153. mods.2.!mod_type = 'objectclass'
  154. mods.2.!modv.0 = 1
  155. mods.2.!modv.1 = 'person'
  156. mods.3.!mod_op = 0
  157. mods.3.!mod_type = 'sn'
  158. mods.3.!modv.0 = 1
  159. mods.3.!modv.1 = cn1
  160. call Rxldap_add_s ld, dn1, 'mods.'
  161. if result <> 'LDAP_SUCCESS' then signal error
  162.  
  163. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  164. if result <> 'LDAP_SUCCESS' then signal error
  165.  
  166. call getvalues ld, msg
  167.  
  168. call Rxldap_rename_s ld, dn1, 'cn=' || cn2, , 1
  169. if result <> 'LDAP_SUCCESS' then signal error
  170.  
  171. call Rxldap_search_s ld, dn2, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  172. if result <> 'LDAP_SUCCESS' then signal error
  173.  
  174. call getvalues ld, msg
  175.  
  176. call Rxldap_delete_s ld, dn2
  177. if result <> 'LDAP_SUCCESS' then signal error
  178.  
  179.  
  180. call say Rxldap_compare_s( ld, 'ou=YSL,o=rxldaptest', 'ou', 'YSL' )
  181.  
  182. call Rxldap_compare ld, 'ou=YSL,o=rxldaptest', 'ou', 'YSL'
  183. if result = -1 then signal error
  184. call getasyncresults ld, result
  185.  
  186. call say Rxldap_compare_ext_s( ld, 'ou=YSL,o=rxldaptest', 'ou', 'YSL' )
  187.  
  188. call Rxldap_compare_ext ld, 'ou=YSL,o=rxldaptest', 'ou', 'YSL', , , 'msgid'
  189. if result <> 'LDAP_SUCCESS' then signal error
  190.  
  191. call getasyncresults ld, msgid
  192.  
  193. mods.0 = 3
  194. mods.1.!mod_op = 0
  195. mods.1.!mod_type = 'cn'
  196. mods.1.!modv.0 = 1
  197. mods.1.!modv.1 = cn1
  198. mods.2.!mod_op = 0
  199. mods.2.!mod_type = 'objectclass'
  200. mods.2.!modv.0 = 1
  201. mods.2.!modv.1 = 'person'
  202. mods.3.!mod_op = 0
  203. mods.3.!mod_type = 'sn'
  204. mods.3.!modv.0 = 1
  205. mods.3.!modv.1 = cn1
  206. call Rxldap_add_s ld, dn1, 'mods.'
  207. if result <> 'LDAP_SUCCESS' then signal error
  208.  
  209. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  210. if result <> 'LDAP_SUCCESS' then signal error
  211.  
  212. call getvalues ld, msg
  213.  
  214. mods.0 = 1
  215. mods.1.!mod_op = 'LDAP_MOD_REPLACE'
  216. mods.1.!mod_type = 'sn'
  217. mods.1.!modv.0 = 1
  218. mods.1.!modv.1 = cn2
  219. call Rxldap_modify_ext_s ld, dn1, 'mods.'
  220. if result <> 'LDAP_SUCCESS' then signal error
  221.  
  222. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  223. if result <> 'LDAP_SUCCESS' then signal error
  224.  
  225. call getvalues ld, msg
  226.  
  227. call Rxldap_delete_s ld, dn1
  228. if result <> 'LDAP_SUCCESS' then signal error
  229.  
  230. mods.0 = 3
  231. mods.1.!mod_op = 0
  232. mods.1.!mod_type = 'cn'
  233. mods.1.!modv.0 = 1
  234. mods.1.!modv.1 = cn1
  235. mods.2.!mod_op = 0
  236. mods.2.!mod_type = 'objectclass'
  237. mods.2.!modv.0 = 1
  238. mods.2.!modv.1 = 'person'
  239. mods.3.!mod_op = 0
  240. mods.3.!mod_type = 'sn'
  241. mods.3.!modv.0 = 1
  242. mods.3.!modv.1 = cn1
  243. call Rxldap_add_s ld, dn1, 'mods.'
  244. if result <> 'LDAP_SUCCESS' then signal error
  245.  
  246. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  247. if result <> 'LDAP_SUCCESS' then signal error
  248.  
  249. call getvalues ld, msg
  250.  
  251. mods.0 = 1
  252. mods.1.!mod_op = 'LDAP_MOD_REPLACE'
  253. mods.1.!mod_type = 'sn'
  254. mods.1.!modv.0 = 1
  255. mods.1.!modv.1 = cn2
  256. call Rxldap_modify_s ld, dn1, 'mods.'
  257. if result <> 'LDAP_SUCCESS' then signal error
  258.  
  259. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  260. if result <> 'LDAP_SUCCESS' then signal error
  261.  
  262. call getvalues ld, msg
  263.  
  264. call Rxldap_delete_s ld, dn1
  265. if result <> 'LDAP_SUCCESS' then signal error
  266.  
  267. mods.0 = 3
  268. mods.1.!mod_op = 0
  269. mods.1.!mod_type = 'cn'
  270. mods.1.!modv.0 = 1
  271. mods.1.!modv.1 = cn1
  272. mods.2.!mod_op = 0
  273. mods.2.!mod_type = 'objectclass'
  274. mods.2.!modv.0 = 1
  275. mods.2.!modv.1 = 'person'
  276. mods.3.!mod_op = 0
  277. mods.3.!mod_type = 'sn'
  278. mods.3.!modv.0 = 1
  279. mods.3.!modv.1 = cn1
  280. call Rxldap_add_s ld, dn1, 'mods.'
  281. if result <> 'LDAP_SUCCESS' then signal error
  282.  
  283. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  284. if result <> 'LDAP_SUCCESS' then signal error
  285.  
  286. call getvalues ld, msg
  287.  
  288. mods.0 = 1
  289. mods.1.!mod_op = 'LDAP_MOD_REPLACE'
  290. mods.1.!mod_type = 'sn'
  291. mods.1.!modv.0 = 1
  292. mods.1.!modv.1 = cn2
  293. call Rxldap_modify ld, dn1, 'mods.'
  294.  
  295. call getasyncresults ld, result
  296.  
  297. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  298. if result <> 'LDAP_SUCCESS' then signal error
  299.  
  300. call getvalues ld, msg
  301.  
  302. call Rxldap_delete_s ld, dn1
  303. if result <> 'LDAP_SUCCESS' then signal error
  304.  
  305. mods.0 = 3
  306. mods.1.!mod_op = 0
  307. mods.1.!mod_type = 'cn'
  308. mods.1.!modv.0 = 1
  309. mods.1.!modv.1 = cn1
  310. mods.2.!mod_op = 0
  311. mods.2.!mod_type = 'objectclass'
  312. mods.2.!modv.0 = 1
  313. mods.2.!modv.1 = 'person'
  314. mods.3.!mod_op = 0
  315. mods.3.!mod_type = 'sn'
  316. mods.3.!modv.0 = 1
  317. mods.3.!modv.1 = cn1
  318. call Rxldap_add_s ld, dn1, 'mods.'
  319. if result <> 'LDAP_SUCCESS' then signal error
  320.  
  321. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  322. if result <> 'LDAP_SUCCESS' then signal error
  323.  
  324. call getvalues ld, msg
  325.  
  326. mods.0 = 1
  327. mods.1.!mod_op = 'LDAP_MOD_REPLACE'
  328. mods.1.!mod_type = 'sn'
  329. mods.1.!modv.0 = 1
  330. mods.1.!modv.1 = cn2
  331. call Rxldap_modify_ext ld, dn1, 'mods.', , , 'msgid'
  332.  
  333. call getasyncresults ld, msgid
  334.  
  335. call Rxldap_search_s ld, dn1, "LDAP_SCOPE_BASE", "(objectclass=*)", , 0, "msg"
  336. if result <> 'LDAP_SUCCESS' then signal error
  337.  
  338. call getvalues ld, msg
  339.  
  340. call Rxldap_delete_s ld, dn1
  341. if result <> 'LDAP_SUCCESS' then signal error
  342.  
  343. mods.0 = 3
  344. mods.1.!mod_op = 0
  345. mods.1.!mod_type = 'cn'
  346. mods.1.!modv.0 = 1
  347. mods.1.!modv.1 = cn1
  348. mods.2.!mod_op = 0
  349. mods.2.!mod_type = 'objectclass'
  350. mods.2.!modv.0 = 1
  351. mods.2.!modv.1 = 'person'
  352. mods.3.!mod_op = 0
  353. mods.3.!mod_type = 'sn'
  354. mods.3.!modv.0 = 1
  355. mods.3.!modv.1 = cn1
  356. call Rxldap_add_s ld, dn1, 'mods.'
  357. if result <> 'LDAP_SUCCESS' then signal error
  358.  
  359. mods.0 = 3
  360. mods.1.!mod_op = 0
  361. mods.1.!mod_type = 'cn'
  362. mods.1.!modv.0 = 1
  363. mods.1.!modv.1 = cn2
  364. mods.2.!mod_op = 0
  365. mods.2.!mod_type = 'objectclass'
  366. mods.2.!modv.0 = 1
  367. mods.2.!modv.1 = 'person'
  368. mods.3.!mod_op = 0
  369. mods.3.!mod_type = 'sn'
  370. mods.3.!modv.0 = 1
  371. mods.3.!modv.1 = cn2
  372. call Rxldap_add_ext_s ld, dn2, 'mods.'
  373. if result <> 'LDAP_SUCCESS' then signal error
  374.  
  375. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 0, "msg"
  376. if result <> 'LDAP_SUCCESS' then signal error
  377.  
  378. call getvalues ld, msg
  379.  
  380. call Rxldap_delete_s ld, dn1
  381. if result <> 'LDAP_SUCCESS' then signal error
  382.  
  383. call Rxldap_delete_ext_s ld, dn2
  384. if result <> 'LDAP_SUCCESS' then signal error
  385.  
  386. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 0, "msg"
  387. if result <> 'LDAP_SUCCESS' then signal error
  388.  
  389. call getvalues ld, msg
  390.  
  391. mods.0 = 3
  392. mods.1.!mod_op = 0
  393. mods.1.!mod_type = 'cn'
  394. mods.1.!modv.0 = 1
  395. mods.1.!modv.1 = cn1
  396. mods.2.!mod_op = 0
  397. mods.2.!mod_type = 'objectclass'
  398. mods.2.!modv.0 = 1
  399. mods.2.!modv.1 = 'person'
  400. mods.3.!mod_op = 0
  401. mods.3.!mod_type = 'sn'
  402. mods.3.!modv.0 = 1
  403. mods.3.!modv.1 = cn1
  404. call Rxldap_add ld, dn1, 'mods.'
  405.  
  406. call getasyncresults ld, result
  407.  
  408. mods.0 = 3
  409. mods.1.!mod_op = 0
  410. mods.1.!mod_type = 'cn'
  411. mods.1.!modv.0 = 1
  412. mods.1.!modv.1 = cn2
  413. mods.2.!mod_op = 0
  414. mods.2.!mod_type = 'objectclass'
  415. mods.2.!modv.0 = 1
  416. mods.2.!modv.1 = 'person'
  417. mods.3.!mod_op = 0
  418. mods.3.!mod_type = 'sn'
  419. mods.3.!modv.0 = 1
  420. mods.3.!modv.1 = cn2
  421. call Rxldap_add_ext ld, dn2, 'mods.', , , 'msgid'
  422.  
  423. call getasyncresults ld, msgid
  424.  
  425. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 0, "msg"
  426. if result <> 'LDAP_SUCCESS' then signal error
  427.  
  428. call getvalues ld, msg
  429.  
  430. call Rxldap_delete ld, dn1
  431.  
  432. call getasyncresults ld, result
  433.  
  434. call Rxldap_delete_ext ld, dn2, , , 'msgid'
  435.  
  436. call getasyncresults ld, msgid
  437.  
  438. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 0, "msg"
  439. if result <> 'LDAP_SUCCESS' then signal error
  440.  
  441. call getvalues ld, msg
  442.  
  443. call Rxldap_search_ext ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 1, , , 10.0, 0, "msgid"
  444. if result <> 'LDAP_SUCCESS' then signal error
  445.  
  446. call Rxldap_abandon_ext ld, msgid
  447. if result <> 'LDAP_SUCCESS' then signal error
  448.  
  449. call Rxldap_url_search_st ld, url, 1, 10.0, "msg"
  450. if result <> 'LDAP_SUCCESS' then signal error
  451.  
  452. count = Rxldap_count_entries( ld, msg )
  453. call Rxldap_get_errno ld
  454. if result <> 'LDAP_SUCCESS' then signal error
  455. call say count
  456.  
  457. call Rxldap_msgfree msg
  458. call Rxldap_get_errno ld
  459. if result <> 'LDAP_SUCCESS' then signal error
  460.  
  461. call Rxldap_search_st ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 1, 10.0, "msg"
  462. if result <> 'LDAP_SUCCESS' then signal error
  463.  
  464. count = Rxldap_count_entries( ld, msg )
  465. call Rxldap_get_errno ld
  466. if result <> 'LDAP_SUCCESS' then signal error
  467. call say count
  468.  
  469. call Rxldap_msgfree msg
  470. call Rxldap_get_errno ld
  471. if result <> 'LDAP_SUCCESS' then signal error
  472.  
  473. call Rxldap_search_ext_s ld, basedn, "LDAP_SCOPE_ONELEVEL", "(objectclass=*)", , 1, , , 10.0, 0, "msg"
  474. if result <> 'LDAP_SUCCESS' then signal error
  475.  
  476. count = Rxldap_count_entries( ld, msg )
  477. call Rxldap_get_errno ld
  478. if result <> 'LDAP_SUCCESS' then signal error
  479. call say count
  480.  
  481. call Rxldap_msgfree msg
  482. call Rxldap_get_errno ld
  483. if result <> 'LDAP_SUCCESS' then signal error
  484.  
  485. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 1, "msg"
  486. if result <> 'LDAP_SUCCESS' then signal error
  487.  
  488. count = Rxldap_count_entries( ld, msg )
  489. call Rxldap_get_errno ld
  490. if result <> 'LDAP_SUCCESS' then signal error
  491. call say count
  492.  
  493. call Rxldap_msgfree msg
  494. call Rxldap_get_errno ld
  495. if result <> 'LDAP_SUCCESS' then signal error
  496.  
  497. call Rxldap_search ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 1
  498. if result = -1 then signal error
  499.  
  500. call Rxldap_result ld, result, 'LDAP_MSG_ONE', 10.0, 'msg'
  501.  
  502. call Rxldap_msgtype msg
  503.  
  504. call Rxldap_msgid msg
  505.  
  506. count = Rxldap_count_entries( ld, msg )
  507. call Rxldap_get_errno ld
  508. if result <> 'LDAP_SUCCESS' then signal error
  509. call say count
  510.  
  511. call Rxldap_msgfree msg
  512. call Rxldap_get_errno ld
  513. if result <> 'LDAP_SUCCESS' then signal error
  514.  
  515. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_ONELEVEL", "(objectclass=*)", , 1, "msg"
  516. if result <> 'LDAP_SUCCESS' then signal error
  517.  
  518. count = Rxldap_count_entries( ld, msg )
  519. call Rxldap_get_errno ld
  520. if result <> 'LDAP_SUCCESS' then signal error
  521. call say count
  522.  
  523. call Rxldap_msgfree msg
  524. call Rxldap_get_errno ld
  525. if result <> 'LDAP_SUCCESS' then signal error
  526.  
  527. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_BASE", "(" || basedn || ")", , 1, "msg"
  528. if result <> 'LDAP_SUCCESS' then signal error
  529. call Rxldap_get_errno ld
  530. if result <> 'LDAP_SUCCESS' then signal error
  531.  
  532. count = Rxldap_count_entries( ld, msg )
  533. call Rxldap_get_errno ld
  534. if result <> 'LDAP_SUCCESS' then signal error
  535. call say count
  536.  
  537. call Rxldap_msgfree msg
  538. call Rxldap_get_errno ld
  539. if result <> 'LDAP_SUCCESS' then signal error
  540.  
  541. call Rxldap_url_search_s ld, url, 1, "msg"
  542. if result <> 'LDAP_SUCCESS' then signal error
  543.  
  544. count = Rxldap_count_entries( ld, msg )
  545. call Rxldap_get_errno ld
  546. if result <> 'LDAP_SUCCESS' then signal error
  547. call say count
  548.  
  549. call Rxldap_msgfree msg
  550. call Rxldap_get_errno ld
  551. if result <> 'LDAP_SUCCESS' then signal error
  552.  
  553. call Rxldap_search ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", , 0
  554.  
  555. call asyncgetvalues ld, result
  556.  
  557. attrs.0 = 5
  558. attrs.1 = "o"
  559. attrs.2 = "ou"
  560. attrs.3 = "objectclass"
  561. attrs.4 = "cn"
  562. attrs.5 = "sn"
  563.  
  564. call Rxldap_search_s ld, basedn, "LDAP_SCOPE_SUBTREE", "(objectclass=*)", "attrs.", 0, "msg"
  565. if result <> 'LDAP_SUCCESS' then signal error
  566.  
  567. call getvalues ld, msg
  568.  
  569. call Rxldap_unbind_s ld
  570. if result <> 'LDAP_SUCCESS' then signal error
  571.  
  572. call RxldapDropFuncs
  573. exit
  574.  
  575. asyncgetvalues: procedure
  576. arg ld, msgid
  577. if msgid = -1 then do
  578.    call Rxldap_get_errno ld
  579.    signal error
  580. end /* do */
  581.  
  582. do forever
  583.    call Rxldap_result ld, 'LDAP_RES_ANY', 'LDAP_MSG_RECEIVED', 2.0, 'res'
  584.    if result <> 'LDAP_RES_SEARCH_ENTRY' then leave
  585.    
  586.    call Rxldap_parse_result ld, res, 'errcode', , , , , 0
  587.    if errcode <> 'LDAP_SUCCESS' then signal error
  588.    
  589.    msg = Rxldap_first_entry( ld, res )
  590.    if msg = 0 then do
  591.       call Rxldap_msgfree res
  592.       leave
  593.    end /* do */
  594.    
  595.    do until msg = 0
  596.    
  597.       dn = Rxldap_get_dn( ld, msg )
  598.       call say dn
  599.       
  600.         call Rxldap_explode_dn dn, 0, 'rdns.'
  601.         do i = 1 to rdns.0
  602.             call say rdns.i
  603.       end /* do */
  604.       
  605.         call Rxldap_explode_dn dn, 1, 'rdns.'
  606.         do i = 1 to rdns.0
  607.             call say rdns.i
  608.       end /* do */
  609.         
  610.       attr = Rxldap_first_attribute( ld, msg, "ber" )
  611.       
  612.       do while attr <> ""
  613.          call say attr
  614.          call Rxldap_get_values ld, msg, attr, "vals."
  615.          do i = 1 to vals.0
  616.             call say attr || '=' || vals.i
  617.          end /* do */
  618.          attr = Rxldap_next_attribute( ld, msg, ber )
  619.       end /* do */
  620.       
  621.       msg = Rxldap_next_entry(ld, msg)
  622.    end /* do */
  623.    call Rxldap_msgfree res
  624. end /* do */
  625. return
  626.  
  627. getvalues: procedure
  628. arg ld, res
  629. msg = Rxldap_first_entry( ld, res )
  630. if msg = 0 then do
  631.    call Rxldap_msgfree res
  632.    return
  633. end /* do */
  634.  
  635. do until msg = 0
  636.  
  637.    dn = Rxldap_get_dn( ld, msg )
  638.    call say dn
  639.    
  640.     call Rxldap_explode_dn dn, 1, 'rdns.'
  641.     do i = 1 to rdns.0
  642.         call say rdns.i
  643.    end /* do */
  644.    
  645.     call Rxldap_explode_dn dn, 0, 'rdns.'
  646.     do i = 1 to rdns.0
  647.         call say rdns.i
  648.    end /* do */
  649.    
  650.    attr = Rxldap_first_attribute( ld, msg, "ber" )
  651.    
  652.    do while attr <> ""
  653.       call Rxldap_get_values ld, msg, attr, "vals."
  654.       do i = 1 to vals.0
  655.          call say attr || '=' || vals.i
  656.       end /* do */
  657.       attr = Rxldap_next_attribute( ld, msg, ber )
  658.    end /* do */
  659.    
  660.    msg = Rxldap_next_entry(ld, msg)
  661. end /* do */
  662. call Rxldap_msgfree res
  663. return
  664.  
  665. getvalueslen: procedure
  666. arg ld, res
  667. msg = Rxldap_first_entry( ld, res )
  668. if msg = 0 then do
  669.    call Rxldap_msgfree res
  670.    return
  671. end /* do */
  672.  
  673. do until msg = 0
  674.  
  675.    dn = Rxldap_get_dn( ld, msg )
  676.    call say dn
  677.    
  678.     call Rxldap_explode_dn dn, 0, 'rdns.'
  679.     do i = 1 to rdns.0
  680.         call say rdns.i
  681.    end /* do */
  682.    
  683.     call Rxldap_explode_dn dn, 1, 'rdns.'
  684.     do i = 1 to rdns.0
  685.         call say rdns.i
  686.    end /* do */
  687.    
  688.    attr = Rxldap_first_attribute( ld, msg, "ber" )
  689.    
  690.    do while attr <> ""
  691.       call Rxldap_get_values_len ld, msg, attr, "vals."
  692.       do i = 1 to vals.0
  693.          call say attr || '=' || vals.i
  694.       end /* do */
  695.       attr = Rxldap_next_attribute( ld, msg, ber )
  696.    end /* do */
  697.    
  698.    msg = Rxldap_next_entry(ld, msg)
  699. end /* do */
  700. call Rxldap_msgfree res
  701. return
  702.  
  703. getasyncresults: procedure
  704. parse arg ld, msgid
  705.  
  706. if msgid = -1 then do
  707.    call Rxldap_get_errno ld
  708.    signal error
  709. end /* do */
  710.  
  711. call Rxldap_result ld, 'LDAP_RES_ANY', 'LDAP_MSG_RECEIVED', 2.0, 'msg'
  712.  
  713. if msg = 0 then return
  714.  
  715. call say Rxldap_msgtype( msg )
  716.  
  717. count = Rxldap_count_messages( ld, msg )
  718. call say count
  719.  
  720. msg = Rxldap_first_message( ld, msg )
  721.  
  722. do while msg <> 0
  723.    call Rxldap_parse_result ld, msg, 'errcode', , , , , 0
  724.    call say Rxldap_msgtype( msg )
  725.    call say Rxldap_err2string( errcode )
  726.    msg = Rxldap_next_message( ld, msg )
  727. end /* do */
  728. return
  729.  
  730. error:
  731. ln = sigl
  732. if symbol('RESULT') = 'VAR' then do
  733.    say result
  734.    call say Rxldap_err2string(result)
  735. end /* do */
  736. if symbol('ERRCODE') = 'VAR' then do
  737.    say errcode
  738.    call say Rxldap_err2string(errcode)
  739. end /* do */
  740. say condition("c") || "@" || ln
  741. say condition("d")
  742. say condition("i")
  743. exit 8
  744.  
  745. say:
  746. parse arg m
  747. say sigl m
  748. return
  749.