PHP LDAP authentication

Source: Internet
Author: User
Tags ldap server port

<?PHP$ldap _host= "Ldap://serverip";//LDAP Server Address$ldap _port= "389";//LDAP Server port number//user name password RDN login$ldap _user= "[Email protected];virtualdomain=mail.com;o=account;dc=org";//Setting the login DN$ldap _pwd= "123456";//Set Password$ldap _conn= Ldap_connect ($ldap _host,$ldap _port);//establish a connection to the LDAP server$set= Ldap_set_option ($ldap _conn, Ldap_opt_protocol_version, 3);//setting parameters, this is not yet knownif(!$ldap _conn){    //Diagnosing Connection Errors     die("Can ' t connect to LDAP Server");} Ldap_bind ($ldap _conn,$ldap _user,$ldap _pwd) or die("Can ' t bind to LDAP server.");//bind to Server/*var_dump ($ldap _conn); exit;*///Connection Successfulif(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.");//disconnecting from the server?>

Ldap:dn and RDN links Appendix A-ldap:dn & RDN

PHP LDAP authentication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.