In an earlier article I’ve been talkin about how to check if a user belongs to a specific domain group. However, the code in that article doesn’t work on local groups and WinNT ADSI provider. I’ve made an update to the code posted there, this should work both on domain and local groups.
If IsUserInGroup("Contoso\JohnDoe", "Contoso\Managers") Then '...do something End If
- Option Strict Off. Sorry, I’m using the GetObject magic function here, so there’s no way I could leave the option strict on.
- Seems to be quite slow when local groups are scanned from outside.
Could be a problem when you have users from two different domains + local users.