Currently, I'm working in one migration request, where we need to change the framework from 3.5 to 4.6.2. Here the problem is after changing the framework below method is not showing result as expected. My.User.IsInRole()
is always returning false.
If My.User.IsInRole(nlRole.InnerText) Then
hasRole = True
Exit For
End If
Also, I tested with below code:
Imports System.Security.Principal
Class PrincipalCheck
Shared Function UserInRole(role As String) As Boolean
Dim currPrincipal As New WindowsPrincipal(New WindowsIdentity(Environment.UserName))
Return currPrincipal.IsInRole(role)
End Function
End Class
Public Sub StartCheck()
MsgBox(PrincipalCheck.UserInRole("MyDomain\MyGroup"))
End Sub
But no luck. Can someone please help me with the above issue.
If you expect some more input from my end, please let me know.