I have a Microsoft SQL server database and a set of users. Now in my application I want to make some functions visible only if the user has entered a username and password with specific rights (admin). Since the databases and usernames and their rights can change, how can I check what rights and rights a user-owned Microsoft SQL Server has?
You can verify user rights on certain secret documents with a help [sys.fn_mypermissions][1]that returns all security permissions. You can also check for a specific resolution HAS_PERMS_BY_NAME. For instance. you can check the permission CONTROL SERVER, which implies that the administrator has logged in:
[sys.fn_mypermissions][1]
HAS_PERMS_BY_NAME
CONTROL SERVER
SELECT HAS_PERMS_BY_NAME(null, null, 'CONTROL SERVER');
I'm not quite sure that I understand your definition of the problem, but I assume that I am doing this .....
SQL Server, , , , ( Windows). , .
, , , SQL Server.
The easiest way to do this is to use the IS_MEMBER function, which checks if the user is in the db_owner role / group. The function will perform database-level validation. If you need to check at the server level, you can use the IS_SRVROLEMEMBER function. Both are available with SQL Server 2005.