Re: SQL to get a list of users/roles/permissions



This function doesn't do much -- it basically tells me (yes or no) if a user
is in a specific role, but then how do I list the effective permission for
that user for all non-system tables in the database?

Thanks

"Uri Dimant" <urid@xxxxxxxxxxx> wrote in message
news:OA4%23UdU7GHA.4708@xxxxxxxxxxxxxxxxxxxxxxx
JA
CREATE FUNCTION dbo.RoleCheckUser
(
@UserName sysname,
@RoleName sysname
)
RETURNS BIT
AS
BEGIN
DECLARE @RetVal BIT
SET @RetVal = 0

SELECT @RetVal = 1
WHERE EXISTS
(
SELECT *
FROM sysmembers membs
JOIN sysusers users on membs.memberuid = users.uid
JOIN sysusers groups on membs.groupuid = groups.uid
WHERE
users.name = @UserName
AND groups.name = @RoleName
)

RETURN @RetVal
END
GO

-- Syntax to use the created function
SELECT dbo.RoleCheckUser('dbo', 'db_owner')
GO






"JA" <JA@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0F68942D-FD82-4D21-81A1-C0284354B1FA@xxxxxxxxxxxxxxxx
I'd like to perform an audit of users/roles/permissions within all my SQL
Server databases. How can I do so via a SQL query? I am looking for the
following sets of data:
1. username and role
2. role and permissions on each database table.

Thanks!!




.



Relevant Pages

  • Re: SQL to get a list of users/roles/permissions
    ... @UserName sysname, ... JOIN sysusers groups on membs.groupuid = groups.uid ... Server databases. ...
    (microsoft.public.sqlserver.security)
  • Re: Display Permissions
    ... JOIN sysusers users on membs.memberuid = users.uid ... JOIN sysusers groups on membs.groupuid = groups.uid ... on a database, and then on the tables within that database? ...
    (microsoft.public.sqlserver.security)
  • Re: Pathname to access and usernames in shortcut
    ... >> network drive (for maintenance reasons initially, ... >> using usernames but no passwords. ... change their passwords within the access database (they won't know how ... >> gets the current username from the system and then calls access (via the ...
    (microsoft.public.access.security)
  • Re: Getting NT User Login Names from Access 2000 or 2003
    ... time, i can recreate it in the blank database, per all your other thoughts. ... In the table setup and adding the bound SomeOtherField field to the ... >> form, plus binding the orig MyUserName field, defaulted to fOSUsername, to ... using the username field as ...
    (microsoft.public.access.formscoding)
  • Re: hashed password and UsernameTokenManager
    ... Sami ... > The reason for further hashing and salting the already hashed password is ... > you have the database. ... >>> to also use hashed password text to construct the username token... ...
    (microsoft.public.dotnet.framework.webservices.enhancements)