Click here to Skip to main content
13,901,044 members
Rate this:
 
Please Sign up or sign in to vote.
My ASP.NET MVC application has a login page and it validates the user credentials from the database properly. Now I need to integrate this:

When a user opens the login page, the application need to get the current logged in username from active directory. If only that username (Not Password) is available in the database, it should login automatically.

I do not have any idea about LDAP authentication. Can anyone please help me on getting current user by providing a simple code example?

What I have tried:

I have created intranet application with a login page that validates user credentials from database and access the system using ASP.NET MVC (C#)
Posted
Updated 28-Aug-18 18:40pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This is something that has been asked plenty of times with lots of different solutions.

I don't know anything about your project (nor does anyone else) so without learning more about it we can only point you in the right direction.

I don't quite know what you mean by getting the current logged in username from active directory, it sounds like this is an intranet app where the user who is logged into the PC is already logged in via AD/LDAP (i think MVC project calls it windows authentication).

Here are the best places to get started

LDAP authentication in ASP.NET MVC application using C - Google Search[^]

c# - LDAP Authentication in ASP.Net MVC - Stack Overflow[^]

Using LDAP and Active Directory with C# 101[^]

LDAP/AD authentication[^]

If these links don't prove useful, i suggest you use the first linked google search to refine what it is you are attempting to do to better suit your needs.

Then, once you've started implementing code and running into issues with the execution of your code after implementation feel free to come back with a clear explanation of your problem, relevant code samples and then I am sure you will find more meaningful assistance.
   
Comments
A.M.Roomi 29-Aug-18 0:42am
   
Thank you for your answer. Yes you are correct this is an intranet application and user who logged into the PC also logged into Active Directory. I will follow your links to find a solution. Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190306.1 | Last Updated 29 Aug 2018
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100