Advertisement
Guest User

Untitled

a guest
Jul 13th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. $username = $_POST['username'];
  3. $pass = $_POST['password'];
  4. $subtree = 'dc=iitb,dc=ac,dc=in';
  5. $conn = ldap_connect("ldap://ldap.iitb.ac.in");
  6. $filter = "(uid=".$username.")";
  7. if ($username){
  8. if ($conn){
  9. $search = ldap_search($conn, $subtree, $filter);
  10. $result = ldap_get_entries($conn, $search);
  11. $ldapbind = ldap_bind($conn, $result[0]["dn"], $pass);
  12. if ($ldapbind){
  13. echo "Successfully Authenticated";
  14. return true;
  15. } else{
  16. echo "Invalid Credentials";
  17. return false;
  18. }
  19. } else {
  20. echo "Could not connect to ldap server";
  21. return false;
  22. }
  23. } else{
  24. echo "Make sure you provide the credentials";
  25. return false;
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement