Skip to content
Snippets Groups Projects
Commit 622a1289 authored by Brett Bieber's avatar Brett Bieber
Browse files

Restrict attributes to only those required and display notice on errors

parent 637feba7
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ if (!$auth->isLoggedIn()) { ...@@ -14,7 +14,7 @@ if (!$auth->isLoggedIn()) {
exit; 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"> <form action="" method="post" enctype="multipart/form-data">
File <input type="file" name="userfile" /> File <input type="file" name="userfile" />
<input type="submit" name="submit" /> <input type="submit" name="submit" />
...@@ -34,12 +34,21 @@ $ldap = UNL_LDAP::getConnection($options); ...@@ -34,12 +34,21 @@ $ldap = UNL_LDAP::getConnection($options);
echo '<pre>'; echo '<pre>';
foreach ($contents as $nuid) { foreach ($contents as $nuid) {
$nuid = rtrim($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)) { if (!count($results)) {
continue; continue;
} }
foreach ($results as $entry) { 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 $entry->unlUNCWID->__toString() . ',' . $entry->uid->__toString().PHP_EOL;
} }
} }
} }
echo '</pre>';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment