Rimuovere Utenti Dal SQL Server: differenze tra le versioni
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
| (7 versioni intermedie di uno stesso utente non sono mostrate) | |||
| Riga 3: | Riga 3: | ||
[[Category:sysadmin]] | [[Category:sysadmin]] | ||
[[Category:Database]] | [[Category:Database]] | ||
il comando '''<code>DROP USER</code>''' rimuove un utente dal SQL Server ma e' bene precisare che da solo esso non e' sufficiente | il comando '''<code>DROP USER</code>''' rimuove un utente dal SQL Server ma e' bene precisare che da solo esso non e' sufficiente, la rimozione dell'utente (generalmente) non si concretizza con la contemporanea rimozione dei permessi ad esso correlati. | ||
Si procede per tanto come segue: | Si procede per tanto come segue: | ||
Rimozione dei privilegi | Rimozione dei privilegi; | ||
<div id="atscreen"> | |||
MariaDB [(none)]> SHOW GRANTS FOR 'iu6crh'@'%';<br> | |||
+-------------------------------------------------------------------------------------------------------+<br> | |||
| Grants for iu6crh@% |<br> | |||
+-------------------------------------------------------------------------------------------------------+<br> | |||
| GRANT USAGE ON *.* TO 'iu6crh'@'%' IDENTIFIED BY PASSWORD '*6DA413D8ACD33A112877D31A8BD9DDFB36411631' |<br> | |||
| GRANT ALL PRIVILEGES ON `hamlog`.* TO 'iu6crh'@'%' |<br> | |||
+-------------------------------------------------------------------------------------------------------+<br> | |||
2 rows in set (0.00 sec)<br> | |||
DROP USER ' | MariaDB [(none)]> REVOKE ALL privileges ON hamlog.* FROM 'iu6crh'@'%';<br> | ||
Query OK, 0 rows affected (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]> SHOW GRANTS FOR 'iu6crh'@'%';<br> | |||
+-------------------------------------------------------------------------------------------------------+<br> | |||
| Grants for iu6crh@% |<br> | |||
+-------------------------------------------------------------------------------------------------------+<br> | |||
| GRANT USAGE ON *.* TO 'iu6crh'@'%' IDENTIFIED BY PASSWORD '*6DA413D8ACD33A112877D31A8BD9DDFB36411631' |<br> | |||
+-------------------------------------------------------------------------------------------------------+<br> | |||
1 row in set (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]> FLUSH PRIVILEGES;<br> | |||
Query OK, 0 rows affected (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]><br> | |||
</div> | |||
Rimozione dell'utente; | |||
<div id="atscreen"> | |||
MariaDB [(none)]> SELECT User, Host, Password, password_expired FROM mysql.user;<br> | |||
+--------+-----------+-------------------------------------------+------------------+<br> | |||
| User | Host | Password | password_expired |<br> | |||
+--------+-----------+-------------------------------------------+------------------+<br> | |||
| root | localhost | | N |<br> | |||
| iu6crh | % | *6DA413D8ACD33A112877D31A8BD9DDFB36411631 | N |<br> | |||
+--------+-----------+-------------------------------------------+------------------+<br> | |||
2 rows in set (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]> DROP USER iu6crh;<br> | |||
Query OK, 0 rows affected (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]> SELECT User, Host, Password, password_expired FROM mysql.user;<br> | |||
+------+-----------+----------+------------------+<br> | |||
| User | Host | Password | password_expired |<br> | |||
+------+-----------+----------+------------------+<br> | |||
| root | localhost | | N |<br> | |||
+------+-----------+----------+------------------+<br> | |||
1 row in set (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]> FLUSH PRIVILEGES;<br> | |||
Query OK, 0 rows affected (0.00 sec)<br> | |||
<br> | |||
MariaDB [(none)]><br> | |||
</div> | |||
Sarebbe opportuno aggiungere che, come riportato dal [https://mariadb.com/kb/it/drop-user/ Manuale], se sul sistema è in uso [https://mariadb.com/ MariaDB], l'esecuzione della query '''<code>DROP USER</code>''' comporta anche la rimozione di tutte le righe delle tabelle grant che impostano privilegi per l'utente oggetto della nostra azione, rendendo di fatto non più necessaria la rimozione preventiva dei privilegi. Tuttavia questa procedura resta una pratica di buona gestione del sistema. | |||
Versione attuale delle 22:21, 13 mag 2021
il comando DROP USER rimuove un utente dal SQL Server ma e' bene precisare che da solo esso non e' sufficiente, la rimozione dell'utente (generalmente) non si concretizza con la contemporanea rimozione dei permessi ad esso correlati.
Si procede per tanto come segue:
Rimozione dei privilegi;
MariaDB [(none)]> SHOW GRANTS FOR 'iu6crh'@'%';
+-------------------------------------------------------------------------------------------------------+
| Grants for iu6crh@% |
+-------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'iu6crh'@'%' IDENTIFIED BY PASSWORD '*6DA413D8ACD33A112877D31A8BD9DDFB36411631' |
| GRANT ALL PRIVILEGES ON `hamlog`.* TO 'iu6crh'@'%' |
+-------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> REVOKE ALL privileges ON hamlog.* FROM 'iu6crh'@'%';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW GRANTS FOR 'iu6crh'@'%';
+-------------------------------------------------------------------------------------------------------+
| Grants for iu6crh@% |
+-------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'iu6crh'@'%' IDENTIFIED BY PASSWORD '*6DA413D8ACD33A112877D31A8BD9DDFB36411631' |
+-------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>
Rimozione dell'utente;
MariaDB [(none)]> SELECT User, Host, Password, password_expired FROM mysql.user;
+--------+-----------+-------------------------------------------+------------------+
| User | Host | Password | password_expired |
+--------+-----------+-------------------------------------------+------------------+
| root | localhost | | N |
| iu6crh | % | *6DA413D8ACD33A112877D31A8BD9DDFB36411631 | N |
+--------+-----------+-------------------------------------------+------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> DROP USER iu6crh;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SELECT User, Host, Password, password_expired FROM mysql.user;
+------+-----------+----------+------------------+
| User | Host | Password | password_expired |
+------+-----------+----------+------------------+
| root | localhost | | N |
+------+-----------+----------+------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>
Sarebbe opportuno aggiungere che, come riportato dal Manuale, se sul sistema è in uso MariaDB, l'esecuzione della query DROP USER comporta anche la rimozione di tutte le righe delle tabelle grant che impostano privilegi per l'utente oggetto della nostra azione, rendendo di fatto non più necessaria la rimozione preventiva dei privilegi. Tuttavia questa procedura resta una pratica di buona gestione del sistema.