Windows Authentication

   Using the below code I can determine if the user is a member of a built-in security group, i.e. Domain Users. However, when I try to determine if the user is a member of a custom security group I get false, even though the user IS a Member of that security group within the domain. 
     If this code doesn't work for determining role membership outside of BUILTIN groups, can someone point me in the right direction on how I can find out if someone is a member of the "thisSpecialProgram"  custom security group
     Thanks.

Mark
     





      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim idWindows As WindowsIdentity
        idWindows = WindowsIdentity.GetCurrent()
        MessageBox.Show(idWindows.Name.ToString)

        'Create a WindowsPrincipal object based 
        'on the windowsIdentity object

        Dim wp As New WindowsPrincipal(idWindows)
        MessageBox.Show(wp.Identity.AuthenticationType)
        MessageBox.Show(CStr(wp.Identity.IsAuthenticated))
        MessageBox.Show(wp.Identity.Name)
        MessageBox.Show(CStr(wp.IsInRole("myDomain\thisSpecialProgram")))
    End Sub
End Class



Answer this question

Windows Authentication

  • Fdeveloper

    I remember that the code I used in my winform app worked, I think, let me try to scrape some up


  • sparkymark75

    oops sorry!  I meant asp.net webform app worked for my winform
  • Windows Authentication