Create an audience which contains an Active Directory Group

In the SDK are examples on how to create an audience which adds a rule like:

   1: AudienceRuleComponent r1 = new AudienceRuleComponent("FirstName", "Contains", "John");

 

But how do you create a rule which takes the membership of an Active Directory Group? Well, look at this:

   1: string groupName = "CN=Users,CN=Builtin,DC=domain,DC=tld";
<pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, 'Courier New', courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none"><span style="color:#606060">   2:</span> AudienceRuleComponent r1 = <span style="color:#0000ff">new</span> AudienceRuleComponent(<span style="color:#006080">"DL"</span>, <span style="color:#006080">"Member of"</span>, groupName);</pre>

To get the ‘distinguishedName’ from a group, you can use ADSI Edit (open up a MMC and add the ADSI Edit Snap-In).

Keywords: Audience, AD, Gruppe, Active Directory, group, SharePoint, Member of