Click here to Skip to main content
15,747,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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#)
Updated 28-Aug-18 18:40pm

1 solution

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.
Share this answer
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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900