Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/scripts/php/
Upload File :
Current File : /var/www/html/mmishra/indem/scripts/php/uidcheck.php

<?php
echo "UID Check\n=============\n";

echo "Enter category [employee/student/rgiit]:\n";
$cat = trim(fgets(STDIN));
if (!$cat) exit;


$ds = ldap_connect("ldap.iiita.ac.in");
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

$ac = ldap_search($ds, "ou=$cat,dc=iiita,dc=ac,dc=in","(&(uid=*)(objectClass=posixAccount))");
$i=0;
$no=0;
while ($acc = ldap_get_entries($ds, $ac)) {
	$i++; 
   	$uid = $acc[$i]["uid"][0];
   	$uidno = $acc[$i]["uidnumber"][0];
    	if ($uid) {
		$bc = ldap_search($ds, "dc=iiita,dc=ac,dc=in","(&(uidnumber=$uidno)(objectClass=posixAccount))");
		$j=ldap_count_entries($ds, $bc);
        	if ($j>1) {
			$no++;
			echo "$no--$uidno--$uid [";
			$j=0;
			while ($bcc = ldap_get_entries($ds, $bc)) {
   				$j++;
				$uid1 = $bcc[$j]["uid"][0];
   				$uidno1 = $bcc[$j]["uidnumber"][0];
   				if ($uid1 && $uid1 != $uid) {
					echo $uid1.' ';
				} else {
					break;
				}
			}
			echo "]\n";
		}
	} else {
		break;
	}
}
ldap_close($ds);
?>