You are here: Re: Caller identity « MsSQL Server « IT news, forums, messages
Re: Caller identity

Posted by Erland Sommarskog on 09/27/36 11:19

[posted and mailed, please reply in news]

(lac@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, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация