Программирование и администрирование ● Web-программирование

To enable LDAPS the ldap.conf file must be in C:/OpenLDAP/sysconf/ even if you do not have OpenLDAP installed. Then the TLS_REQCERT option can be set. I had to do the following after installing WAMP Server:

  • Enable Apache ssl_module and ldap_module
  • Uncomment 'Include conf/extra/httpd-ssl.conf' in httpd.conf
  • Copy over crt and key files
  • Configure httpd-ssl.conf
  • Enable the openssl and ldap_php extension in PHP
  • Copy libsasl.dll from the php directory to the apache bin directory
  • Create directory C:/OpenLDAP/sysconf
  • Create file ldap.conf in C:/OpenLDAP/sysconf/ldap.conf
  • Add there one line: TLS_REQCERT never
  • Restart Apache

Connection to LDAP server: 

<?php
// Connect to LDAP server
$ldapconn = ldap_connect('ldaps://'.$_config['ldap_server']);
?>

Change password

<?php
$newPassword = "\"password\"";
$len = strlen($newPassword);
for ($i = 0; $i < $len; $i++)
        $newPassw .= "{$newPassword{$i}}\000";
 
  
$entry = array();
$entry["unicodePwd"] = $newPassw;
$entry["pwdLastSet"] = 0;
  
if (ldap_mod_replace($ldapconn, "cn=test.phpuser,OU=Пользователи,OU=Test,DC=domain,DC=local", $entry)  ===  false) {
    $error = ldap_error($ldapconn);
    $errno = ldap_errno($ldapconn);
    $message['pwdset_status'] = "E201 - Your password cannot be change, please contact the administrator. <br />$errno - $error";
} else {
    $message['pwdset_status'] = "The password for user_id has been changed.<br/>Your new password is now fully Active.";
}
?>

ИНФОРМАЦИЯ
МЕТКИ
    (меток не найдено)
Все метки