catch(AudienceException e)
{}5、获取访问群体的成员下面的代码将访问群体的成员的WindowsNT系统名称显示了出来。
TopologyManager topology = new TopologyManager();
PortalSite portal = topology.PortalSites[new Uri("http://server_name")];
PortalContext context = PortalApplication.GetContext(portal);
AudienceManager AudMgr = new AudienceManager(context);
try
{
ArrayList memarray = AudMgr.Audiences["Engineer"].GetMembership();
foreach(UserInfo o in memarray)
{
Console.WriteLine(o.NTName);
}
}
catch(AudienceException e)
{}
6、显示用户所隶属于的访问群体已此类推,我们也可以显示一个用户所隶属于德所有访问群体。
TopologyManager topology = new TopologyManager();
PortalSite portal = topology.PortalSites[new Uri("http://server_name")];
PortalContext context = PortalApplication.GetContext(portal);
AudienceManager AudMgr = new AudienceManager(context);
try
{
//传入一个Windows帐号名来获取隶属于的访问群体组。
//如果要获取当前用户的隶属访问群体组,只要不指定任何参数直接GetUserAudienceIDs()就可以了
ArrayList audienceIDNames = AudMgr.GetUserAudienceIDs("domain_name\\alias");
ArrayList audienceNames = new ArrayList();
for (int i=0; i<audienceIDNames.Count; i++)
{
AudienceNameID arrTemp = (AudienceNameID) audienceIDNames[i];
audienceNames.Add(arrTemp.AudienceName);
Console.WriteLine(audienceNames[i].ToString());
}
}
catch(AudienceException e)
{}
7、得到规程操作符的显示名称和内部名称可以用下面的代码看看这些操作符在Web管理页面中怎么叫。
TopologyManager topology = new TopologyManager();
PortalSite portal = topology.PortalSites[new Uri("http://server_name")];
PortalContext context = PortalApplication.GetContext(portal);
AudienceManager AudMgr = new AudienceManager(context);
ArrayList OpList = AudMgr.AudienceOperatorList;
for (int list=0; list < OpList.Count; list++)
{
Console.WriteLine(list.ToString());
Console.WriteLine(" Name: {0}" , ((AudienceOperator)OpList[list]).OperatorName);
Console.WriteLine(" DisplayName: {0}" , ((AudienceOperator)OpList[list]).OperatorDisplayName);
}
8、得到规则操作符左侧操作数允许使用的名称可以用下面的代码看看可以用作规则操作符左侧操作数的所有内容。包括在Web管理页面中显示的名称和我们在编程时使用的内部名称。上面有提到的“Everyone”,“DL”就包括在这里,还有好多活动目录中有的属性,值得细细去查看。
TopologyManager topology = new TopologyManager();
PortalSite portal = topology.PortalSites[new Uri("http://server_name")];
PortalContext context = PortalApplication.GetContext(portal);
AudienceManager AudMgr = new AudienceManager(context);
ArrayList LeftContentList;
LeftContentList = AudMgr.AudienceLeftContentList;
for (int list=0; list < LeftContentList.Count; list++)
{
Console.WriteLine(list.ToString());
Console.WriteLine(" Name: " + ((AudienceLeftContent)LeftContentList[list]).Name);
Console.WriteLine(" DisplayName: " + ((AudienceLeftContent)LeftContentList[list]).DisplayName);
Console.WriteLine(" DataType: " + ((AudienceLeftContent)LeftContentList[list]).DataType);
Console.WriteLine(" DataLength: " + ((AudienceLeftContent)LeftContentList[list]).DataLength);
Console.WriteLine(" bProperty: " + ((AudienceLeftContent)LeftContentList[list]).bProperty);
}
(完)