PHP LDAP connection with AD LDS

I am trying to write some PHP to query an AD LDS / LDAP (2012 R2) instance and I cannot connect it. I am currently configured as an unencrypted connection (prod will be ssl / tls).

Current troubleshooting:

  • I can connect to my LDAP instance via ldapsearch and execute queries
  • I can connect via LDP on my windows.
  • I can ping the LDAP server and telnet to the port from my nix window.
  • Tried full rdn for username
  • Tried the URI (ldap: // ldapserver: 50001 or passed the port as native var)

I rewrote the code a million times thinking it was some syntax error or something wrong. $ ldapconn returns "Resource Id # 2" which looks correct in the PHP manual. I'm stumped. Is there any additional debugging I can enable?

Here is his error:

Warning: ldap_bind (): Unable to bind to server: Unable to bind to LDAP server in / usr / share / nginx / html / logintest 3.php on line 20

Here's the relevant code:

<?php

// all the debugging
ini_set('display_errors', 'On');
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);

$ldapuser = "ldapbind";
$ldappassword = "ldapbinder";
$ldapserver = "ldapserver";
$ldapport = 50001;

// connect to ldap server
$ldapconn = ldap_connect($ldapserver, $ldapport)
or die("Could not connect to $ldapserver");

// check if ldap_connect returned a resource value 
if($ldapconn) echo "$ldapconn";

// attempting bind
$ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappassword);

echo "Ldap connection debug: " . ldap_error($ldapconn) . "\n";

?>

      

+3


source to share


1 answer


try



ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);

      

0


source







All Articles