为ASP设置windows身份验证.. NET使用本地工作组



我需要为我们的web应用程序构建windows身份验证。我们计划创建本地工作组(在Windows 2008 Server上)来管理用户,而不是Active Directory。我们的理由是,通过AD创建组和移动用户需要几个月的时间(我们的客户更希望我们走这条路)。是否有可能为asp.net应用程序设置windows身份验证并根据本地工作组验证用户凭据?请记住,我们将尝试将他们的登录名与我们的本地工作组相匹配。

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

在你的web配置中做这样的事情。

<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(请求。ApplicationPath," logout.html")

end if

你可以从这个链接从微软http://msdn.microsoft.com/en-us/library/ff647401.aspx阅读更多使用WindowsTokenRoleProvider

最新更新