使用本地工作组为ASP.NET设置Windows身份验证? [英] Setup windows authentication for ASP.NET using local workgroups?

查看:143
本文介绍了使用本地工作组为ASP.NET设置Windows身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为我们的Web应用程序构建Windows身份验证。我们计划创建本地工作组(在Windows 2008 Server上)来管理用户而不是Active Directory。我们的理由是,创建群组并通过AD移动用户需要数月时间(我们的客户希望我们选择这条路线)。是否可以为asp.net应用程序设置Windows身份验证并验证针对本地工作组的用户凭据?请记住,我们会尝试将他们的登录名与我们当地的工作组相匹配。

I have requirement to build windows authentication for our web applications. We plan to created local work groups (on Windows 2008 Server) to manage users instead of Active Directory. Our reason, it takes months to create groups and move users via AD (and our client would prefer we go this route). Is it possible to setup windows authentication for an asp.net application and validate the user credentials against the local workgroups? Keep in mind we would try to match their login names to our local workgroups.

推荐答案

您可以使用AspNetWindowsTokenRoleProvider。这使得ASP.net使用Windows Local组。

You can use AspNetWindowsTokenRoleProvider. This makes ASP.net use the Windows Local groups.

在您的网络配置中执行类似的操作。

In your web config do something like this.

<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中,您可以检查用户是否存在角色。我把它放在我的母版页中。

then in your aspx you can check if user exists in role. I placed this in my master page.

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)

Response.Redirect(Request.ApplicationPath & "\logout.html")

end if

您可以从Microsoft的此链接中了解更多信息 http://msdn.microsoft.com /en-us/library/ff647401.aspx 使用WindowsTokenRoleProvider

You can read more from this Link from Microsoft http://msdn.microsoft.com/en-us/library/ff647401.aspx under Using WindowsTokenRoleProvider

这篇关于使用本地工作组为ASP.NET设置Windows身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆