daloradius icon indicating copy to clipboard operation
daloradius copied to clipboard

Username change in account info

Open bmarkovic06 opened this issue 2 years ago • 2 comments

It would be great to have option to change username of the already added user. For example If we add some user with mac auth, username is mac address. So if router dies and need replacement, we dont have to delete that user and add another one, simply change the username for new mac.

For now I have to manualy change it in phpmyadmin for tables radcheck, userinfo and userbillinfo.

userinfo

bmarkovic06 avatar Mar 11 '22 15:03 bmarkovic06

I can't say I'll be making this change soon as I'm not actively developing daloRADIUS but if you end up making a pull request here for the code change with a fix, I am happy to merge it.

lirantal avatar Mar 12 '22 20:03 lirantal

I can't say I'll be making this change soon as I'm not actively developing daloRADIUS but if you end up making a pull request here for the code change with a fix, I am happy to merge it.

Thanks a lot Liran. So far I've made simple php page that change that. I dont have experience neither in php or mysql (I'm network technician).

I've just put get-user-data.php and user-update.php in /var/www/html/daloradius/ and point to http://localhost/daloradius/get-user-data.php

Here is a code: user-update.php page that update username

<?php
 $servername='localhost';
   $username='radius';
   $password='radius123';
   $dbname = "radius";
   $con=mysqli_connect($servername,$username,$password,"$dbname");
   if(!$conn){
      die('Could not Connect My Sql:' .mysql_error());
   }
   
if(count($_POST)>0) {
mysqli_query($conn,"UPDATE userinfo set username='" . $_POST['username'] . "' WHERE id='" . $_POST['id'] . "'");
mysqli_query($conn,"UPDATE userbillinfo set username='" . $_POST['username'] . "' WHERE id='" . $_POST['id'] . "'");
mysqli_query($conn,"UPDATE radcheck set username='" . $_POST['username'] . "' WHERE id='" . $_POST['id'] . "'");
$message = "Record Modified Successfully";
}
$result = mysqli_query($conn,"SELECT * FROM userinfo WHERE username='" . $_GET['username'] . "'");
$row= mysqli_fetch_array($result);
$result = mysqli_query($conn,"SELECT * FROM userbillinfo WHERE username='" . $_GET['username'] . "'");
$row= mysqli_fetch_array($result);
$result = mysqli_query($conn,"SELECT * FROM radcheck WHERE username='" . $_GET['username'] . "'");
$row= mysqli_fetch_array($result);

?>
<html>
<head>
<title>Update MAC/Username of user</title>
</head>
<body>
<form name="frmUser" method="post" action="">
<div><?php if(isset($message)) { echo $message; } ?>
</div>
<div style="padding-bottom:5px;">
<a href="get-user-data.php">User List</a>
</div>
New mac/username: <br>
<input type="hidden" name="username" class="txtField" value="<?php echo $row['username']; ?>">
<input type="text" name="username"  value="<?php echo $row['username']; ?>">
<br>
ID: <br>
<input type="text" name="id" class="txtField" value="<?php echo $row['id']; ?>">
<br>
<input type="submit" name="submit" value="Submit" class="buttom">

</form>
</body>
</html>

get-user-data.php code to get userinfo data

<?php
$servername='localhost';
   $username='radius';
   $password='radius123';
   $dbname = "radius";
   $con=mysqli_connect($servername,$username,$password,"$dbname");
   if(!$conn){
      die('Could not Connect My Sql:' .mysql_error());
   }
$result = mysqli_query($conn,"SELECT * FROM userinfo");
?>
<!DOCTYPE html>
<html>
 <head>
   <title> Retrive user data</title>
   <link rel="stylesheet" href="style.css">
 </head>
<body>
<?php
if (mysqli_num_rows($result) > 0) {
?>
<table>
	  <tr>
	    <td>id</td>
		<td>username</td>
		<td>firstname</td>
                <td>lastname</td>
		
	  </tr>
			<?php
			$i=0;
			while($row = mysqli_fetch_array($result)) {
			?>
	  <tr>
	    <td><?php echo $row["id"]; ?></td>
		<td><?php echo $row["username"]; ?></td>
		<td><?php echo $row["firstname"]; ?></td>
                <td><?php echo $row["lastname"]; ?></td>
		<td><a href="user-update.php?id=<?php echo $row["id"]; ?>">Update</a></td>
      </tr>
			<?php
			$i++;
			}
			?>
</table>
 <?php
}
else
{
    echo "No result found";
}
?>
 </body>
</html>

bmarkovic06 avatar Mar 14 '22 08:03 bmarkovic06