Ejemplo n.º 1
0
        public static string GetHelperText(string line, int rightsType, out Tuple <string, string, TreeViewItem[]> details, bool translateSID)
        {
            var sd = new SecurityDescriptor(line);

            if (sd.IsOk)
            {
                var lSIDs   = sd.GetAllSIDs();
                var lRights = sd.GetAllRights();
                var sb      = new StringBuilder();
                if (lSIDs.Count != 0)
                {
                    sb.AppendLine();
                    sb.AppendLine("SIDs:");
                    sb.AppendLine("-----");
                    foreach (var lSID in lSIDs)
                    {
                        sb.AppendLine(SecurityDescriptor.SIDToLong(lSID, translateSID));
                    }
                    sb.AppendLine("-----");
                }
                if (lRights.Count != 0)
                {
                    sb.AppendLine();
                    sb.AppendLine("Rights (" + ACE.RightType(rightsType) + "):");
                    sb.AppendLine("-----");
                    foreach (var lRight in lRights)
                    {
                        sb.AppendLine(ACE.RigthToLong(lRight, rightsType));
                    }
                    sb.AppendLine("-----");
                }
                var aces         = sd.GetACEs();
                var treeElements = new TreeViewItem[aces.Count];
                for (var i = 0; i < aces.Count; i++)
                {
                    treeElements[i] = ACEToTreeViewItem(aces[i], rightsType, translateSID);
                }
                details = new Tuple <string, string, TreeViewItem[]>(sd.GetOwner(), sd.GetGroup(), treeElements);
                return(sb.ToString());
            }
            details = new Tuple <string, string, TreeViewItem[]>("", "", new TreeViewItem[0]);
            return(string.Empty);
        }