PHP编程入门--LDAP验证
PHP编程入门--LDAP验证
https://www.cnblogs.com/bmbh/p/4623987.html
<?php $ldap_host = "ldap://ServerIP";//LDAP 服务器地址 $ldap_port = "389";//LDAP 服务器端口号 //用户名密码 RDN登录 $ldap_user = "mail=uid@mail.com;virtualDomain=mail.com;o=Account;dc=org";//设定登录DN $ldap_pwd = "123456";//设定密码 $ldap_conn = ldap_connect($ldap_host, $ldap_port);//建立与 LDAP 服务器的连接 $set = ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); //设置参数,这个目前还不了解 if(!$ldap_conn) { //诊断连接错误 die("Can't connect to LDAP server"); } ldap_bind($ldap_conn, $ldap_user, $ldap_pwd) or die("Can't bind to LDAP server.");//与服务器绑定 /*var_dump($ldap_conn); exit;*/ //连接成功 if(ldap_errno($ldap_conn)!=0) { echo "Can't log in! ".ldap_error($ldap_conn)."<br>"; } else { echo "Welcome $ldap_user"; } ldap_unbind($ldap_conn) or die("Can't unbind from LDAP server."); //与服务器断开连接 ?>
LDAP:DN与RDN链接 Appendix A - LDAP: DN & RDN