private void DownloadRolesExport() { var allright = CurrentRights.GetAllRightsMaster(); var rols = Request.Form.Get("rol"); if (rols != null) { foreach (var rol in rols.Split(',')) { var account = Sitecore.Security.Accounts.Role.FromName(rol); if (account == null) { break; } dowload.Text += "role," + account.Name + ","; int count = 0; foreach (var subrol in RolesInRolesManager.GetRolesInRole(account, false)) { if (count != 0) { dowload.Text += "|"; } dowload.Text += subrol.Name; count++; } dowload.Text += "\n"; } foreach (var rol in rols.Split(',')) { var account = Sitecore.Security.Accounts.Role.FromName(rol); if (account == null) { break; } foreach (var itemWithRights in allright) { var accessRules = itemWithRights.Security.GetAccessRules(); if (accessRules != null) { foreach (var rule in accessRules) { if (rule.Account == account) { AccessRuleCollection ruleCollection = new AccessRuleCollection(); ruleCollection.Add(rule); dowload.Text += itemWithRights.Paths.FullPath + "," + ruleCollection.ToString() + "\n"; } } } } } } Response.Clear(); Response.ContentType = "application/CSV"; Response.AddHeader("Cache-Control", "must-revalidate"); Response.AddHeader("Pragma", "must-revalidate"); Response.AddHeader("Content-type", "application/x-download"); Response.AddHeader("Content-disposition", "attachment; filename=sitecore-roles-export.csv"); }
protected override void ProcessRecord() { if (!this.CanFindAccount(Identity, AccountType.Role)) { return; } var role = Role.FromName(Identity.Name); switch (ParameterSetName) { case "Id": WriteObject(RolesInRolesManager.GetRoleMembers(role, Recursive), true); break; case "UsersOnly": WriteObject(RolesInRolesManager.GetUsersInRole(role, Recursive), true); break; case "RolesOnly": WriteObject(RolesInRolesManager.GetRolesInRole(role, Recursive), true); break; } }