Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to Authorize the logged in user

Posted on 2014-02-13
2
Medium Priority
?
291 Views
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.

regards,
0
Comment
Question by:shah36
[X]
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
2 Comments
 
LVL 2

Assisted Solution

by:RannyMeier
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));
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr["login"] = @"sal_chc_mta\username";
dt.Rows.Add(dr);
string currentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (dt.AsEnumerable().Any (d => d.Field<string>("login") == currentUser))
{
	Debug.WriteLine("true");
}
else
{
	Debug.WriteLine("false");
}

Open in new window


Your database query will likely be different than this example.

Ranny
0
 
LVL 2

Accepted Solution

by:
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.

Ranny
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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