471,108 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

Caller identity

lac
I am using SQL Server 2000 and SQL authentication in a web
appliacation. All data access is done via single SQL Server account.
In my front end I am using forms authentication. Is there a way to
retrieve the forms identity (or just a username) from SQL Server?

Thanks,
Lac

Jul 23 '05 #1
2 1668
Stu
SQL can only know what's passed through the connection string, which
will be the SQL username.

Of course, there might be a solution if you describe more of the
problem; are you trying to log user activity? Do you just need to know
when a certain user is logged on or off?

Stu

Jul 23 '05 #2
[posted and mailed, please reply in news]

(la*@myrealbox.com) writes:
I am using SQL Server 2000 and SQL authentication in a web
appliacation. All data access is done via single SQL Server account.
In my front end I am using forms authentication. Is there a way to
retrieve the forms identity (or just a username) from SQL Server?


Yes, but the form has to cooperate, and do this:

DECLARE @bin varbinary(128)
SELECT @bin = convert(varbinary(128), 'Username')
SET CONTEXT_INFO @bin

Then you can retrieve the username in SQL Server this way:

DECLARE @username varchar(128)
SELECT @username = convert(varchar(128), context_info)
FROM master.dbo.sysprocesses
WHERE spid = @@spid

Note that on SQL 2005, you should replace the access to sysprocesses to
use the built-in function context_info(). (Which unfortunately is not
available in SQL 2000.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by ivan_oj28 | last post: by
9 posts views Thread by jaden10001 | last post: by
4 posts views Thread by Thomas Mlynarczyk | last post: by
9 posts views Thread by Csaba Gabor | last post: by
2 posts views Thread by Mike9900 | last post: by
5 posts views Thread by pamelafluente | last post: by
7 posts views Thread by Rahul | last post: by
7 posts views Thread by =?UTF-8?B?QW50w7NuaW8gTWFycXVlcw==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.