Hello,
I have a simple ASP.NET page that I want to capture the AD account a user is logged in with and record it in a SQL Server database. I have the following SQLDataSource defined below. I tried using SUSER_SNAME(), but realized that this only provided the account that I used to establish the database connection and not the AD account. Is there an easy way to get the AD account and pass it into a Insert Parameter? Does anyone have an example?
Thanks!
john
<asp:SqlDataSource ID="insTransaction" runat="server" ConnectionString="<%$ ConnectionStrings:MARTConnectionString %>"
InsertCommand="INSERT INTO TT_TRANS(ProjID, EmpID, TRANDATE, Hours, Description, Billed, CreatedBy) VALUES (@ProjID, @EmpID, @TDate, @Hours,@Desc,'N',SUSER_SNAME() )"
oninserted="insTransaction_Inserted">
<InsertParameters>
<asp:ControlParameter ControlID="DropDownList2" Name="ProjID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList1" Name="EmpID" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TextBox1" Name="TDate" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="Hours" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox3" Name="Desc" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>