如何使用C#在ASP.NET MVC应用程序中使用LDAP身份验证? [英] How do I use LDAP authentication in ASP.NET MVC application using C#?

查看:113
本文介绍了如何使用C#在ASP.NET MVC应用程序中使用LDAP身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET MVC应用程序有一个登录页面,它可以正确验证数据库中的用户凭据。现在我需要整合它:



当用户打开登录页面时,应用程序需要从活动目录中获取当前登录的用户名。如果数据库中只有该用户名(非密码),则应自动登录。



我对LDAP身份验证一无所知。有谁可以通过提供一个简单的代码示例来帮助我获得当前用户?



我尝试过:



我创建了一个带有登录页面的Intranet应用程序,该页面验证来自数据库的用户凭据并使用ASP.NET MVC访问系统(C#)

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#)

推荐答案

这已经被很多次问过很多不同的解决方案。



我对你的项目一无所知(其他人也不知道) )所以如果不了解它,我们只能指出你正确的方向。



我不太清楚你的意思是通过获取当前登录的用户名活动目录,听起来这是一个内部网应用程序,登录到PC的用户已经通过AD / LDAP登录(我认为MVC项目称之为Windows身份验证)。



以下是最好的入场地点



使用C的ASP.NET MVC应用程序中的LDAP身份验证 - Google搜索 [ ^ ]



c# - ASP.Net MVC中的LDAP身份验证 - 堆栈溢出 [ ^ ]



在C#101上使用LDAP和Active Directory [ ^ ]



LDAP / AD身份验证 [ ^ ]



如果这些链接不能证明有用,我建议你使用第一个链接的谷歌搜索到改进你试图做的事情以更好地满足你的需求。



然后,一旦你开始实现代码并遇到代码执行问题在实施后随时可以回过头来清楚地解释您的问题,相关的代码示例,然后我相信您会找到更有意义的帮助。
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.


这篇关于如何使用C#在ASP.NET MVC应用程序中使用LDAP身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆