Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Way to pull user like suser_sname()

Status
Not open for further replies.

jymm

Programmer
Apr 11, 2002
707
0
0
US
I have a bunch of SQL background and am looking for a way in ASP to pull a variable that would be the user's network/login ID (or name). Much like when in a SQL script I say select @user = suser_sname() --- which would set @user to the person's ID which was used to login to SQL.

I realize that the asp code is really being run on the server and that most of the traffic comes in through the IIS users, but still would like to pull that variable for an intranet application. Ideas?

Thanks in advance
 
If you do not allow anonymous access to your web site (You have to set the directory security in IIS) a server variable is set to the network domain/userid. You can use the following syntax to test and see if the variable is being set.

Response.write(request.servervariables("LOGON_USER"))

I pass this variable to Crystal Reports and print the user name on the bottom of each report produced from my intranet site.

Hope this helps,
 
[tt]
The only problem I have with the Response.write(request.servervariables("LOGON_USER")) method is that when a management team member logs on to the intranet he/she has now open the door for anyone without access to certain material on our site to view it without a problem.

I prefer using the cookie method with a logout option.

Then again, that's just me...
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
Tony,

What do you mean they have opened up access to other users? I use NTFS permissions to protect my intranet pages. Now if a member of management logs on and walks away from his PC to allow someone else to use it, I can see that happening. But if he protects his logon ID and locks his PC when he has to walk away there is no issue.
 
Guys,

I've tried

Response.write(request.servervariables(&quot;LOGON_USER&quot;)).

But It retrieved nothing.
Any ideas why?

Thank you.
 
If you allow anonymous access to your intranet site this variable will not be set. You have to uncheck Anonymous Access in the IIS Directory Security tab.

Hope this helps,
George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top