简体   繁体   English

有关使用C#和自定义角色的Windows身份验证的次要查询

[英]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.

相关问题 具有角色的C#MVC简单自定义身份验证 - C# MVC Simple Custom Authentication with Roles 使用 Active Directory 和 Windows 身份验证在 Blazor 服务器中提供自定义角色 - Using Active Directory and Windows Authentication to give custom roles in Blazor Server c# .NET wpf 使用自定义令牌的 Google Cloud Firestore 大约有 40% 的时间会引发身份验证错误 - c# .NET wpf Google Cloud Firestore using custom tokens throws Authentication Errors about 40% of the time C#— Windows Server 2012使用Powershell安装功能和角色 - C# — Windows Server 2012 installing Features and Roles using Powershell 使用数据库和C#(MVC)的Windows身份验证 - Windows authentication using database and C# (MVC) 使用C#绕过SSRS的Windows身份验证 - Bypassing Windows authentication for SSRS using c# 在Windows身份验证中使用asp.net中的角色 - using roles in asp.net with windows authentication Windows身份验证-检查角色 - Windows Authentication - Check Roles 没有角色的自定义用户权限c# - Custom User Permissions without Roles c# ASP.NET将Windows身份验证与自定义应用程序组/角色结合使用 - ASP.NET Combining Windows Authentication with Custom Application Groups/Roles
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM