Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 16th, 2012  |  syntax: None  |  size: 3.71 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ------------------------------------
  2. Case: Port in protocol address.
  3. Expected result: Connects on port 390.
  4. Actual result: Connects on port 390.
  5. ------------------------------------
  6.  
  7. ----
  8. Code
  9. ----
  10.  
  11. <?php
  12. ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
  13. $cxn = ldap_connect("ldap://somehostname.info:390");
  14. if(!$cxn)
  15.         die("couldn't connect");
  16. ldap_set_option($cxn,LDAP_OPT_PROTOCOL_VERSION,3);
  17. ldap_set_option($cxn,LDAP_OPT_REFERRALS,0);
  18.  
  19. if(!ldap_bind($cxn,NULL,'somepassword'))
  20.         die("couldn't bind");
  21.  
  22. ------
  23. Output
  24. ------
  25.  
  26. root@ip-someip:~# php test.php
  27. ldap_create
  28. ldap_url_parse_ext(ldap://somehostname.info:390)
  29. ldap_bind_s
  30. ldap_simple_bind_s
  31. ldap_sasl_bind_s
  32. ldap_sasl_bind
  33. ldap_send_initial_request
  34. ldap_new_connection 1 1 0
  35. ldap_int_open_connection
  36. ldap_connect_to_host: TCP somehostname.info:390
  37. ldap_new_socket: 3
  38. ldap_prepare_socket: 3
  39. ldap_connect_to_host: Trying 192.168.1.101:390
  40. ldap_pvt_connect: fd: 3 tm: -1 async: 0
  41. ldap_open_defconn: successful
  42. ldap_send_server_request
  43. ldap_result ld 0x2ced1c0 msgid 1
  44. wait4msg ld 0x2ced1c0 msgid 1 (infinite timeout)
  45. wait4msg continue ld 0x2ced1c0 msgid 1 all 1
  46. ** ld 0x2ced1c0 Connections:
  47. * host: somehostname.info  port: 390  (default)
  48.   refcnt: 2  status: Connected
  49.   last used: Thu Feb 16 16:43:24 2012
  50.  
  51.  
  52. ** ld 0x2ced1c0 Outstanding Requests:
  53.  * msgid 1,  origid 1, status InProgress
  54.    outstanding referrals 0, parent count 0
  55.   ld 0x2ced1c0 request count 1 (abandoned 0)
  56. ** ld 0x2ced1c0 Response Queue:
  57.    Empty
  58.   ld 0x2ced1c0 response count 0
  59. ldap_chkResponseList ld 0x2ced1c0 msgid 1 all 1
  60. ldap_chkResponseList returns ld 0x2ced1c0 NULL
  61. ldap_int_select
  62. read1msg: ld 0x2ced1c0 msgid 1 all 1
  63. read1msg: ld 0x2ced1c0 msgid 1 message type bind
  64. read1msg: ld 0x2ced1c0 0 new referrals
  65. read1msg:  mark request completed, ld 0x2ced1c0 msgid 1
  66. request done: ld 0x2ced1c0 msgid 1
  67. res_errno: 0, res_error: <>, res_matched: <>
  68. ldap_free_request (origid 1, msgid 1)
  69. ldap_parse_result
  70. ldap_msgfree
  71. ldap_free_connection 1 1
  72. ldap_send_unbind
  73. ldap_free_connection: actually freed
  74. root@ip-someip:~# vi test.php
  75. root@ip-someip:~# cat test.php
  76.  
  77. ------------------------------------
  78. Case: Port in protocol address.
  79. Expected result: Connects on port 390.
  80. Actual result: Tries to connect on port 389.
  81. ------------------------------------
  82.  
  83. ----
  84. Code
  85. ----
  86.  
  87. <?php
  88. ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
  89. $cxn = ldap_connect("ldap://somehostname.info",390);
  90. if(!$cxn)
  91.         die("couldn't connect");
  92. ldap_set_option($cxn,LDAP_OPT_PROTOCOL_VERSION,3);
  93. ldap_set_option($cxn,LDAP_OPT_REFERRALS,0);
  94.  
  95. if(!ldap_bind($cxn,NULL,'somepassword'))
  96.         die("couldn't bind");
  97.  
  98. ------
  99. Output
  100. ------
  101.  
  102. root@ip-someip:~# php test.php
  103. ldap_create
  104. ldap_url_parse_ext(ldap://somehostname.info)
  105. ldap_bind_s
  106. ldap_simple_bind_s
  107. ldap_sasl_bind_s
  108. ldap_sasl_bind
  109. ldap_send_initial_request
  110. ldap_new_connection 1 1 0
  111. ldap_int_open_connection
  112. ldap_connect_to_host: TCP somehostname.info:389
  113. ldap_new_socket: 3
  114. ldap_prepare_socket: 3
  115. ldap_connect_to_host: Trying 192.168.1.101:389
  116. ldap_pvt_connect: fd: 3 tm: -1 async: 0
  117. ldap_close_socket: 3
  118. ldap_err2string
  119.  
  120. Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in /root/test.php on line 9
  121. couldn't bind
  122.  
  123. ------------------------------------
  124. System Information
  125. ------------------------------------
  126.  
  127. root@ip-someip:~# uname -a
  128. Linux ip-someip 2.6.32-318-ec2 #38-Ubuntu SMP Thu Sep 1 18:09:30 UTC 2011 x86_64 GNU/Linux
  129.  
  130. root@ip-someip:~# php -v
  131. PHP 5.3.2-1ubuntu4.9 with Suhosin-Patch (cli) (built: May  3 2011 00:45:52)
  132. Copyright (c) 1997-2009 The PHP Group
  133. Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
  134.     with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH