Skip to content

Instantly share code, notes, and snippets.

@ranveeraggarwal
Created July 18, 2014 17:13
Show Gist options
  • Save ranveeraggarwal/bc6d047eb1f790d711a9 to your computer and use it in GitHub Desktop.
Save ranveeraggarwal/bc6d047eb1f790d711a9 to your computer and use it in GitHub Desktop.
IITB LDAP Auth Script (PHP)
<?php
function ldap_auth($ldap_id, $ldap_password){
$ds = ldap_connect("ldap.iitb.ac.in") or die("Unable to connect to LDAP server. Please try again later.");
if($ldap_id=='') die("You have not entered any LDAP ID. Please go back and fill it up.");
if($ldap_password=='') die("You have not entered any password. Please go back and fill it up.");
$sr = ldap_search($ds,"dc=iitb,dc=ac,dc=in","(uid=$ldap_id)");
$info = ldap_get_entries($ds, $sr);
$roll = $info[0]["employeenumber"][0];
//print_r($info);
$ldap_id = $info[0]['dn'];
if(@ldap_bind($ds,$ldap_id,$ldap_password)){
return var_dump($info);
}
else
{
return "NONE";
}
}
echo ldap_auth($_GET['user'],$_GET['pass']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment