{"id":210,"date":"2015-12-29T10:45:43","date_gmt":"2015-12-29T10:45:43","guid":{"rendered":"http:\/\/www.softreeconsulting.com\/?p=210"},"modified":"2015-12-29T10:45:43","modified_gmt":"2015-12-29T10:45:43","slug":"get-collection-of-ad-groups-associated-with-ad-user","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/","title":{"rendered":"Get collection of AD groups associated with AD user"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>try\n\n{\n\nstring domainName = \"your domain name\";\n\nstring usertitle = \"Administrator\";\n\nList&lt;string> domainControllerAdGroupColl = new List&lt;string>();\n\nusing (PrincipalContext pContext = new\u00a0\u00a0 PrincipalContext(ContextType.Domain, domainName))\n\n{\n\nusing (PrincipalSearchResult&lt;System.DirectoryServices.AccountManagement.Principal> src = \u00a0UserPrincipal.FindByIdentity(pContext, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0userName).GetGroups(pContext))\n\n{\n\nsrc.ToList().ForEach(sr => domainControllerAdGroupColl.Add(sr.SamAccountName.ToLower()));\n\n}\n\n}\n\n}\n\ncatch { }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[75],"class_list":["post-210","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-in-which-group-ad-user-is-present"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get collection of AD groups associated with AD user - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get collection of AD groups associated with AD user - Softree Technology\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-29T10:45:43+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get collection of AD groups associated with AD user - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/","og_locale":"en_US","og_type":"article","og_title":"Get collection of AD groups associated with AD user - Softree Technology","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/","og_site_name":"Softree Technology","article_published_time":"2015-12-29T10:45:43+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Get collection of AD groups associated with AD user","datePublished":"2015-12-29T10:45:43+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/"},"wordCount":9,"commentCount":1,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"keywords":["In which group Ad user is present"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/","name":"Get collection of AD groups associated with AD user - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"datePublished":"2015-12-29T10:45:43+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/get-collection-of-ad-groups-associated-with-ad-user\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Get collection of AD groups associated with AD user"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=210"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/210\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}