You are creating a Microsoft Office SharePoint Server 2007 site. An audience named Purchasing contains all the users in a Microsoft Active Directory group.
You need to display the name of each member of the audience.
Which code segment should you use?
A.
AudienceManager audManager = new AudienceManager();
Audience aud = audManager.Audiences[“Purchasing”];
ArrayList members = aud.GetMembership();
foreach (object obj in members) {
UserInfo user = (UserInfo)obj;
System.Web.HttpContext.Current.Response.Write(“User: {0}” +
user.PreferredName);
}
B.
AudienceManager audManager = new AudienceManager();
AudienceCollection members = audManager.Audiences;
foreach (Audience obj in members) {
string user =
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (obj.IsMember(user))
System.Web.HttpContext.Current.Response.Write(“User: {0}” + user);
}
C.
AudienceManager audManager = new AudienceManager();
AudienceCollection audCol = audManager.Audiences;
Audience aud = audManager.Audiences[“Purchasing”];
ArrayList members = aud.GetMembership();
foreach (object obj in audCol) {
UserInfo user = (UserInfo)members[audCol.Count];
System.Web.HttpContext.Current.Response.Write(“User: {0}” +
user.PreferredName);
}
D.
Audience_List members = new Audience_List();
AudienceManager audManager = new AudienceManager();
Audience aud = audManager.Audiences[“Purchasing”];
members.GetData();
members.DataBind();