Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject.ChangeRolePermissions C# (CSharp) Method

ChangeRolePermissions() public method

public ChangeRolePermissions ( RoleInfo role ) : void
role RoleInfo
return void
        public void ChangeRolePermissions(RoleInfo role)
        {
            string rolePath = Path.Combine(Paths.RootPath, role.Name);
            DirectoryInfo directoryInfo = new DirectoryInfo(rolePath);
            DirectorySecurity directoryAccess = directoryInfo.GetAccessControl(AccessControlSections.All);
            directoryAccess.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null),
                FileSystemRights.ReadAndExecute | FileSystemRights.Write, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
            directoryInfo.SetAccessControl(directoryAccess);
        }

Usage Example

Esempio n. 1
0
        public override void ExecuteCmdlet()
        {
            RootPath = RootPath ?? CommonUtilities.GetServiceRootPath(CurrentPath());
            CloudServiceProject service = new CloudServiceProject(RootPath, null);
            RoleInfo roleInfo = null;
            
            if (isWebRole)
            {
                roleInfo = service.AddWebRole(Scaffolding, Name, Instances);
            }
            else
            {
                roleInfo = service.AddWorkerRole(Scaffolding, Name, Instances);
            }

            OnProcessing(roleInfo);

            try
            {
                service.ChangeRolePermissions(roleInfo);
                SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleInfo.Name);
                WriteVerbose(string.Format(successMessage, RootPath, roleInfo.Name));
            }
            catch (UnauthorizedAccessException)
            {
                WriteWarning(Resources.AddRoleMessageInsufficientPermissions);
            }
        }
All Usage Examples Of Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject::ChangeRolePermissions