{"id":314,"date":"2017-06-13T16:59:53","date_gmt":"2017-06-13T20:59:53","guid":{"rendered":"http:\/\/techref.camellarry.com\/?p=314"},"modified":"2017-06-13T16:59:53","modified_gmt":"2017-06-13T20:59:53","slug":"determine-if-a-user-belongs-to-a-particular-ad-group","status":"publish","type":"post","link":"http:\/\/techref.camellarry.com\/?p=314","title":{"rendered":"Determine if a user belongs to a particular AD Group"},"content":{"rendered":"<p>This is the easiest way to determine if a user belongs to particular Active Directory user group using VB.NET without having to enumerate through all the user&#8217;s groups.<\/p>\n<pre>Public Function IsInGroup(ByVal GroupName As String) As Boolean\r\n Dim MyIdentity As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()\r\n Dim MyPrincipal As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(MyIdentity)\r\n Return MyPrincipal.IsInRole(GroupName)\r\nEnd Function<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is the easiest way to determine if a user belongs to particular Active Directory user group using VB.NET without having to enumerate through all the user&#8217;s groups. Public Function IsInGroup(ByVal GroupName As String) As Boolean Dim MyIdentity As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent() Dim MyPrincipal As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(MyIdentity) Return MyPrincipal.IsInRole(GroupName) End Function<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[12,13,29,45,76,77,78,80],"class_list":["post-314","post","type-post","status-publish","format-standard","hentry","category-vb-net","tag-net","tag-active-directory","tag-example","tag-microsoft","tag-vb","tag-vb-net","tag-visualbasic","tag-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9t3oE-54","_links":{"self":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=314"}],"version-history":[{"count":1,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions"}],"predecessor-version":[{"id":315,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions\/315"}],"wp:attachment":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}