How can i check if my webserver wich have Ubuntu/Apache/PHP is inside a windows active diretory ?
I have php-ldap and openssl php extensions enabled, but i still can not login using ldap.
the ldap bind returns false.
The code is the same that works on my local machine.
There is some network command line i can use from ubuntu to check it ?
Or even a php function instead of ldap_connect and ldap_bind ?
Thank´s in advance
EDIT:
this is the code i use to test the connection it works on my local machine and not in the webserver :
<?php
$useremail = 'myuser';
$data['password'] = 'mypassword';
$adServer = "ldap://my.veryowndomain.com";
$ldap = ldap_connect($adServer);
var_dump($useremail);
$ldaprdn = 'myveryowndomain' . "\\" . $useremail;
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap, $ldaprdn, $data['password']);
var_dump($bind);
echo "1 ldap_error: " . var_dump(ldap_error($conn))."<hr>";
ldap_get_option($conn, LDAP_OPT_DIAGNOSTIC_MESSAGE, $err);
echo "2 ldap_get_option: ". $err."<hr>";
echo ' >> 3 '. var_dump( ldap_errno() )."<hr>";
echo ' >> 4 '.var_dump( ldap_err2str( ldap_errno() ) )."<hr>";
if ($bind) {
$filter="(sAMAccountName=" . $useremail . ")";
$result = ldap_search($ldap,"DC=myveryowndomain,DC=com,DC=br",$filter);
echo '<hr> 5 result'."<hr>";
var_dump($result);
ldap_sort($ldap,$result,"sn");
$info = ldap_get_entries($ldap, $result);
echo '<hr> 6 result'."<hr>";
var_dump($info);
if ( $info['count'] >= 1 ) {
$success = true;
$usernome = $info[0]['cn'][0];
$usernetworkUser = $info[0]['samaccountname'][0];
$useremail = $info[0]['mail'][0];
$userimage = base64_encode($info[0]['thumbnailphoto'][0]);
echo ($ret);
} else {
$success = false;
echo '7 not authorized'."<hr>";
}
} else {
echo ' >> 8 '. var_dump( ldap_errno() )."<hr>";
echo ' >> 9 '.var_dump( ldap_err2str( ldap_errno() ) )."<hr>";
$success = false;
echo '10 Fail to connect to'."<hr>";
}
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Using LDAPv3<br>";
} else {
echo "Failed to set protocol version to 3";
}
@ldap_close($ldap);