PHP & LDAPS : cant connect to AD

49 views Asked by At

For my project, i need to change ldap user password. For my setup :

  1. VSCode
  2. PHP 8.2
  3. Wampserver

The LDAPS(Active Directory) is activ on my Windows server and i can set a connection with the port 636 with the ldp microsoft's app. Ive exported the certifcates on my local machine. And i dont know how to do with it.

At this time i tried too many things like :

$ldapConnect = ldap_connect("ldaps://10.1.1.1:389");
$ldapConnect = ldap_connect("10.1.1.1:636");
putenv('LDAPTLS_REQCERT=never');

but nothing works

My last attempt is :

$newPassword = "newPassword";
$ldapConnect = ldap_connect("ldaps://10.1.1.1:636");
ldap_set_option($ldapConnect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapConnect, LDAP_OPT_REFERRALS, 0);
ldap_start_tls($ldapConnect);
$ldapbind = ldap_bind($ldapConnect, "DOMAIN\\admin", "AdminPassword");
$newPassword = '"' . $mdp . '"';
$newPassEncoded = iconv('UTF-8', 'UTF-16LE', $newPassword);
$userdata["unicodePwd"] = $newPassEncoded;
ldap_mod_replace($ldapConnect, "CN=name firstname,OU=YES,OU=Users,DC=DOMAIN,DC=COM", $userdata);

And the gave me some errors :

Warning: ldap_start_tls(): Unable to start TLS: Can't contact LDAP server in C:\wamp64\www\dev\passwordchanger\Controllers\login.php on line 15

( ! ) Warning: ldap_bind(): Unable to bind to server: Can't contact LDAP server in C:\wamp64\www\dev\passwordchanger\Controllers\login.php on line 16

Its a certicate problem or ?..

0

There are 0 answers