简体   繁体   中英

C# Active Directory Client User name

I have website in mvc c#, running on a server. 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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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