Coppermill
Programmer
Is there anyway of finding a list of roles that the current logged in users is a member of?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
create table #t (UserName nvarchar(128), GroupName nvarchar(128), LoginName nvarchar(128), DefDBName nvarchar(128), UserID smallint, SID smallint)
insert into #t exec sp_helpuser
select * from #t where UserName = user
drop table #t
--drop table rolemember
create table #roles_users (UserName nvarchar(50), GroupName nvarchar(50), LoginName nvarchar(50), DefDBName nvarchar(50), UserID Int, SID varbinary(50))
insert into #roles_users
EXEC sp_helpuser
DECLARE @username nvarchar(50)
DECLARE @GroupName nvarchar(50)
DECLARE @MyCursor CURSOR
SET @MyCursor = CURSOR FAST_FORWARD
FOR
Select LoginName, UserName
From #roles_users
OPEN @MyCursor
FETCH NEXT FROM @MyCursor
INTO @username, @GroupName
WHILE @@FETCH_STATUS = 0
BEGIN
-- PRINT @RoleName
IF IS_MEMBER(@username) = 1
BEGIN
insert into tblDomainGroups
SELECT sUser_sName(), @username, @GroupName, 'None'
END
FETCH NEXT FROM @MyCursor
INTO @username, @GroupName
END
CLOSE @MyCursor
DEALLOCATE @MyCursor