< ?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"; } ?>