troubleshooting Question

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

Avatar of Shepwedd
Shepwedd asked on
.NET ProgrammingASP.NETC#
2 Comments1 Solution304 ViewsLast Modified:
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();
 
    }
}
ASKER CERTIFIED SOLUTION
i_love_programming_08

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros