我正在使用以下代码来确定用户是否在特定组中。该代码在我的本地开发环境中工作正常,但是当我将其推送到我们的开发服务器时,它始终返回false。确定用户是否在Active Directory组中
有什么我需要在IIS中配置?
注意:此代码仅在特定页面上运行。它没有在全球范围内用于所有网页。
Public Function IsInGroup(ByVal GroupName As String)
Dim MyIdentity As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
Dim MyPrincipal As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(MyIdentity)
'' Web team needs access to all pages. See web.config for value.
If MyPrincipal.IsInRole(ConfigurationManager.AppSettings("ISSupportAllAccessADGRoup").ToString.ToUpper) Then
Return True
Else
If MyPrincipal.IsInRole(GroupName) Then
Return True
Else
Return False
End If
End If
End Function
是为Windows身份验证设置的IIS服务器? –
是的。 Windows身份验证已启用。 – crjunk
做一些调试......在本地开发框中,Request.LogonUserIdentity.Name包含值“ABC \ john.doe”。在开发网站上,Request.LogonUserIdentity.Name包含值“NT AUTHORITY \ IUSR”。 – crjunk