Tags

,

I have searched for a solution to get all users from a SharePoint group and found nothing simple. Mostly all solutions are C# based. But looking on Microsoft website I discovered membership CAML clause. This was perfect fit for me. I created a SPDataSource for this and worked. See code below.

<SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;Membership Type=&quot;SPGroup&quot; ID=&quot;108&quot;&gt;&lt;FieldRef Name=&quot;ID&quot;/&gt;&lt;/Membership&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;EMail&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" ID="DSUsers">
<SelectParameters><asp:Parameter Name="ListName" DefaultValue="User Information List" /></SelectParameters>
</SharePoint:SPDataSource>

SPDataSource above is displaying all users from SharePoint group with ID 108. Of course in your case this ID will be different. Decoded CAML looks like this.

<View><Query><Where><Membership Type="SPGroup" ID="108"><FieldRef Name="ID"/></Membership></Where><OrderBy><FieldRef Name="EMail"/></OrderBy></Query></View>
Advertisements