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

时间:2014-07-04 03:18:22

标签: asp.net iis webserver windows-authentication workgroup

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

1 个答案:

答案 0 :(得分:3)

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

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

<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&amp;&#34; \ logout.html&#34;)

end if

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