예제 #1
0
        private void StoreAttributes(List <SearchResultEntry> attributeSchema)
        {
            foreach (SearchResultEntry entry in attributeSchema)
            {
                bool isdefunct = false;

                ActiveDirectorySyntax syntax = ActiveDirectorySyntax.CaseIgnoreString;

                if (entry.Attributes["isDefunct"] != null)
                {
                    string sdef = entry.Attributes["isDefunct"].GetValues(typeof(string))[0].ToString();

                    isdefunct = Boolean.Parse(sdef);
                }

                if (!isdefunct)
                {
                    #region name + syntax

                    string name = entry.Attributes["lDAPDisplayName"][0].ToString();

                    string asyntax = entry.Attributes["attributeSyntax"][0].ToString();

                    int omsyntax = 0;

                    if (Int32.TryParse(entry.Attributes["oMSyntax"][0].ToString(), out omsyntax))
                    {
                        syntax = DecodeLDAPAttributeSyntax(asyntax, omsyntax);
                    }

                    long systemflags = 0;

                    if (entry.Attributes.Contains("systemFlags"))
                    {
                        long.TryParse(entry.Attributes["systemFlags"][0].ToString(), out systemflags);
                    }

                    long linkid = 0;

                    if (entry.Attributes.Contains("linkID"))
                    {
                        long.TryParse(entry.Attributes["linkID"][0].ToString(), out linkid);
                    }



                    bool flags = false;
                    if ((systemflags & 4) == 4)
                    {
                        flags = true;
                    }

                    ForestBase.AttributeCache.Add(name, new AttributeSchema(name, syntax, flags, linkid));

                    ForestBase.CurrentAttributesNode.Add(new XElement(name, syntax.ToString(), new XAttribute("checked", "0"), new XAttribute("constructed", Convert.ToInt32(flags)), new XAttribute("linked", Convert.ToInt32(linkid))));

                    ForestBase.CurrentClassesNode.Elements("All").FirstOrDefault().Add(new XElement("Attribute", name));

                    #endregion

                    #region guids

                    string oid = String.Empty;

                    foreach (byte[] value in entry.Attributes["schemaIDGUID"].GetValues(typeof(byte[])))
                    {
                        oid = new Guid(value).ToString();

                        if (ForestBase.RightsGuids.AddSafe <string, string>(oid, name))
                        {
                            ForestBase.CurrentExtendedRightsNode.Add(new XElement("GUID" + oid.ToUpperInvariant(), name));
                        }
                    }

                    if (entry.Attributes.Contains("attributeSecurityGUID"))
                    {
                        foreach (byte[] value in entry.Attributes["attributeSecurityGUID"].GetValues(typeof(byte[])))
                        {
                            oid = new Guid(value).ToString();

                            if (ForestBase.RightsGuids.AddSafe <string, string>(oid, name))
                            {
                                ForestBase.CurrentExtendedRightsNode.Add(new XElement("GUID" + oid.ToUpperInvariant(), name));
                            }
                        }
                    }

                    #endregion
                }
            }
        }