Within a VB.net program, I want to check if a user is in a group. The code I have only works if I am joined to the domain (see below). I either need to modify this code to accept credentials (username/password) or I need different code. I tried many different versions of code (most using LDAP), but can't get anything to work running from a PC that is not yet joined to the domain.
Public Function IsInGroup2(ByVal objectName As String, groupName As String) As Boolean
Return New WindowsPrincipal(New WindowsIdentity(objectName)).IsInRole(groupName)
Catch ex As Exception