<?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