diff --git a/index.php b/index.php index ac1966c10fd9e121aec98ff5df6f096ce59d40cb..6efbb977b9dcab2c02a01838774e5c52ccf9682c 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ if (!$auth->isLoggedIn()) { exit; } -echo '<h1>Upload a file containing NUIDs</h1> +echo '<h1>Upload a file containing NUIDs or My.UNL Usernames</h1> <form action="" method="post" enctype="multipart/form-data"> File <input type="file" name="userfile" /> <input type="submit" name="submit" /> @@ -34,12 +34,21 @@ $ldap = UNL_LDAP::getConnection($options); echo '<pre>'; foreach ($contents as $nuid) { $nuid = rtrim($nuid); - if ($results = $ldap->search('dc=unl,dc=edu', '(|(unlUNCWID='.$nuid.')(uid='.$nuid.'))')) { + if ($results = $ldap->search( + 'dc=unl,dc=edu', + '(|(unlUNCWID='.$nuid.')(uid='.$nuid.'))', + array('attributes' => array('unlUNCWID', 'uid')) + )) { if (!count($results)) { continue; } foreach ($results as $entry) { + if (!isset($entry->unlUNCWID)) { + throw new Exception('Error, '.$entry->uid->__toString().' is not a student.'); + } echo $entry->unlUNCWID->__toString() . ',' . $entry->uid->__toString().PHP_EOL; } } } +echo '</pre>'; +