Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the method <code>SPUtility.GetPrincipalsInGroup</code> (<a href="http://msdn.microsoft.com/en-us/library/ms457726%28v=office.14%29.aspx" rel="noreferrer">MSDN</a>).</p> <p>All parameters are self-explaining except <code>string input</code>, which is the NT account name of the security group:</p> <pre><code>bool reachedMaxCount; SPWeb web = SPContext.Current.Web; int limit = 100; string group = "Domain\\SecurityGroup"; SPPrincipalInfo[] users = SPUtility.GetPrincipalsInGroup(web, group, limit, out reachedMaxCount); </code></pre> <p>Please note that this method does not resolve nested security groups. Further the executing user is required to have browse user info permission (<code>SPBasePermissions.BrowseUserInfo</code>) on the current web.</p> <p><strong>Update:</strong></p> <pre><code>private void ResolveGroup(SPWeb w, string name, List&lt;string&gt; users) { foreach (SPPrincipalInfo i in SPUtility.GetPrincipalsInGroup(w, name, 100, out b)) { if (i.PrincipalType == SPPrincipalType.SecurityGroup) { ResolveGroup(w, i.LoginName, users); } else { users.Add(i.LoginName); } } } List&lt;string&gt; users = new List&lt;string&gt;(); foreach (SPUser user in SPContext.Current.Web.AllUsers) { if (user.IsDomainGroup) { ResolveGroup(SPContext.Current.Web, user.LoginName, users); } else { users.Add(user.LoginName); } } </code></pre> <p><strong>Edit:</strong></p> <blockquote> <p>[...] resorting to Active Directory querying (which is something I would rather avoid because you probably need sufficient rights to do such operations [...]</p> </blockquote> <p>That's true, of course, but SharePoint has to lookup the AD as well. That's why a application pool service account is required to have read access to the AD. In other words, you should be safe executing queries against the AD if you run your code reverted to the process account.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload