How to connect ldap securely with php

0

I have an inconvenient and it is that I am trying to connect to my AD with ldap in php in the following way ...

This way it does not work for me, and that's how I should connect myself

//conexion con ldaps://
$ldap_server = "ldaps://example.com";
$ldap_user = "CN=MiUsuario,OU=IT,DC=example,DC=com";
$ldap_pass = "password";

$ad = ldap_connect($ldap_server);
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
$bound = ldap_bind($ad, $ldap_user, $ldap_pass);

if($bound)
    return $ad;

This form if you connect me

//conexion con ldap://
$ldap_server = "ldap://example.com";
$ldap_user = "local\MiUsuario";
$ldap_pass = "password";

$ad = ldap_connect($ldap_server);
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
$bound = ldap_bind($ad, $ldap_user, $ldap_pass);

if($bound)
    return $ad;

Any idea why? I already have the certificate configured on my linux server (RedHat) - use php 5.4 - I have all the necessary libraries installed - I also saw that they use the UID = instead of CN =, something like that

$ldap_user = "UID=MiUsuario,OU=IT,DC=example,DC=com";

If anyone has an idea of why, I would appreciate it very much Oh and I also saw that on my linux server (RedHat) the SELinux is disabled

    
asked by Cristian Veizaga 12.07.2018 в 02:25
source

0 answers