Re: Get the Domain-Groups of a User?
From: Rob Windsor [MVP] (rwindsor_at_NO.MORE.SPAM.bigfoot.com)
Date: 02/13/04
- Next message: Herfried K. Wagner [MVP]: "Re: Conversion"
- Previous message: Herfried K. Wagner [MVP]: "Re: Finding current Procedure"
- In reply to: P Dietz: "Get the Domain-Groups of a User?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 13 Feb 2004 09:16:46 -0500
The .NET Framework provides a way to check if the user is in a specific
role. For example if I wanted to check if the current user was part of the
group "Accounting" I would make this call:
System.Threading.Thread.CurrentPrincipal.IsInRole("Accounting")
It doesn't appear that you can easily get a list of all the roles. The
WindowsIdentity class does keep an internal list of roles but it does not
expose a public method to access the list. You can use reflection to get
this list but be carefull, because this code is accessing an internal
variable there is no guarantee that it will work in upcoming versions of
.NET
Imports System.Security.Principal
Imports System.Security
Imports System.Reflection
Dim id As WindowsIdentity
Dim result As Object
Dim roles() As String
id = WindowsIdentity.GetCurrent()
result = GetType(WindowsIdentity).InvokeMember( _
"_GetRoles", _
BindingFlags.Static Or _
BindingFlags.InvokeMethod Or _
BindingFlags.NonPublic, _
Nothing, id, New Object() {id.Token}, Nothing)
roles = DirectCast(result, String())
-- Rob Windsor [MVP-VB] G6 Consulting Toronto, Canada "P Dietz" <anonymous@discussions.microsoft.com> wrote in message news:61104147-62B1-4ABB-AC65-471056E0F332@microsoft.com... > Hello, > how can i get the groupslist, of which the current Windows-User is a member? > > Thanks! > Peter
- Next message: Herfried K. Wagner [MVP]: "Re: Conversion"
- Previous message: Herfried K. Wagner [MVP]: "Re: Finding current Procedure"
- In reply to: P Dietz: "Get the Domain-Groups of a User?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|