Each user of my asp.net forms app logs into a PC with their Active Directory credentials. How could the ASP.NET forms app get the user name and the email address currently logged into the PC?
There is no guaranteed way to find out which user they are logged into their computer with. However, you can:
network.negotiate-auth.delegation-uris
setting) If you skip step 2, then the user will be prompted for credentials. If the credentials sent in step 2 fail for whatever reason (for example, they are logged in with a local account instead of a domain account), the user will be prompted for credentials. Then they can type in whatever AD account they want, which may not be the same as what they are logged into their computer with. That's why I say that there is no 100% guaranteed way to know what account they are logged into their computer with.
If only some of your users have AD accounts, and some don't, then you can use split Forms and Windows authentication. I've done this before and described how I did it in a past answer .
使用HttpContext.Current.Request.LogonUserIdentity
获取用户名,而不是查询AD以获取电子邮件检查如何从Active Directory中获取用户的电子邮件地址?
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.