From: Phil on
I can check whether a user is in a group using My.User.IsInRole. This takes
the name of a windows group as a parameter, but how can I get a list of all
the groups defined for the machine on which the application is installed?
TIA
Phil.


From: Wilson, Phil on
The Win32 API NetGroupEnum is the traditional way (depending whether you
want use AD or not). I'm not aware of any .NET classes.

--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


"Phil" <p> wrote in message
news:rZqdnQZ4VI1ZoP3WnZ2dnUVZ8vidnZ2d(a)brightview.co.uk...
>I can check whether a user is in a group using My.User.IsInRole. This takes
>the name of a windows group as a parameter, but how can I get a list of all
>the groups defined for the machine on which the application is installed?
> TIA
> Phil.
>

From: Phil on

"Wilson, Phil" <philw(a)wonderware.nospam.com> wrote in message
news:4A20447C-D813-4A71-B47B-932A66358817(a)microsoft.com...
> The Win32 API NetGroupEnum is the traditional way (depending whether you
> want use AD or not). I'm not aware of any .NET classes.

Thanks for this. I did a bit of research, and came up with the following
code using DirectoryServices:

Imports System.DirectoryServices
Public Function GetWindowsUserGroups() As List(Of String)
Dim grp As DirectoryEntry
Dim names As New List(Of String)
With New DirectoryEntry("WinNT://" & Environment.MachineName +
",computer")
For Each grp In .Children
If LCase(grp.SchemaClassName) = "group" Then
names.Add(grp.Name)
End If
Next
End With
Return names
End Function

I haven't looked at you suggestion of using Win32 API NetGroupEnum, but the
above looks nice and simple. Is there any disadvantage doing it this way? It
seems to work on my development machine (Windows XP logged into a Windows
Server domain). I don't need to worry about Windows 98 or ME, but it would
be a pain if there were problems with Vista or Windows 7, with other network
providers, or with home editions of Windows.

Thanks again
Phil.


From: Wilson, Phil on
I'm not too familiar with it so I can't say, however I suspect that the WMI
class you're using calls NetGroupEnum internally.

--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


"Phil" <p> wrote in message
news:gNydnX14x8CRa__WnZ2dnUVZ8gSdnZ2d(a)brightview.co.uk...
>
> "Wilson, Phil" <philw(a)wonderware.nospam.com> wrote in message
> news:4A20447C-D813-4A71-B47B-932A66358817(a)microsoft.com...
>> The Win32 API NetGroupEnum is the traditional way (depending whether you
>> want use AD or not). I'm not aware of any .NET classes.
>
> Thanks for this. I did a bit of research, and came up with the following
> code using DirectoryServices:
>
> Imports System.DirectoryServices
> Public Function GetWindowsUserGroups() As List(Of String)
> Dim grp As DirectoryEntry
> Dim names As New List(Of String)
> With New DirectoryEntry("WinNT://" & Environment.MachineName +
> ",computer")
> For Each grp In .Children
> If LCase(grp.SchemaClassName) = "group" Then
> names.Add(grp.Name)
> End If
> Next
> End With
> Return names
> End Function
>
> I haven't looked at you suggestion of using Win32 API NetGroupEnum, but
> the above looks nice and simple. Is there any disadvantage doing it this
> way? It seems to work on my development machine (Windows XP logged into a
> Windows Server domain). I don't need to worry about Windows 98 or ME, but
> it would be a pain if there were problems with Vista or Windows 7, with
> other network providers, or with home editions of Windows.
>
> Thanks again
> Phil.
>

From: Phil on
OK. Thanks.
I think I'll go ahead using this method, and wait and see if any users have
problems.

"Wilson, Phil" <philw(a)wonderware.nospam.com> wrote in message
news:A0F4B480-8A4D-49FC-ADBD-C4FCA8D4CBA3(a)microsoft.com...
> I'm not too familiar with it so I can't say, however I suspect that the
> WMI class you're using calls NetGroupEnum internally.
>
> --
> Phil Wilson
> The Definitive Guide to Windows Installer
> http://www.apress.com/book/view/1590592972
>
>
> "Phil" <p> wrote in message
> news:gNydnX14x8CRa__WnZ2dnUVZ8gSdnZ2d(a)brightview.co.uk...
>>
>> "Wilson, Phil" <philw(a)wonderware.nospam.com> wrote in message
>> news:4A20447C-D813-4A71-B47B-932A66358817(a)microsoft.com...
>>> The Win32 API NetGroupEnum is the traditional way (depending whether you
>>> want use AD or not). I'm not aware of any .NET classes.
>>
>> Thanks for this. I did a bit of research, and came up with the following
>> code using DirectoryServices:
>>
>> Imports System.DirectoryServices
>> Public Function GetWindowsUserGroups() As List(Of String)
>> Dim grp As DirectoryEntry
>> Dim names As New List(Of String)
>> With New DirectoryEntry("WinNT://" & Environment.MachineName +
>> ",computer")
>> For Each grp In .Children
>> If LCase(grp.SchemaClassName) = "group" Then
>> names.Add(grp.Name)
>> End If
>> Next
>> End With
>> Return names
>> End Function
>>
>> I haven't looked at you suggestion of using Win32 API NetGroupEnum, but
>> the above looks nice and simple. Is there any disadvantage doing it this
>> way? It seems to work on my development machine (Windows XP logged into a
>> Windows Server domain). I don't need to worry about Windows 98 or ME, but
>> it would be a pain if there were problems with Vista or Windows 7, with
>> other network providers, or with home editions of Windows.
>>
>> Thanks again
>> Phil.
>>
>