Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = $_POST['username'];
- $pass = $_POST['password'];
- $subtree = 'dc=iitb,dc=ac,dc=in';
- $conn = ldap_connect("ldap://ldap.iitb.ac.in");
- $filter = "(uid=".$username.")";
- if ($username){
- if ($conn){
- $search = ldap_search($conn, $subtree, $filter);
- $result = ldap_get_entries($conn, $search);
- $ldapbind = ldap_bind($conn, $result[0]["dn"], $pass);
- if ($ldapbind){
- echo "Successfully Authenticated";
- return true;
- } else{
- echo "Invalid Credentials";
- return false;
- }
- } else {
- echo "Could not connect to ldap server";
- return false;
- }
- } else{
- echo "Make sure you provide the credentials";
- return false;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement