コード例 #1
0
        /// <summary>
        /// Renders the Access Control Entry as an SDDL ACE string
        /// </summary>
        /// <returns>An SDDL ACE string.</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("{0};", aceTypeStrings[(int)aceType]);

            for (var flag = 0x01; flag <= (int)AceFlags.AuditFailure; flag = flag << 1)
            {
                if ((flag & (int)flags) == flag)
                {
                    sb.Append(aceFlagStrings[(int)Math.Log(flag, 2.0d)]);
                }
            }

            sb.Append(';');

            foreach (var right in this)
            {
                sb.Append(rightsStrings[(int)Math.Log((int)right, 2.0d)]);
            }

            sb.Append(';');

            sb.AppendFormat("{0};", objectGuid != Guid.Empty ? objectGuid.ToString() : "");

            sb.AppendFormat("{0};", inheritObjectGuid != Guid.Empty ? inheritObjectGuid.ToString() : "");

            if (accountSID != null)
            {
                sb.Append(accountSID.ToString());
            }

            return(sb.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Renders the Security Descriptor as an SDDL string
        /// </summary>
        /// <remarks>For more info on SDDL see <a href="http://msdn.microsoft.com/library/en-us/secauthz/security/security_descriptor_string_format.asp">MSDN: Security Descriptor String Format.</a></remarks>
        /// <returns>An SDDL string</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();

            if (ownerSid != null)
            {
                sb.AppendFormat("O:{0}", ownerSid.ToString());
            }

            if (groupSid != null)
            {
                sb.AppendFormat("G:{0}", groupSid.ToString());
            }

            if (dacl != null)
            {
                sb.AppendFormat("D:{0}", dacl.ToString());
            }

            if (sacl != null)
            {
                sb.AppendFormat("S:{0}", sacl.ToString());
            }

            return(sb.ToString());
        }