I have a Microsoft SQL server database and a set of users.
Now in my app I want to make some functionality only visible, if the user has entered username and password with certain rights (admin).
Since the databases and the usernames and their rights can change, how do i check what permissions/rights an Microsoft SQL server user has?
You can check current user’s right on certain securables using
[sys.fn_mypermissions][1]which returns all permission on the securable. You can also check a specific permission withHAS_PERMS_BY_NAME. Eg. you can check forCONTROL SERVERpermission which implies an administrator is logged in: