【问题标题】:Setup windows authentication for ASP.NET using local workgroups?使用本地工作组为 ASP.NET 设置 Windows 身份验证?
【发布时间】:2014-07-04 03:18:22
【问题描述】:
我需要为我们的 Web 应用程序构建 Windows 身份验证。我们计划创建本地工作组(在 Windows 2008 Server 上)来管理用户而不是 Active Directory。我们的理由是,通过 AD 创建组和移动用户需要几个月的时间(我们的客户希望我们走这条路)。是否可以为 asp.net 应用程序设置 Windows 身份验证并针对本地工作组验证用户凭据?请记住,我们会尝试将他们的登录名与我们的本地工作组匹配。
【问题讨论】:
标签:
asp.net
iis
webserver
windows-authentication
workgroup
【解决方案1】:
您可以使用 AspNetWindowsTokenRoleProvider。这使得 ASP.net 使用 Windows 本地组。
在你的网络配置中做这样的事情。
<authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
--> <authentication mode="Windows"/>
<identity impersonate="false"/>
<authorization>
</authorization>
<roleManager enabled="true"
defaultProvider="AspNetWindowsTokenRoleProvider"/>
然后在您的 aspx 中,您可以检查用户是否存在于角色中。我把它放在我的母版页中。
If Not Roles.IsUserInRole(Context.Current.User.identity.name, "Managers") Then
'label1.Text = "You are not authorized to view user roles."
Response.Redirect(Request.ApplicationPath & "\logout.html")
end if
您可以从 Microsoft http://msdn.microsoft.com/en-us/library/ff647401.aspx 的此链接中了解更多信息
使用 WindowsTokenRoleProvider