Re: How to verify whether a user has been added to a database role?



Peter (Peter@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
I want to validate whether a user has been added to a particular database
role. I cannot use the is_member function since it only works with the
current user.

In additions to Dan's suggestion, you can:

EXECUTE AS LOGIN = 'thatuser'
go
SELECT is_member('somerole')
go
REVERT

I think this is better than running queries as Dan suggested, particularly
in the case that user may be have role membership through a Windows
domain.

If you think that there should be a function to retrieve permissions
or role membership with going through impersonation - which is impractical
if you want to check a suite of users - submit a suggestion on
http://connect.microsoft.com/SqlServer/Feedback. (I wouldn't be surprised
if there is such a suggestion already.)



--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

.



Relevant Pages

  • Re: Access denied after OS Disk upgrade!?
    ... Thank you Vikram Vamshi, for your quick response. ... I am suspicious of the last message about the system being older than SQL ... When I attempted your suggestion of trying to start from the command line, ... Please verify SQL Server is running ...
    (microsoft.public.sqlserver.connect)
  • Re: Tricky file import problem using vba
    ... Jeanette's suggestion but have to say I didn't think of a back end / front ... That is for *each* MDB. ... If you don't think that 2GB is enough, you could use SQL Express. ... where the first 4 digits represent an ID ...
    (microsoft.public.access.modulesdaovba)
  • Re: Querying a database using vb
    ... I have run a sql suggestion and had the following queries,: ... (I made one small adjustment to your first suggestion in order to exclude ... Dim pairsAdapter As New MWFNTableAdapters.MWFNTableAdapter ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Display Times as HH:MM in a Crosstab
    ... Paste your modified SQL into a reply. ... > I've tried your suggestion however, the Crosstab now displays all time ... >> Duane Hookom ...
    (microsoft.public.access.queries)
  • Re: splicing names together
    ... Ron, I used your suggestion (nothing personal to the ... which is coming from the bottom of the sql. ... But the textbox is giving me fits. ...
    (microsoft.public.access.formscoding)