OK, this is the code:
$adServer = "ldaps://
ldap.example.com";
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$ldap = ldap_connect($adServer);
$username = 'myusername';
$password = 'mypassword';
$splitDom = array_slice(explode('.', $adServer), 1);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap, $username . '@' . implode('.',$splitDom), $password);
if ($bind) {
foreach ($splitDom as &$val)
$val = "dc=" . $val;
$result = ldap_search($ldap,implode(',',$splitDom),"(samAccountName=$username)",array('memberof'));
$info = ldap_get_entries($ldap, $result);
//var_dump($info);
if ($info['count'] > 0)
if (!empty($info[0]['memberof']) && ($info[0]['memberof']['count'] > 0))
for($i = 0; $i < $info[0]['memberof']['count']; $i++)
echo "\t" . substr(explode(',',$info[0]['memberof'][$i])[0], 3) . "\n";
@ldap_close($ldap);
} else {
ldap_get_option($ldap, LDAP_OPT_ERROR_STRING, $extended_error);
echo $extended_error;
}
On 5.6.25, it works, and on 5.7.1 it does something different and does not work, with the previously mentioned difference in the Hello. Can anyone confirm working ldaps with PHP 5.7.1 on Windows and a Windows DC?