Ejemplo n.º 1
0
        public bool IsWellKnown(WellKnownSidType type)
        {
            WellKnownAccount acct = WellKnownAccount.LookupByType(type);

            if (acct == null)
            {
                return(false);
            }

            string sid = Value;

            if (acct.IsAbsolute)
            {
                return(sid == acct.Sid);
            }

            return(sid.StartsWith("S-1-5-21", StringComparison.OrdinalIgnoreCase) &&
                   sid.EndsWith("-" + acct.Rid, StringComparison.OrdinalIgnoreCase));
        }
Ejemplo n.º 2
0
        public SecurityIdentifier(WellKnownSidType sidType,
                                  SecurityIdentifier domainSid)
        {
            WellKnownAccount acct = WellKnownAccount.LookupByType(sidType);

            if (acct == null)
            {
                throw new ArgumentException("Unable to convert SID type: " + sidType);
            }

            if (acct.IsAbsolute)
            {
                buffer = ParseSddlForm(acct.Sid);
            }
            else
            {
                if (domainSid == null)
                {
                    throw new ArgumentNullException("domainSid");
                }

                buffer = ParseSddlForm(domainSid.Value + "-" + acct.Rid);
            }
        }