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
 SQL Server Development (2000)
 Stump the SQL Guru

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-12-11 : 13:43:39
Mark writes "I was browsing through the 4Guys site and saw this chance to stump a SQL guru. Although this question has a little be of ASP, but it is mainly a SQL question I haven't been able to figure out yet.

Ok, so I have a table with a trigger setup to automatically fill in a 'modified by' field using the default system_user. It works great through my VB app and ODBC, but how can one connect via DSN through the web and still have the system_user variable return without being NULL or default to DBO? I can pass the users NT authentication to the webserver no problem, but getting the SQL box to then grab the NT authentication or any session variables seems to be impossible.

-M"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-12-11 : 14:15:43
If the users are authenticating to IIS using Windows authentication, then you can use Request.Servervariables("AUTH_NAME") to return their Windows login name. You would need to pass this to SQL Server however, because the web server is making the connection to SQL Server, not the user. More accurately, the account under which IIS runs is the one making the connection to SQL Server; that's the result that SYSTEM_USER will return.

You can also look the HOST_NAME() and HOST_ID() SQL functions, these return the machine names of the connections, but again, in a web environment you'll get the web server, not the user.

Go to Top of Page
   

- Advertisement -