简体   繁体   English

C#Active Directory客户端用户名

[英]C# Active Directory Client User name

I have website in mvc c#, running on a server. 我在mvc c#中有一个在服务器上运行的网站。 I want to bypass the login page and authenticate a user if the user is present in active directory. 我想绕过登录页面并验证用户身份(如果该用户位于活动目录中)。 For my website, i have forms authentication and anonymous authentication enabled. 对于我的网站,我启用了表单身份验证和匿名身份验证。

The problem is, i want to find out the name of user who is visiting the website. 问题是,我想找出正在访问该网站的用户名。 The user can be present on internet. 用户可以出现在互联网上。 With this name, i will do a lookup in Active directory and do the validation. 使用此名称,我将在Active Directory中进行查找并进行验证。

I am unable to find the user name. 我找不到用户名。 Any help would be appreciated. 任何帮助,将不胜感激。

Thanks. 谢谢。

You can have Active Directory Authentication in mvc by using Active Directory as the Membership Provider and get the username as 您可以通过使用Active Directory作为Membership Provider来在mvc中进行Active Directory Authentication ,并以

MembershipUser user = Membership.GetUser();
if (user != null)
    string name = user.UserName;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM