How to: create a rule-based Access Group

Source: Internet
Author: User

Microsoft SharePoint Server 2010 allows you to set content targets based on access group rules, Sharepoint groups, and Microsoft Exchange distribution list (DL) membership. In addition, Sharepoint Server 2010 provides the ability to set content targets at the list item level, not just at the list level.

This code example shows how to create a rule-based access group that can be set as the content target.

Note

In this example, only the access group is created. No access group is collected and no rules are added. You can use the user interface or object model to add rules, and then use the user interface to collect access groups. The object model does not support collecting access groups.

Before running this sample code, add the following references to the Microsoft Visual Studio project:

Microsoft. Office. server. dll

Microsoft. Office. server. userprofiles. dll

Microsoft. Sharepoint. dll

System. Web. dll

 

 

Using system; using system. collections. generic; using system. text; using Microsoft. sharepoint. administration; using Microsoft. office. server. audience; using Microsoft. sharePoint; using Microsoft. office. server; using system. web; namespace audienceconsoleapp {class program {static void main (string [] ARGs) {try {using (spsite site = new spsite ("http: // MOSS: 8001 ")) {spservicecontext context = spservicecontext. getcontext (SITE); audiencemanager audmanager = new audiencemanager (context); audiencecollection AC = audmanager. audiences; audience A = NULL; string saudname = "moss2010 rule access group"; string sdescription = "moss2010 rule access group"; try {A = ac. create (saudname, sdescription );

Console. writeline ("created successfully ");
Console. Read ();

                    }                    catch (AudienceDuplicateNameException e)                    {                        //Your exception handling code here                    }                    catch (AudienceException e1)                    {                        //Your exception handling code here                    }                }            }            catch (Exception exception)            {                Console.WriteLine(exception.ToString());                Console.Read();            }        }    }}

Open the target access group of a list in http: // MOSS: 8001.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.