/// <summary>
        /// Update ACL recusive async function
        /// </summary>
        protected override async Task OperationAclResusive(long taskId)
        {
            IStorageBlobManagement localChannel = Channel;

            progressRecord    = GetProgressRecord("Update", taskId);
            continuationToken = this.ContinuationToken;

            bool foundAFolder = false;

            DataLakeFileClient      fileClient = null;
            DataLakeDirectoryClient dirClient  = null;

            DataLakeFileSystemClient fileSystem = GetFileSystemClientByName(localChannel, this.FileSystem);

            foundAFolder = GetExistDataLakeGen2Item(fileSystem, this.Path, out fileClient, out dirClient);


            if (foundAFolder)
            {
                if (ShouldProcess(dirClient.Uri.ToString(), "Update Acl recursively on Directory: "))
                {
                    await dirClient.UpdateAccessControlRecursiveAsync(PSPathAccessControlEntry.ParseAccessControls(this.Acl),
                                                                      continuationToken,
                                                                      GetAccessControlChangeOptions(taskId),
                                                                      CmdletCancellationToken).ConfigureAwait(false);

                    SetProgressComplete();
                    WriteResult(taskId);
                }
            }
            else
            {
                if (ShouldProcess(fileClient.Uri.ToString(), "Update Acl recursively on File: "))
                {
                    await fileClient.UpdateAccessControlRecursiveAsync(PSPathAccessControlEntry.ParseAccessControls(this.Acl),
                                                                       continuationToken,
                                                                       GetAccessControlChangeOptions(taskId),
                                                                       CmdletCancellationToken).ConfigureAwait(false);

                    SetProgressComplete();
                    WriteResult(taskId);
                }
            }
        }
Ejemplo n.º 2
0
        // </Snippet_SetACLRecursively>

        #endregion

        #region Update ACLs recursively

        // <Snippet_UpdateACLsRecursively>
        public async Task UpdateACLsRecursively(DataLakeServiceClient serviceClient, bool isDefaultScope)
        {
            DataLakeDirectoryClient directoryClient =
                serviceClient.GetFileSystemClient("my-container").
                GetDirectoryClient("my-parent-directory");

            List <PathAccessControlItem> accessControlListUpdate =
                new List <PathAccessControlItem>()
            {
                new PathAccessControlItem(AccessControlType.User,
                                          RolePermissions.Read |
                                          RolePermissions.Write |
                                          RolePermissions.Execute, isDefaultScope,
                                          entityId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"),
            };

            await directoryClient.UpdateAccessControlRecursiveAsync
                (accessControlListUpdate, null);
        }