예제 #1
0
        public SchemaConnection(IEntryFetcherFactory entryFetcherFactory, String baseHost, String upn, String passwd)
        {
            this.entryFetcherFactory = entryFetcherFactory;
            baseEntryFetcher         = entryFetcherFactory.CreateEntryFetcher(baseHost, upn, passwd);
            if (baseEntryFetcher == null)
            {
                throw new SchemaConnectionException("Base server is not reachable");
            }

            entryFetchers = new Dictionary <String, IEntryFetcher>();

            DseRootEntry dseRootEntry = baseEntryFetcher.GetDseRootEntry();
            ServerEntry  serverEntry  = baseEntryFetcher.GetServerEntry(dseRootEntry.serverDn);

            baseServerName = serverEntry.serverName;

            RefreshSchemaConnection(upn, passwd);
        }
예제 #2
0
        public void ExportToXML(String filepath)
        {
            using (XmlTextWriter writer = new XmlTextWriter(filepath, null))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("Node");

                // host name
                writer.WriteElementString("HostName", baseServerName);

                // host status
                writer.WriteElementString("Status", "1");

                // dse root
                DseRootEntry dseRootEntry = baseEntryFetcher.GetDseRootEntry();
                writer.WriteStartElement("DseRootEntry");
                writer.WriteElementString("Domain", dseRootEntry.domain);
                writer.WriteElementString("ServerDn", dseRootEntry.serverDn);
                writer.WriteEndElement();

                // list of server nodes
                IList <ServerEntry> serverEntries = baseEntryFetcher.GetServerEntries();
                writer.WriteStartElement("ServerEntries");
                foreach (ServerEntry e in serverEntries)
                {
                    writer.WriteStartElement("ServerEntry");
                    writer.WriteElementString("DN", e.dn);
                    writer.WriteElementString("ServerName", e.serverName);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // subschema subentry
                SubSchemaSubEntry baseSubSchema = baseEntryFetcher.GetSubSchemaSubEntry();
                writer.WriteStartElement("SubSchemaSubEntry");
                writer.WriteStartElement("AttributeTypes");
                foreach (AttributeType at in baseSubSchema.GetAttributeTypeList())
                {
                    writer.WriteElementString("AttributeType", at.ToString());
                }
                writer.WriteEndElement();
                writer.WriteStartElement("ObjectClasses");
                foreach (ObjectClass oc in baseSubSchema.GetObjectClassList())
                {
                    writer.WriteElementString("ObjectClass", oc.ToString());
                }
                writer.WriteEndElement();
                writer.WriteEndElement();

                // list of attribute schema entries
                SchemaComparableList <SchemaEntry> baseAtEntries =
                    baseEntryFetcher.GetAttributeSchemaEntries();
                SchemaComparableList <SchemaEntry> baseOcEntries =
                    baseEntryFetcher.GetClassSchemaEntries();
                writer.WriteStartElement("SchemaEntries");
                writer.WriteStartElement("AttributeSchemaEntries");
                foreach (SchemaEntry ae in baseAtEntries)
                {
                    writer.WriteStartElement("AttributeSchemaEntry");
                    writer.WriteElementString("Name", ae.defName);
                    writer.WriteStartElement("AttributeMetadata");
                    foreach (AttributeMetadata m in ae.GetMetadataList())
                    {
                        writer.WriteElementString("Value", m.raw);
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // list of class schema entries
                writer.WriteStartElement("ClassSchemaEntries");
                foreach (SchemaEntry ce in baseOcEntries)
                {
                    writer.WriteStartElement("ClassSchemaEntry");
                    writer.WriteElementString("Name", ce.defName);
                    writer.WriteStartElement("AttributeMetadata");
                    foreach (AttributeMetadata m in ce.GetMetadataList())
                    {
                        writer.WriteElementString("Value", m.raw);
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();

                // end node
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }