Re: SQL Roles

From: Alek Davis (alek_DOT_davis_AT_intel_DOT_com)
Date: 04/11/03


From: "Alek Davis" <alek_DOT_davis_AT_intel_DOT_com>
Date: Fri, 11 Apr 2003 11:54:42 -0700


Darren,

I assume that you meant the roles (plural), not the role (singular), since
the user can belong to many SQL server roles. I may be wrong, but I doubt
that there is an API which would return you a list of SQL roles for a user,
unless you query system tables directly (this assumes that you either
connect to SQL server using a separate account and the user's Window's
credentials match SQL credentials or the user can connect to SQL server and
query system tables). By the way, there are SQL server roles (e.g. sysadmin)
and there are also database roles (e.g. db_owner); I guess that you
understand the difference.

If you want to quickly check if user has a role, you can call
IS_SRVROLEMEMBER or IS_MEMBER function (they will check role membership for
currently connected user). Otherwise, you should probably get the list of
all roles and then verify whether the user has each role. In non-.NET world,
the cleanest way to do this would be via SQL-DMO. I am not sure what would
be the best option for .NET.

You may want to post this question to one of the SQL newsgroups.

-- Alek

"Darren" <darren@dns-solutions.com.au> wrote in message
news:043301c2fe5b$fa9f0600$a401280a@phx.gbl...
> Hello All,
> I am using windows authentication and impersonation in
> an intranet application, this works fine, however can
> anyone advise me how to return the SQL role a user
> belongs to?
>
> Thanks in advance
>
> P.S. Thanks to those who assisted my last post



Relevant Pages

  • Re: Security issue with win integrated authentication
    ... > windows integrated authentication checked in IIS ... > also access data in the database although he doesn't belong to group_b ... > configured in SQL server to access data.this user A doesn't belong to ... > any other group and has no login in SQL as well. ...
    (microsoft.public.dotnet.security)
  • Failure Audit Event ID: 18456 SQL Server Error
    ... I am getting the following error in MS SQL SERVER 2005 Enterprise Edition. ... The IP reported does not even belong to our domain. ... Event Source: MSSQLSERVER ...
    (microsoft.public.sqlserver.connect)
  • List of NTGroup users
    ... I need to find out list of users that belong to a NT Group. ... stored procedure or query in Sql server that I can use? ...
    (microsoft.public.sqlserver.security)
  • Re: security table in sqlserver 2000
    ... Create the table and don't grant any permissions to any users you don't want ... Make sure these users don't belong to any role that can give ... Co-Author SQL Server 2000 Programming by Example ...
    (microsoft.public.sqlserver.security)

Quantcast