How to query DB based off of IIS authentication - Newbie ?

J

John Graham

Brief background, I'm new to .net, and my train of thought is how do I
convert my asp scripting to work in .net.

I have asp code that is grabbing a old session variable and doing the
query against my sql db essentially letting someone update their
information in the db. When using a sql data source, I'm trying to
get it to access the user login name, preferably without the
DomainName\ part of DomainName\USERNAME.

My question is how do I access that username in the sql query?

My previous code was,

rsFaculty = Server.CreateObject("ADODB.Recordset")
rsFaculty.ActiveConnection = MM_DSNci_STRING
rsFaculty.Source = "SQL QUERY find.... Where ID" &
session("variable")
rsFaculty.CursorType = 0
rsFaculty.CursorLocation = 2
rsFaculty.LockType = 3
rsFaculty.Open()
rsFaculty_numRows = 0

I'm guessing the new would be something like...

page class
public strUsername as String =
httpContext.current.user.Identity.name.ToString

on page code
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connStrNAME %>"
SelectCommand="SELECT * FROM [tblFaculty] WHERE
([id] = " & strUseraname & ")">

</asp:SqlDataSource>

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top