How to Authorize the logged in user

Posted on 2014-02-13
Last Modified: 2014-03-17
Hi there,

I am trying to write a programme to capture the current domain user(sal_chc_mta\username) and then matches it with the login  column of the table (sal_chc_mta\username) and if the user is there in the table it redirects to a page and if not it redirects to another page.

i want a very secure method.

can you please help me.

Question by:shah36
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Assisted Solution

RannyMeier earned 500 total points
ID: 39859302
Hi shah36,
I think that System.Security.Principal.WindowsIdentity.GetCurrent().Name is the method that can help.  For example:

DataTable dt = new DataTable();
DataColumn dc = new DataColumn("login", typeof(string));
DataRow dr = dt.NewRow();
dr["login"] = @"sal_chc_mta\username";
string currentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (dt.AsEnumerable().Any (d => d.Field<string>("login") == currentUser))

Open in new window

Your database query will likely be different than this example.


Accepted Solution

RannyMeier earned 500 total points
ID: 39859430
Hi shah36,
Me again.  My previous post is a specific answer to your question if your program is running on Windows.  Now as your question mentions "page", then maybe your application is a Web application.  If yours is a web application, then maybe it is to run on Windows IIS.  If that is the case then there are Authentication methods such as Forms Authentication and Windows Authentication built in that can use Active Directory.


Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question