参考博客:http://www.hejunbin.com/?p=78
<?php
$host = "ad服务器IP:端口(默认是389)";
$user = "用户名@域名";
$pswd = "密码";
$conn = ldap_connect($host) or die("Could not connect!" );
if($conn){
//设置参数
ldap_set_option ( $conn, LDAP_OPT_PROTOCOL_VERSION, 3 );
ldap_set_option ( $conn, LDAP_OPT_REFERRALS, 0 ); // Binding to ldap server
$bd = ldap_bind($conn, $user, $pswd) or die ("Could not bind");
echo "ldap_bind success";
}
else{
echo "Unable to connect to AD server";
}
?>
部分人可能需要下载php_ldap.dll
我用的是windows下的php 5.3.3 VC6版本。对应的dll如下