httpContext用户身份

时间:2015-08-19 12:59:04

标签: asp.net vb.net iis httpcontext

我想基于用户身份限制用户在我的网站上的访问权限,我使用下面的代码在Visual Studio中可以正常工作,但是当我发布到IIS时,将 userIdentity = NULL 发送到数据库。

Dim httpContext__1 As HttpContext = HttpContext.Current
Dim winIdentity As System.Security.Principal.WindowsIdentity = DirectCast(httpContext__1.User.Identity, WindowsIdentity)
Dim userIdentity As String = winIdentity.Name

hasAccess = GetUserFromDB(userIdentity)
If hasAccess Then
    ' restrictions on 
Else
End If

1 个答案:

答案 0 :(得分:0)

我们需要确保启用Windows身份验证并禁用匿名身份验证。Please See This Link

相关问题