This content is not currently approved and is visible here for review only.

Library code snippets

List Windows Groups for authenticated user without Active Directory

Page 1 of 2
  1. groups.aspx.vb
  2. groups.aspx

groups.aspx.vb

Imports System.Security.Principal

Partial Public Class groups
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sb As StringBuilder = New StringBuilder
        Dim WinId As IIdentity = User.Identity
        Dim userId As WindowsIdentity = DirectCast(WinId, WindowsIdentity)
        sb.Append("<b>List of Windows Groups</b> for: " & userId.Name)
        Dim irefGroups As IdentityReferenceCollection = userId.Groups.Translate(GetType(NTAccount))
        Dim idRef As NTAccount
        For i As Integer = 0 To irefGroups.Count - 1
            idRef = irefGroups(i)
            sb.Append("<br />" & idRef.ToString)
        Next
        Label1.Text = sb.ToString()

    End Sub

End Class

Comments

  1. 01 Jan 1999 at 00:00

Leave a comment

Sign in or Join us (it's free).

AddThis

Related podcasts

  • Enterprise Architecture

    Podcast (MP3): Download Hosts: &#13;&#10; Markus &#13;&#10; Guests: Andy Longshaw Recording venue: In this episode Markus and our Guest Andy Longshaw talk about enterprise architecture. More specifically, we talk about some of the patterns in Andy Longshaw's and Paul Dyson's book Archite...

Events coming up

  • Jun 16

    Code Generation 2009

    Cambridge, United Kingdom

    A developer event with a practical focus on helping people get to grips with code generation tools and technologies.