在项目中遇到需要获取客户端登录的域账号信息的需求.
关键部分在于服务器的iis配置
1.确保服务器接入对应的域里面,使用域账号登录的。
2.iis需要设置为windows身份认证
3.我使用webform开发对应站点,通过request.ServerVariables["LOGON_USER"]获取账号
web.config需要对应配置
<authentication mode="Windows"/>
<authorization>
<allow user="*"/>
</authorization>
<modules>
<remove name="FormsAuthenticationModule"/>
<remove name="FormsAuthentication"/>
</modules>
4. Startup中ConfigureAuth,方法体注释掉
本文介绍了如何在项目中获取客户端的域账号信息,主要涉及服务器IIS配置为Windows身份认证,通过request.ServerVariables['LOGON_USER']获取登录账号,并在web.config中进行相应设置,禁用FormsAuthentication模块,同时在Startup中注释相关授权配置。
780

被折叠的 条评论
为什么被折叠?



