ASP.Net“;安全。原则。IsInRole“;在.Net 4.0上不起作用?
我有一个应用程序,它当前检查用户是否是Active Directory组的成员。代码是:ASP.Net“;安全。原则。IsInRole“;在.Net 4.0上不起作用?,asp.net,Asp.net,我有一个应用程序,它当前检查用户是否是Active Directory组的成员。代码是: Dim UsersIdentity As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent() Dim Principal As System.Security.Principal.WindowsPrincipal = New System.Secu
Dim UsersIdentity As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
Dim Principal As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(UsersIdentity)
If Principal.IsInRole(GroupName) Then
Return True
Else
Return False
End If
当我们发布到IIS并且应用程序池设置为.Net 2.0时,这可以正常工作,但是当我们将应用程序池更改为.Net 4.0时,该函数总是返回false
MSDN建议IsInRole仍然是一个受支持的函数,有人知道它为什么不能在.NET4.0上工作吗?(IIS被设置为Windows身份验证)。发现这在.Net 4.0中有效:
Dim UsersIdentity As System.Security.Principal.WindowsIdentity = HttpContext.Current.Request.LogonUserIdentity
与从System.Security.Principal..Net 4.0托管管道模式(经典或集成)获取标识不同,它设置为集成。我把它换成了经典,但它似乎有同样的问题。