Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.
Public Shared Function IsMemberOfGroup(userName As String, machineName As String, memberGroup As String) As Boolean Dim isMember As Boolean = False Using rootContext As New PrincipalContext(ContextType.Machine, machineName), _ grp As GroupPrincipal = GroupPrincipal.FindByIdentity(rootContext, memberGroup), _ usr As UserPrincipal = UserPrincipal.FindByIdentity(rootContext, IdentityType.SamAccountName, userName) If grp IsNot Nothing AndAlso usr IsNot Nothing Then ' Check if the user is a member of the group. isMember = grp.GetMembers(True).Contains(usr) MsgBox("yay") Else isMember = False MsgBox("nah") End If End Using Return isMember End Function
IsMemberOfGroup(localusrname, TextBox1.Text, "administrators")
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|VB.NET Application Installation with sqlserver||8||69|
|VB.net Excel VSTO Add-in version compatability||2||37|
|Variable 'id' is used before it has been assigned a value||29||45|
|Display Day name if condition is true in crystal report (VB.Net)||2||36|
Join the community of 500,000 technology professionals and ask your questions.