Пример #1
0
        public List <string> TryCustomDecoding(DirectoryAttribute attrib, SearchResultEntry entry, ref bool match, ref bool exclusive, ActiveDirectorySyntax aSyntax = ActiveDirectorySyntax.CaseIgnoreString)
        {
            exclusive = false;

            match = true;

            List <string> ret = new List <string>();

            bool isbad = false;

            #region userparamters

            if (attrib.Name.ToLowerInvariant() == "userparameters")
            {
                if (MainBase.UserSettings.DecodeUserParameters)
                {
                    DirectoryAttribute desam = entry.Attributes["sAMAccountName"];

                    string sam = DecodeStringData(desam, ActiveDirectorySyntax.CaseIgnoreString, out isbad, true)[0];

                    DateTime start = DateTime.Now;

                    WtsApi userparams = new WtsApi(ForestBase.CurrentDC, sam);

                    GlobalEventHandler.RaiseSubsequentQuery((long)DateTime.Now.Subtract(start).TotalMilliseconds);

                    ret = userparams.Print();

                    if (!userparams.HasError)
                    {
                        exclusive = true;
                    }
                }
            }

            #endregion

            #region memberof

            else if (attrib.Name.ToLowerInvariant() == "memberof")
            {
                if (MainBase.UserSettings.DecodePrimaryGroupID)
                {
                    try
                    {
                        DirectoryAttribute deprid = entry.Attributes["primaryGroupID"];

                        string pgid = DecodePrimaryGroupId(deprid, true);

                        ret.Add(pgid.Replace("<", "<(primaryGroupID) "));
                    }

                    catch (Exception ex)
                    { ex.ToDummy(); }
                }
            }

            #endregion

            #region primarygroupid

            else if (attrib.Name.ToLowerInvariant() == "primarygroupid")
            {
                try
                {
                    DirectoryAttribute deprid = entry.Attributes["primaryGroupID"];

                    string pgid = DecodePrimaryGroupId(deprid, MainBase.UserSettings.DecodePrimaryGroupID);

                    ret.Add(pgid);

                    exclusive = true;
                }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            else if (attrib.Name.ToLowerInvariant() == "defaultsecuritydescriptor")
            {
                DirectoryAttribute deprid = entry.Attributes["defaultsecuritydescriptor"];

                ret = DecodeDefaultSD(deprid, MainBase.UserSettings.DecodeDefaultSD);

                exclusive = true;
            }

            #endregion

            #region logonhours

            else if (attrib.Name.ToLowerInvariant() == "logonhours")
            {
                try
                {
                    ret = DecodeLogonHours(attrib);

                    exclusive = true;
                }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            #endregion

            #region dSaSignature

            else if (attrib.Name.ToLowerInvariant() == "dsasignature")
            {
                try
                {
                    ret = DecodeDsaSignature(attrib);

                    exclusive = true;
                }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            else if (attrib.Name.ToLowerInvariant() == "schemainfo")
            {
                try
                {
                    Int32 uver = 0;

                    ret = DecodeSchemaInfo(attrib, out uver);

                    exclusive = true;
                }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            #endregion

            #region tokenGroups  tokenGroupsGlobalAndUniversal tokenGroupsNoGCAcceptable

            else if ((attrib.Name.ToLowerInvariant() == "tokengroups") || (attrib.Name.ToLowerInvariant() == "tokengroupsglobalanduniversal") || (attrib.Name.ToLowerInvariant() == "tokengroupsglobalanduniversal"))
            {
                if (MainBase.UserSettings.ResolveSids)
                {
                    ret.AddRange(DecodeByteData(attrib, ActiveDirectorySyntax.Sid, out isbad, true));

                    exclusive = true;
                }
            }

            #endregion

            #region trust

            else if (attrib.Name.ToLowerInvariant() == "msds-trustforesttrustinfo")
            {
                foreach (byte[] value in attrib.GetValues(typeof(byte[])))
                {
                    ret.AddRange(new ForestTrustInfoDecoder(value).ToString());

                    exclusive = true;
                }
            }

            #endregion

            #region replication

            else if (attrib.Name.ToLowerInvariant() == "repluptodatevector")
            {
                foreach (byte[] value in attrib.GetValues(typeof(byte[])))
                {
                    ret.AddRange(new ReplUpToDateVector().Decode(value));

                    exclusive = true;
                }
            }

            else if (attrib.Name.ToLowerInvariant() == "replpropertymetadata")
            {
                //ActiveDirectoryReplicationMetadata metadata = CurrentDC
            }

            else if (aSyntax == ActiveDirectorySyntax.ReplicaLink)
            {
            }

            #endregion

            else
            {
                match = false;
            }

            return(ret);
        }