我想基于用户身份限制用户在我的网站上的访问权限,我使用下面的代码在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