Пример #1
0
        private void UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent)
        {
            // The xml serializer will output differently if the type is not exact
            if (userPolicy.GetType() != typeof(UserPolicy))
            {
                var json = _jsonSerializer.SerializeToString(userPolicy);
                userPolicy = _jsonSerializer.DeserializeFromString <UserPolicy>(json);
            }

            var path = GetPolicyFilePath(user);

            Directory.CreateDirectory(Path.GetDirectoryName(path));

            lock (_policySyncLock)
            {
                _xmlSerializer.SerializeToFile(userPolicy, path);
                user.Policy = userPolicy;
            }

            if (fireEvent)
            {
                UserPolicyUpdated?.Invoke(this, new GenericEventArgs <User> {
                    Argument = user
                });
            }
        }
Пример #2
0
        public object Post(CustomQuery request)
        {
            _logger.Info("CustomQuery : " + request.CustomQueryString);

            Dictionary <string, object> responce = new Dictionary <string, object>();

            AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy        policy    = _userManager.GetUserPolicy(user_info.User);

            if (!policy.IsAdministrator)
            {
                return(responce);
            }

            List <List <object> > result = new List <List <object> >();
            List <string>         colums = new List <string>();
            string message = repository.RunCustomQuery(request.CustomQueryString, colums, result);

            int index_of_user_col = colums.IndexOf("UserId");

            if (request.ReplaceUserId && index_of_user_col > -1)
            {
                colums[index_of_user_col] = "UserName";

                Dictionary <string, string> user_map = new Dictionary <string, string>();
                foreach (var user in _userManager.Users)
                {
                    user_map.Add(user.Id.ToString("N"), user.Name);
                }

                foreach (var row in result)
                {
                    String user_id = (string)row[index_of_user_col];
                    if (user_map.ContainsKey(user_id))
                    {
                        row[index_of_user_col] = user_map[user_id];
                    }
                }
            }


            /*
             * List<object> row = new List<object>();
             * row.Add("Shaun");
             * row.Add(12);
             * row.Add("Some Date");
             * result.Add(row);
             *
             * colums.Add("Name");
             * colums.Add("Age");
             * colums.Add("Started");
             */

            responce.Add("colums", colums);
            responce.Add("results", result);
            responce.Add("message", message);

            return(responce);
        }
Пример #3
0
        private bool CanAccessDevice(UserPolicy policy, string id)
        {
            if (policy.EnableAllDevices)
            {
                return(true);
            }

            return(ListHelper.ContainsIgnoreCase(policy.EnabledDevices, id));
        }
Пример #4
0
        /// <summary>
        /// Create User Policy
        /// </summary>
        /// <example>
        /// {
        /// "Active": true,
        /// "Policy": {
        /// "Id": "123"
        /// }
        /// }
        /// </example>
        /// <remarks>
        /// Assigns a Policy to a user
        /// </remarks>
        /// <param name="url"></param>
        /// <param name="policy"></param>
        /// <returns>
        /// Returns newly assigned Policy
        /// </returns>
        public IQuery <UserPolicy> CreateByUser(Uri url, UserPolicy policy)
        {
            var sfApiQuery = new ShareFile.Api.Client.Requests.Query <UserPolicy>(Client);

            sfApiQuery.Action("Policies");
            sfApiQuery.Uri(url);
            sfApiQuery.Body       = policy;
            sfApiQuery.HttpMethod = "POST";
            return(sfApiQuery);
        }
Пример #5
0
 public void CreateUserPolicy(UserPolicy userPolicy)
 {
     using (VoteContext voteContext = new VoteContext())
     {
         voteContext.Users.Attach(userPolicy.user);
         voteContext.Entry(userPolicy.user).State = System.Data.Entity.EntityState.Unchanged;
         voteContext.UserPolicies.Add(userPolicy);
         voteContext.SaveChanges();
     }
 }
Пример #6
0
        /// <summary>
        /// Update a single UserPolicy
        /// </summary>
        /// <example>
        /// {
        /// "Active": false
        /// }
        /// </example>
        /// <remarks>
        /// Updates a single user Policy. Currently this only allows an update to the Active flag.
        /// </remarks>
        /// <param name="url"></param>
        public IQuery <UserPolicy> UpdateByUser(Uri url, string id, UserPolicy updatedPolicy)
        {
            var sfApiQuery = new ShareFile.Api.Client.Requests.Query <UserPolicy>(Client);

            sfApiQuery.Action("Policies");
            sfApiQuery.Uri(url);
            sfApiQuery.ActionIds(id);
            sfApiQuery.Body       = updatedPolicy;
            sfApiQuery.HttpMethod = "PATCH";
            return(sfApiQuery);
        }
Пример #7
0
 private static void PCheckUserPolicyCompliance(string userName, UserPolicy usrPolicy)
 {//by lara
     if (userName.Length < usrPolicy.UserdMinLength)
     {
         throw new UserPolicyException("The username does not have a length of at least " + usrPolicy.UserdMinLength + " characters");
     }
     if (userName.Length > usrPolicy.UserMaxLength)
     {
         throw new UserPolicyException("The username is longer than " + usrPolicy.UserMaxLength + " characters");
     }
 }
Пример #8
0
        /// <summary>
        /// Gets user policy object that is set-able.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static UserPolicy GetUserPolicyObject(string userID)
        {
            UserPolicy policy = new UserPolicy();

            policy.UserID            = userID;
            policy.FileSizeLimit     = policy.SpaceLimit = policy.SyncInterval = policy.SharingStatus = policy.EncryptionStatus = -1;
            policy.FileTypesExcludes = policy.FileTypesIncludes = null;
            policy.NoiFoldersLimit   = -3;
            policy.LoginEnabled      = true;
            return(policy);
        }
Пример #9
0
        private void SetUserSharedPolicy(UserPolicy policy, UserOptions shared = null)
        {
            if (shared == null)
            {
                shared = _sharedPolicyAccessor.GetPolicy().User;
            }

            shared.AllowedUserNameCharacters = policy.AllowedUserNameCharacters;
            shared.RequireUniqueEmail        = policy.RequireUniqueEmail;

            _sharedPolicyAccessor.SetUserPolicy(shared);
        }
Пример #10
0
 public static Boolean TryUserNamePolicyCompliance(String username, UserPolicy usrPolicy, ref UserPolicyException usrPolicyException)
 {
     try
     {//by lara
         PCheckUserPolicyCompliance(username, usrPolicy);
         return(true);
     }
     catch (UserPolicyException ex)
     {
         usrPolicyException = ex;
     }
     return(false);
 }
Пример #11
0
        /// <summary>
        /// Gets the file type policy for the current user.
        /// </summary>
        /// <param name="policy">User policy.</param>
        public void GetFileTypePolicy(UserPolicy policy)
        {
            // Show new file type controls
            NewFileTypeName.Visible = AddButton.Visible = true;

            // Create a list from the file type policy.
            FileTypeSource = CreateFileTypeSource(policy);

            // Build the data view from the table.
            FileTypeList.DataSource = CreateFileTypeListView();
            FileTypeList.DataBind();
            SetPageButtonState();
        }
Пример #12
0
        private bool CanAccessDevice(UserPolicy policy, string id)
        {
            if (policy.EnableAllDevices)
            {
                return(true);
            }

            if (policy.IsAdministrator)
            {
                return(true);
            }

            return(policy.EnabledDevices.Contains(id, StringComparer.OrdinalIgnoreCase));
        }
Пример #13
0
        private bool CanAccessDevice(UserPolicy policy, string id)
        {
            if (policy.EnableAllDevices)
            {
                return true;
            }

            if (policy.IsAdministrator)
            {
                return true;
            }

            return ListHelper.ContainsIgnoreCase(policy.EnabledDevices, id);
        }
Пример #14
0
        public object Get(TypeFilterList request)
        {
            AuthorizationInfo auth_user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy        policy         = _userManager.GetUserPolicy(auth_user_info.User);

            if (!policy.IsAdministrator)
            {
                return(new List <string>());
            }

            List <string> filter_list = repository.GetTypeFilterList();

            return(filter_list);
        }
Пример #15
0
        /// <summary>
        /// Bind the Data to the Page.
        /// </summary>
        private void BindData()
        {
            long used  = 0;
            long limit = 0;

            ifolderID = Request.QueryString.Get("iFolder");

            if ((ifolderID != null) && (ifolderID.Length != 0))
            {
                // ifolder
                iFolderPolicy policy = web.GetiFolderPolicy(ifolderID);
                used  = policy.SpaceUsed;
                limit = policy.SpaceLimitEffective;

                Title.Text = GetString("IFOLDERQUOTA");
            }
            else
            {
                // global
                try
                {
                    UserPolicy policy = web.GetAuthenticatedUserPolicy();
                    used  = policy.SpaceUsed;
                    limit = policy.SpaceLimitEffective;

                    Title.Text = GetString("HOMEQUOTA");
                }
                catch (Exception e)
                {
//					Title.Text = e.Message;
                }
            }

            // used
            SpaceUsed.Text = WebUtility.FormatSize(used, rm);

            // limit
            if (limit == -1)
            {
                // no limit
                SpaceAvailable.Text = GetString("NOLIMIT");
            }
            else
            {
                // limit

                long Available = (limit - used) >= 0 ? (limit - used) : 0;
                SpaceAvailable.Text = WebUtility.FormatSize(Available, rm);
            }
        }
Пример #16
0
        public object Get(GetBreakdownReport request)
        {
            AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy        policy    = _userManager.GetUserPolicy(user_info.User);

            if (!policy.IsAdministrator)
            {
                return(new List <Dictionary <string, object> >());
            }

            DateTime end_date;

            if (string.IsNullOrEmpty(request.end_date))
            {
                end_date = DateTime.Now;
            }
            else
            {
                _logger.Info("End_Date: " + request.end_date);
                end_date = DateTime.ParseExact(request.end_date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
            }

            List <Dictionary <string, object> > report = repository.GetBreakdownReport(request.user_id, request.days, end_date, request.BreakdownType);

            if (request.BreakdownType == "UserId")
            {
                foreach (var row in report)
                {
                    string user_id = row["label"] as string;
                    MediaBrowser.Controller.Entities.User user = null;
                    if (!string.IsNullOrEmpty(user_id))
                    {
                        Guid user_guid = new Guid(user_id);
                        user = _userManager.GetUserById(user_guid);
                    }

                    if (user != null)
                    {
                        row["label"] = user.Name;
                    }
                    else
                    {
                        row["label"] = "unknown";
                    }
                }
            }

            return(report);
        }
Пример #17
0
        /// <summary>
        /// Gets the account policy for the current user.
        /// </summary>
        /// <param name="policy">User policy object</param>
        public void GetEncryptionPolicy(UserPolicy policy)
        {
            int securityStatus = policy.EncryptionStatus;

            encryption.Checked = enforceEncryption.Checked = ssl.Checked = enforceSSL.Checked = false;
            SystemPolicy SystemPolicy    = web.GetSystemPolicy();
            int          SysEncrPolicy   = SystemPolicy.EncryptionStatus;
            int          GroupEncrPolicy = web.GetGroupEncryptionPolicy(policy.UserID);
            int          DerivedStatus   = 0;

            Session["SharingWasEnforced"]   = "false";
            Session["EncryptionWasChecked"] = "false";
            DerivedStatus = DeriveStatus(SysEncrPolicy, GroupEncrPolicy, securityStatus, securityStatus);
            if (DerivedStatus != 0)
            {
                if ((DerivedStatus & (int)Encryption.Encrypt) == (int)Encryption.Encrypt)
                {
                    encryption.Enabled = false;
                    Session["EncryptionWasChecked"] = "true";
                    if ((DerivedStatus & (int)Encryption.EnforceEncrypt) == (int)Encryption.EnforceEncrypt)
                    {
                        encryption.Checked        = enforceEncryption.Checked = true;
                        enforceEncryption.Enabled = true;
                    }
                    else
                    {
                        encryption.Checked        = true;
                        enforceEncryption.Checked = false;
                        enforceEncryption.Enabled = true;
                    }
                    // next check for bug id 296014 , where if this user has created an encrypted iFolder then disable
                    // the encryption check box for him.
                    if (IsUser)
                    {
                        if (web.IsPassPhraseSetForUser(Request.Params["ID"]))
                        {
                            encryption.Enabled = false;
                        }
                    }
                }
                else if ((DerivedStatus & (int)Encryption.EnforceSSL) == (int)Encryption.EnforceSSL)
                {
                    // this is the case of enforceSharing for the particular user on userlevel policy
                    encryption.Checked            = enforceEncryption.Checked = false;
                    Session["SharingWasEnforced"] = "true";
                }
            }
        }
Пример #18
0
        public async Task <UserPolicy> SetUserPolicy(UserPolicy policy)
        {
            using (var ctx = new UserDbContext(_options))
            {
                var ent = await ctx.UserPolicies.AddAsync(policy.ToEntity());

                var cnt = await ctx.SaveChangesAsync();

                if (cnt < 1 || cnt > 2)
                {
                    throw new Exception("There was an error updating the User Policy record.");
                }

                return(ent.Entity.ToModel());
            }
        }
        internal static UserPolicyEntity ToEntity(this UserPolicy model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new UserPolicyEntity
            {
                Id = model.Id,
                Created = model.Created,
                CreatedById = model.CreatedById,
                AllowedUserNameCharacters = model.AllowedUserNameCharacters,
                RequireUniqueEmail = model.RequireUniqueEmail
            });
        }
Пример #20
0
        public bool GivePolicyToUser(int userId, int pollId)
        {
            if (_userRepos.GetUser(userId) == null)
            {
                return(false);
            }
            UserPolicy userPolicy = new UserPolicy()
            {
                PolicyType = (PolicyType)0,
                user       = _userRepos.GetUser(userId),
                PollId     = pollId
            };

            _userRepos.CreateUserPolicy(userPolicy);
            return(true);
        }
Пример #21
0
        public object Get(LoadBackup load_backup)
        {
            AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy        policy    = _userManager.GetUserPolicy(user_info.User);

            if (!policy.IsAdministrator)
            {
                return(new List <string>()
                {
                    "Not Authorized"
                });
            }

            FileInfo fi = new FileInfo(load_backup.backupfile);

            if (fi.Exists == false)
            {
                return(new List <string>()
                {
                    "Backup file does not exist"
                });
            }

            int count = 0;

            try
            {
                string load_data = "";
                using (StreamReader sr = new StreamReader(new FileStream(fi.FullName, FileMode.Open)))
                {
                    load_data = sr.ReadToEnd();
                }
                count = repository.ImportRawData(load_data);
            }
            catch (Exception e)
            {
                return(new List <string>()
                {
                    e.Message
                });
            }

            return(new List <string>()
            {
                "Backup loaded " + count + " items"
            });
        }
Пример #22
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext filterContext, ActionExecutionDelegate next)
        {
            UserPolicy policy = new UserPolicy(_context, HttpContext, this.ControllerContext.RouteData);

            if (await policy.isAdmin() == false)
            {
                filterContext.Result = new RedirectResult(Url.Action("Index", "Home"));
                this.OnActionExecuting(filterContext);
            }
            else
            {
                this.OnActionExecuting(filterContext);
                var resultContext = await next();

                this.OnActionExecuted(resultContext);
            }
        }
Пример #23
0
        public object Get(GetHourlyReport request)
        {
            AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy        policy    = _userManager.GetUserPolicy(user_info.User);

            if (!policy.IsAdministrator)
            {
                return(new SortedDictionary <string, int>());
            }

            string[] filter_tokens = new string[0];
            if (request.filter != null)
            {
                filter_tokens = request.filter.Split(',');
            }

            DateTime end_date;

            if (string.IsNullOrEmpty(request.end_date))
            {
                end_date = DateTime.Now;
            }
            else
            {
                _logger.Info("End_Date: " + request.end_date);
                end_date = DateTime.ParseExact(request.end_date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
            }

            SortedDictionary <string, int> report = repository.GetHourlyUsageReport(request.user_id, request.days, end_date, filter_tokens);

            for (int day = 0; day < 7; day++)
            {
                for (int hour = 0; hour < 24; hour++)
                {
                    string key = day + "-" + hour.ToString("D2");
                    if (report.ContainsKey(key) == false)
                    {
                        report.Add(key, 0);
                    }
                }
            }

            return(report);
        }
Пример #24
0
        /// <summary>
        /// Sets the enabled status on all selected users.
        /// </summary>
        /// <param name="status">If true then all selected users will be enabled.</param>
        private void SetSelectedUserStatus(bool status)
        {
            foreach (string userID in CheckedUsers.Keys)
            {
                // Don't set the status if already set.
                if (( bool )CheckedUsers[userID] != status)
                {
                    /// Check for the policy for the groupadmin...
                    int preference = GetRightsForUser(userID);
                    if (preference != -1 && preference != 0xffff)
                    {
                        UserGroupAdminRights rights = new UserGroupAdminRights((int)preference);
                        if (rights.EnableDisableUserAllowed == false)
                        {
                            continue;
                        }
                    }

                    UserPolicy policy = Utils.GetUserPolicyObject(userID);
                    policy.LoginEnabled = status;
                    try
                    {
                        web.SetUserPolicy(policy);
                    }
                    catch (Exception ex)
                    {
                        string errMsg = String.Format(GetString("ERRORCANNOTSETUSERPOLICY"), userID);
                        TopNav.ShowError(errMsg, ex);
                        return;
                    }
                }
            }

            // Clear the checked members.
            CheckedUsers.Clear();
            AllUsersCheckBox.Checked = false;

            // Set the action buttons.
            SetActionButtons();

            // Rebind the data source with the new data.
            GetUsers();
        }
Пример #25
0
        /// <summary>
        /// Sets the  policy for the user.
        /// </summary>
        /// <param name="policy">User policy where the information will be set.</param>
        public void SetDisableSharingPolicy(UserPolicy policy, string PolicyID)
        {
            int          DisableSharingStatus = 0;
            int          UserDisableStatus    = policy.DisableSharingStatus;
            SystemPolicy systemPolicy         = web.GetSystemPolicy();
            int          SystemDisableStatus  = systemPolicy.DisableSharingStatus;


            if (((UserDisableStatus & (int)DisableShare.EnableSharing) == (int)DisableShare.EnableSharing) && disableSharingOn.Checked == false)
            {
                /// it means for this user , admin has enable the sharing on UserDetails page, so retain that
                DisableSharingStatus += (int)DisableShare.EnableSharing;                  //8
            }
            /// if for this user disable sharing was "on" (either on user level or system level) and now admin has unchecked the checkbox then also store enable sharing -- 8
            else if ((((SystemDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing) || ((UserDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing)) && disableSharingOn.Checked == false)
            {
                DisableSharingStatus += (int)DisableShare.EnableSharing;                  //8
            }

            if (disableSharingOn.Checked && UserDisableStatus != 0)
            {
                /// add this value only if on user level some policy was set
                DisableSharingStatus += (int)DisableShare.DisableSharing;                 //1;
            }
            else if (disableSharingOn.Checked && (SystemDisableStatus == 0))
            {
                DisableSharingStatus += (int)DisableShare.DisableSharing;                 //1;
            }

            if (enforcedDisableSharing.Checked)
            {
                DisableSharingStatus += (int)DisableShare.EnforcedDisableSharing;                 //4;
            }
            policy.DisableSharingStatus = DisableSharingStatus;

            /// Next change is to remove the past sharing
            if (disablePastSharing.Checked)
            {
                /// pass the userID
                web.DisableUserPastSharing(PolicyID);
                disablePastSharing.Checked = false;
            }
        }
Пример #26
0
        /// <summary>
        /// Gets the disk quota policy for the current user.
        /// </summary>
        /// <param name="policy">User policy object</param>
        public void GetDiskSpacePolicy(UserPolicy policy)
        {
            EffectiveSpace = policy.SpaceLimitEffective;

            Enabled.Checked = LimitValue.Enabled = (policy.SpaceLimit >= 0);

            UsedValue.Text = Utils.ConvertToMBString(policy.SpaceUsed, false, rm);
            UsedUnits.Text = GetString("MB");

            LimitValue.Text = Enabled.Checked ?
                              Utils.ConvertToMBString(policy.SpaceLimit, false, rm) : String.Empty;


            if ((policy.SpaceLimitEffective >= 0) || (policy.SpaceLimit >= 0))
            {
                AvailableValue.Text = Utils.ConvertToMBString(policy.SpaceAvailable, false, rm);
                AvailableUnits.Text = GetString("MB");
            }
            else
            {
                AvailableValue.Text = GetString("UNLIMITED");
                AvailableUnits.Text = String.Empty;
            }

            if (Enabled.Checked)
            {
                EffectiveTag.Visible = EffectiveValue.Visible = EffectiveUnits.Visible = false;
            }
            else
            {
                EffectiveTag.Visible = EffectiveValue.Visible = EffectiveUnits.Visible = true;
                if (policy.SpaceLimitEffective >= 0)
                {
                    EffectiveValue.Text = Utils.ConvertToMBString(policy.SpaceLimitEffective, false, rm);
                    EffectiveUnits.Text = GetString("MB");
                }
                else
                {
                    EffectiveValue.Text = GetString("UNLIMITED");
                    EffectiveUnits.Text = String.Empty;
                }
            }
        }
Пример #27
0
        public ActionResult UpdateUserPolicy(
            [FromRoute, Required] Guid userId,
            [FromBody] UserPolicy newPolicy)
        {
            if (newPolicy == null)
            {
                return(BadRequest());
            }

            var user = _userManager.GetUserById(userId);

            // If removing admin access
            if (!newPolicy.IsAdministrator && user.HasPermission(PermissionKind.IsAdministrator))
            {
                if (_userManager.Users.Count(i => i.HasPermission(PermissionKind.IsAdministrator)) == 1)
                {
                    return(Forbid("There must be at least one user in the system with administrative access."));
                }
            }

            // If disabling
            if (newPolicy.IsDisabled && user.HasPermission(PermissionKind.IsAdministrator))
            {
                return(Forbid("Administrators cannot be disabled."));
            }

            // If disabling
            if (newPolicy.IsDisabled && !user.HasPermission(PermissionKind.IsDisabled))
            {
                if (_userManager.Users.Count(i => !i.HasPermission(PermissionKind.IsDisabled)) == 1)
                {
                    return(Forbid("There must be at least one enabled user in the system."));
                }

                var currentToken = _authContext.GetAuthorizationInfo(Request).Token;
                _sessionManager.RevokeUserTokens(user.Id, currentToken);
            }

            _userManager.UpdatePolicy(userId, newPolicy);

            return(NoContent());
        }
Пример #28
0
        /// <summary>
        /// Sets the policy for the user.
        /// </summary>
        /// <param name="policy">iFolder policy where the  information will be set.</param>
        public void SetDisableSharingPolicy(iFolderPolicy policy, string PolicyID)
        {
            int          DisableSharingStatus = 0;
            iFolder      ifolder              = web.GetiFolder(PolicyID);
            string       OwnerID              = ifolder.OwnerID;
            SystemPolicy systemPolicy         = web.GetSystemPolicy();
            UserPolicy   userPolicy           = web.GetUserPolicy(OwnerID);
            int          iFolderDisableStatus = policy.DisableSharingStatus;
            int          UserDisableStatus    = userPolicy.DisableSharingStatus;
            int          SystemDisableStatus  = systemPolicy.DisableSharingStatus;

            if (((iFolderDisableStatus & (int)DisableShare.EnableSharing) == (int)DisableShare.EnableSharing) && disableSharingOn.Checked == false)
            {
                /// it means for this iFolder , admin had earlier enabled the sharing on iFolderDetails page, so retain that
                DisableSharingStatus += (int)DisableShare.EnableSharing;                  //8
            }
            else if ((((SystemDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing) || ((UserDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing) || ((iFolderDisableStatus & (int)DisableShare.DisableSharing) == (int)DisableShare.DisableSharing)) && disableSharingOn.Checked == false)
            {
                /// if for this iFolder , disable sharing was "on" (either iFolder, user or system level) , and now admin has unchecked the box , then also store enable sharing -- 8
                DisableSharingStatus += (int)DisableShare.EnableSharing;                  //8
            }
            if (disableSharingOn.Checked && iFolderDisableStatus != 0)
            {
                /// consider the case when no disable of sharing on iFolder level but disable past sharing is applied.
                DisableSharingStatus += (int)DisableShare.DisableSharing;                 //1;
            }
            else if (disableSharingOn.Checked && (UserDisableStatus == 0 || ((UserDisableStatus & (int)DisableShare.EnableSharing) == (int)DisableShare.EnableSharing)))
            {
                /// if on user level, it was enabled and then if on iFolder level it is disabled , then for that case
                DisableSharingStatus += (int)DisableShare.DisableSharing;                 //1;
            }

            policy.DisableSharingStatus = DisableSharingStatus;

            /// Next change is to remove the past sharing ,
            if (disablePastSharing.Checked)
            {
                /// pass the iFolderID
                web.DisableiFolderPastSharing(PolicyID);
                disablePastSharing.Checked = false;
            }
        }
Пример #29
0
        public object Get(SaveBackup save_backup)
        {
            AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy        policy    = _userManager.GetUserPolicy(user_info.User);

            if (!policy.IsAdministrator)
            {
                return(new List <string>()
                {
                    "Not Authorized"
                });
            }

            BackupManager bum     = new BackupManager(_config, _logger, _fileSystem);
            string        message = bum.SaveBackup();

            return(new List <string>()
            {
                message
            });
        }
Пример #30
0
        public bool IsEnabledToSendToUser(string type, string userId, UserPolicy userPolicy)
        {
            NotificationOption opt = GetOptions(type);

            if (opt != null && opt.Enabled)
            {
                if (opt.SendToUserMode == SendToUserType.All)
                {
                    return(true);
                }

                if (opt.SendToUserMode == SendToUserType.Admins && userPolicy.IsAdministrator)
                {
                    return(true);
                }

                return(ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId));
            }

            return(false);
        }
        /// <summary>
        /// Creates a list of permissions using the specified list of supported rights and the specified protection policy
        /// </summary>
        /// <param name="supportedRights">The supported rights</param>
        /// <param name="policy">The current protection policy</param>
        /// <param name="permissions">The output permissions collection</param>
        public static void CreateListFromPolicy(IEnumerable<string> supportedRights, UserPolicy policy, IList<Permission> permissions)
        {
            permissions.Clear();

            if (policy == null || policy.AccessCheck(CommonRights.Owner))
            {
                // If this is the owner, show only the owner right
                permissions.Add(new Permission(CommonRights.Owner, true));
            }
            else
            {
                foreach (var right in supportedRights)
                {
                    // Don't show the owner right
                    if (String.Compare(right, CommonRights.Owner, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        permissions.Add(new Permission(right, policy.AccessCheck(right)));
                    }
                }
            }
        }