How to Authorize the logged in user

Posted on 2014-02-13
Medium Priority
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 2000 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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

765 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