[英]Minor query about windows authentication using C# and custom roles
I have visual studio installed on my local machine and the MVC project is present for the development server. 我在本地计算机上安装了Visual Studio,并且开发服务器存在MVC项目。 I have to use windows authentication to see if users are authenticated using windows login. 我必须使用Windows身份验证来查看是否使用Windows登录名对用户进行了身份验证。
All users will have a local workstation of the company and they are going to login to the website we are developing using visual studio and development server. 所有用户都将拥有公司的本地工作站,他们将使用Visual Studio和开发服务器登录到我们正在开发的网站。
My query is- if i do windows authentication, i need to check the windows user details of the employee in the companys user database. 我的查询是-如果我执行Windows身份验证,则需要在公司的用户数据库中检查员工的Windows用户详细信息。 I donot want to check the active directory of the development server where the website is present. 我不想检查网站所在的开发服务器的活动目录。
Will this code help me to check authentication by referring it to the companys active directory database ? 此代码是否可以通过将其引用到公司的活动目录数据库来帮助我检查身份验证?
if (httpContext.User.Identity.IsAuthenticated)
Yes, that works regardless of what kind of authentication you are using. 是的,无论您使用哪种身份验证,它都可以工作。 However, you want 随你怎么便
HttpContext...
not 不
httpContext
Also, you'll need to enable windows authentication in your web.config file for this to work. 另外,您需要在web.config文件中启用Windows身份验证才能使其正常工作。
<system.web>
...
<authentication mode="Windows"/>
...
</system.web>
See https://msdn.microsoft.com/en-us/library/ff647405.aspx 请参阅https://msdn.microsoft.com/en-us/library/ff647405.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.