We help IT Professionals succeed at work.
Get Started

How do I use query string variables to pass data from a database to an asp.net visual c# web site?

Shepwedd
Shepwedd asked
on
303 Views
Last Modified: 2013-12-17
I have written the attached code to identify a users login details. I next want to pass in three query string parameters: Database details (from a connection string), a document number from the database (int) and a version number from the database (int), however I only want the information to be available to the user if they have sufficient permission, hence obtaining their login details.

Thanks.
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Principal;
using System.Runtime.InteropServices;
using IManage;
 
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Pull back current users login details and show in a text box
        //TextBox1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
 
        //Pull back current users login details and show in a text box, but only in this particular section of code which is before the undo statement
        System.Security.Principal.WindowsImpersonationContext impersonationContext;
        impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
 
        WindowsIdentity currIdentity = WindowsIdentity.GetCurrent();
        string NtAccountName = currIdentity.Name;
        TextBox1.Text = NtAccountName;
 
        impersonationContext.Undo();
 
    }
}

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE