April 8, 2009 at 1:06 pm
Is there any way to create a view that can show records based on the Microsoft domain login?
If I had a table with supervisors and a column with their domain login that would tie to results in another table (let's say employees that worked under them)....I want the view to only show the employees that work for them. But I can't seem to figure out what syntax to use to pass the domain login. Help!!!
April 9, 2009 at 3:43 pm
You could use a stored proc and capture the calling user, as long as they are using windows login and then use the value in the proceding select
declare @loginame nvarchar(250)
set @loginame = (select top 1 loginame)
from sys.sysprocesses where spid=@@spid)
Andrew
April 9, 2009 at 3:45 pm
Or create roles or logins that are windows security groups and use these to assign rights.
April 9, 2009 at 4:02 pm
Hi
If your users are connected via domain authentication you can use the sys.dm_exec_sessions. Have a look to the login_name column:
SELECT * FROM sys.dm_exec_sessions WHERE session_id = @@SPID
If not you can use a table valued function instead of a view.
Greets
Flo
April 10, 2009 at 8:53 am
n_parker (4/8/2009)
Is there any way to create a view that can show records based on the Microsoft domain login?
If you are using Windows Authentication, you can use SUSER_NAME()
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply