Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Check if a user belongs to a group in T-SQL

Author  Topic 

vpoko
Starting Member

22 Posts

Posted - 2006-02-15 : 10:59:48
Hi all,

I assume it's something very obvious, but I can't find a way to determine if the current user (or any user for that matter) belongs to a certain standard database role.

I have row-level security implemented on my database with all data access going through stored procedures (no direct access to tables), but my 'security check' function needs to always grant access to users in the SuperUser group. Right now I can only list individual users in the function to flag as superusers, but I'd rather use a group. Thanks!

mallier
Starting Member

24 Posts

Posted - 2006-02-16 : 09:35:52
Execute sp_helpuser and insert into a table,do a search based on username,group name.

create table #Users
(
UserName varchar(200),
GroupName varchar(200),
LoginName varchar(200),
DefDBName varchar(200),
UserId int,
SID varbinary(500)
)
go
insert into #Users EXEC sp_helpuser

select * from #Users

cheers,
http://mallier.blogspot.com
Go to Top of Page

vpoko
Starting Member

22 Posts

Posted - 2006-02-16 : 10:17:09
Thanks, worked great!
Go to Top of Page
   

- Advertisement -