{"id":439,"date":"2016-08-31T13:06:24","date_gmt":"2016-08-31T13:06:24","guid":{"rendered":"http:\/\/blog.softreeconsulting.com\/?p=439"},"modified":"2016-08-31T13:06:24","modified_gmt":"2016-08-31T13:06:24","slug":"users-from-nested-ad-groups-in-sharepoint-in-india","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/","title":{"rendered":"How to get users from nested AD groups in SharePoint"},"content":{"rendered":"<p style=\"text-align: justify;\">As we know we can assign permission to specific AD groups from SharePoint workspace. So all users presents in that specific AD groups can get\u00a0permission\u00a0to SharePoint sites based on the permission defined to this AD groups in\u00a0SharePoint sites. If this AD group is a nested AD group then also all users present in all nested groups can have the permission to this SharePoint site.<\/p>\n<p style=\"text-align: justify;\">If there are requirements to list out all the users present in a specific AD group (Nested AD group) then this below mentioned code functions will help you in getting the Users presents in Nested AD groups.<\/p>\n<p>[code lang=&#8221;c&#8221;]<\/p>\n<p>using System;<br \/>\nusing System.Linq;<br \/>\nusing System.Net;<br \/>\nusing System.Text;<br \/>\nusing System.Security;<br \/>\nusing System.Threading.Tasks;<br \/>\nusing System.Collections.Generic;<br \/>\nusing System.DirectoryServices.AccountManagement;<\/p>\n<p>using Microsoft.SharePoint.Client;<br \/>\nusing Microsoft.SharePoint.Client.UserProfiles;<\/p>\n<p>namespace ConsoleApplicationForADGroupMembers<br \/>\n{<br \/>\nprivate class Program<br \/>\n{<br \/>\nstatic void Main(string[] args)<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nstring adGroup = &#8220;AdGroup Name&#8221;;\/\/Provide the ADGroup Name.<br \/>\nCheckNestedAdGroups(adGroup);<br \/>\nConsole.ReadLine();<br \/>\n}<br \/>\ncatch (Exception ex) { }<br \/>\n}<br \/>\nprivate static void CheckNestedAdGroups(string adgrpName)<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nusing (PrincipalContext pContext = new PrincipalContext(ContextType.Domain, &#8220;Domain Name&#8221;)) \/\/Provide the SharePoint Server Domain Name.<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nGroupPrincipal adGroup = GroupPrincipal.FindByIdentity(pContext, adgrpName); \/\/Provide the ADGroup Name<br \/>\nPrincipalSearchResult&lt;System.DirectoryServices.AccountManagement.Principal&gt; src = adGroup.GetMembers(false);\/\/ Here true or false decides whether it will be recursive or not.<\/p>\n<p>foreach (System.DirectoryServices.AccountManagement.Principal item in src.ToList())<br \/>\n{<br \/>\nif (item.StructuralObjectClass.ToLower() == &#8220;user&#8221;)<br \/>\n{<br \/>\n\/\/SharePoint User<br \/>\nstring userloginName = string.Empty;<br \/>\nuserloginName = item.SamAccountName;<br \/>\nConsole.WriteLine(userloginName);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\/\/AD Group<br \/>\nstring userloginName = string.Empty;<br \/>\nuserloginName = item.SamAccountName;<br \/>\nConsole.WriteLine(userloginName);<\/p>\n<p>CheckNestedAdGroups(userloginName);\/\/if ADGroup it will agin call the same function to get the members within it.<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\ncatch (Exception ex) { }<br \/>\n}<br \/>\n}<br \/>\ncatch (Exception ex) { }<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>[\/code]<\/p>\n<h6><strong>This solution is brought to you by our SharePoint professionals&#8230;<\/strong><\/h6>\n<p style=\"text-align: justify;\"><em><a href=\"https:\/\/www.softreetechnology.com\/\">Softree Technology <\/a>employs SharePoint consultants, who are experienced in writing for a multiplicity of SharePoint verticals including technical, promotional, creative, branding content, cataloging and ethical media comprising journalism.<\/em><\/p>\n<p style=\"text-align: justify;\"><em>With more than 10 years of industry experience, these professionals have the best resources to deliver optimum results. They have been satisfying customers with some of the best SharePoint Strategies. \u00a0<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we know we can assign permission to specific AD groups from SharePoint workspace. So all users presents in that specific AD groups can get\u00a0permission\u00a0to SharePoint sites based on the permission defined to this AD groups in\u00a0SharePoint sites. If this AD group is a nested AD group then also all users present in all nested groups can have the permission [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":443,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[119,120,59,121],"class_list":["post-439","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sharepoint","tag-how-to-get-users-from-ad-groups-presents-in-sharepoint","tag-how-to-get-users-from-nested-ad-groups-in-sharepoint","tag-sharepoint-2013","tag-sharepoint-2016"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Users from nested AD groups in SharePoint in India<\/title>\n<meta name=\"description\" content=\"As we know we can assign permission to a specific AD groups from SharePoint workspace.So all users presents in this specific AD groups\" \/>\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\/users-from-nested-ad-groups-in-sharepoint-in-india\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Users from nested AD groups in SharePoint in India\" \/>\n<meta property=\"og:description\" content=\"As we know we can assign permission to a specific AD groups from SharePoint workspace.So all users presents in this specific AD groups\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-31T13:06:24+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\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Users from nested AD groups in SharePoint in India","description":"As we know we can assign permission to a specific AD groups from SharePoint workspace.So all users presents in this specific AD groups","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\/users-from-nested-ad-groups-in-sharepoint-in-india\/","og_locale":"en_US","og_type":"article","og_title":"Users from nested AD groups in SharePoint in India","og_description":"As we know we can assign permission to a specific AD groups from SharePoint workspace.So all users presents in this specific AD groups","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/","og_site_name":"Softree Technology","article_published_time":"2016-08-31T13:06:24+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"How to get users from nested AD groups in SharePoint","datePublished":"2016-08-31T13:06:24+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/"},"wordCount":364,"commentCount":1,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#primaryimage"},"thumbnailUrl":"","keywords":["How to get users from AD groups presents in SharePoint","How to get users from nested ad groups in SharePoint","SharePoint 2013","SharePoint 2016"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/","name":"Users from nested AD groups in SharePoint in India","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#primaryimage"},"thumbnailUrl":"","datePublished":"2016-08-31T13:06:24+00:00","description":"As we know we can assign permission to a specific AD groups from SharePoint workspace.So all users presents in this specific AD groups","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/users-from-nested-ad-groups-in-sharepoint-in-india\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to get users from nested AD groups in SharePoint"}]},{"@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\/439","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=439"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/439\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}