Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting a list of logged in users roles(groups)
Message
From
22/01/2007 10:24:46
 
 
To
20/01/2007 10:08:45
General information
Forum:
ASP.NET
Category:
Security
Miscellaneous
Thread ID:
01187341
Message ID:
01187668
Views:
13
>I have a window forms app I'm adding security to. How can I determine what groups the logged in user belongs to?

Something like this?

Imports System.Security.Principal

Dim CurrentUser As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim strUserName As String = Replace(CurrentUser.Name, "\", "/")
Dim objWMI As Object

objWMI = GetObject("WinNT://" & strUserName)

Dim Group As Object
Dim Groups As String = ""

For Each Group In objWMI.Groups()
Groups += Group.Name + vbCr
Next

MsgBox(Groups, MsgBoxStyle.Information, "Group memberships")
Previous
Reply
Map
View

Click here to load this message in the networking platform