I have searched for IsInRole in this forum and I found one topic ( that addresses this issue, but the solution listed did not work.
Here is my code:
----------------
The second function that uses WindowsBuiltInRole works perfectly. The first function that allows for a string to be passed does not.
I commented out the solution from because that didn't work either.
I appreciate any help that would help resolve this issue.
Thank you,
Qamgine
Here is my code:
----------------
Code:
Imports System
Imports System.Security
Imports System.Security.Principal
Imports System.Threading
Module modUserInfo
Public Function IsMemberOf(ByVal Group As String) As Boolean
Try
Dim aID As Principal.WindowsIdentity
Dim aName As String = aID.GetCurrent.Name
Dim aDomain As String = aName.Substring(0, aName.IndexOf("\") + 1)
AppDomain.CurrentDomain.SetPrincipalPolicy(Principal.PrincipalPolicy.WindowsPrincipal)
Dim wp As WindowsPrincipal = Thread.CurrentPrincipal
Return wp.IsInRole(aDomain & Group)
'Solution from: [URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=541090[/URL]
'----------------------------------------------------------------
'AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
'Return Thread.CurrentPrincipal.IsInRole(aDomain & Group)
Catch ex As Exception
RaiseError(ex)
Return False
End Try
End Function
Public Function IsMemberOf(ByVal Group As WindowsBuiltinRole) As Boolean
Try
AppDomain.CurrentDomain.SetPrincipalPolicy(Principal.PrincipalPolicy.WindowsPrincipal)
Dim WP As WindowsPrincipal
WP = Thread.CurrentPrincipal
Return WP.IsInRole(Group)
Catch ex As Exception
RaiseError(ex)
Return False
End Try
End Function
End Module
The second function that uses WindowsBuiltInRole works perfectly. The first function that allows for a string to be passed does not.
I commented out the solution from because that didn't work either.
I appreciate any help that would help resolve this issue.
Thank you,
Qamgine