我正在使用以下代碼來確定用戶是否在特定組中。該代碼在我的本地開發環境中工作正常,但是當我將其推送到我們的開發服務器時,它始終返回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