Partager via


IndividuallySecurableMetadataObject.SetAccessControlList, méthode (Microsoft.Office.Server.ApplicationRegistry.Administration)

Sets the access control list for an individually securable metadata object.

Espace de noms : Microsoft.Office.Server.ApplicationRegistry.Administration
Assembly : Microsoft.SharePoint.Portal (dans microsoft.sharepoint.portal.dll)

Syntaxe

'Déclaration
Public Overridable Sub SetAccessControlList ( _
    acl As IAccessControlList _
)
'Utilisation
Dim instance As IndividuallySecurableMetadataObject
Dim acl As IAccessControlList

instance.SetAccessControlList(acl)
public virtual void SetAccessControlList (
    IAccessControlList acl
)

Paramètres

  • acl
    The IAccessControlList object to set.

Exemple

        public static void SetAccessControlListForCurrentUser()
        {
            LobSystemInstance mySysInstance = null;
            LobSystemInstanceCollection sysInsCollection = ApplicationRegistry.Instance.GetLobSystemInstancesLikeName("AdventureWorksSampleFromCode");
            foreach (LobSystemInstance sysInstance in sysInsCollection)
            {
                if (sysInstance.Name == "AdventureWorksSampleFromCode")
                {
                    mySysInstance = sysInstance;
                    break;
                }
            }
            LobSystem ls = mySysInstance.LobSystem;
            IAccessControlList acl = new BdcAccessControlList();
            String currentIdentity = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            acl.Add(new IndividualAccessControlEntry(currentIdentity, BdcRights.SetPermissions | BdcRights.Execute | BdcRights.Edit | BdcRights.UseInBusinessDataInLists | BdcRights.UseInWebParts));
            try
            {
                ls.SetAccessControlList(acl);
            }

            catch (AccessDeniedException)
            {
            }
        }


        public static void SetAccessControlList()
        {
            LobSystemInstance mySysInstance = null;
            LobSystemInstanceCollection sysInsCollection = ApplicationRegistry.Instance.GetLobSystemInstancesLikeName("AdventureWorksSampleFromCode");
            foreach (LobSystemInstance sysInstance in sysInsCollection)
            {
                if (sysInstance.Name == "AdventureWorksSampleFromCode")
                {
                    mySysInstance = sysInstance;
                    break;
                }
            }
            LobSystem ls = mySysInstance.LobSystem;

            IAccessControlList acl = ls.GetAccessControlList();
            String currentIdentity = "Redmond\\umas";
            acl.Add(new IndividualAccessControlEntry(currentIdentity, BdcRights.SetPermissions | BdcRights.Execute | BdcRights.Edit | BdcRights.UseInBusinessDataInLists | BdcRights.UseInWebParts));
            try
            {
                ls.SetAccessControlList(acl);
            }

            catch (AccessDeniedException)
            {
            }
        }

Voir aussi

Référence

IndividuallySecurableMetadataObject, classe
Membres IndividuallySecurableMetadataObject
Microsoft.Office.Server.ApplicationRegistry.Administration, espace de noms