public Schema GetSchema(System.Collections.ObjectModel.KeyedCollection <string, ConfigParameter> configParameters)
        {
            Schema schema = Schema.Create();

            Microsoft.MetadirectoryServices.SchemaType type;

            //we want to fetch schema for all MAs, that way configuration wont get lost if an item is
            //unselected, and the checkbox can become simply an activate/deactivate switch
            DataSet mas = FIMConfiguration.GetManagementAgents(null);

            foreach (DataRow ma in mas.Tables["Config"].Rows)
            {
                string maName = ma["ma_name"].ToString();
                string maType = ma["ma_type"].ToString();
                string maList = ma["ma_listname"].ToString();

                if (maType.Equals("FIM", StringComparison.InvariantCultureIgnoreCase) ||
                    maList.Equals("Provisioning Management Agent (Insight)", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                //create a new schema type based on the ma
                type = Microsoft.MetadirectoryServices.SchemaType.Create(maName, false);

                //add a generic Anchor Attribute to allow user to add flows for the actual anchor
                type.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("Anchor", AttributeType.String));

                //we must preface each attribute with the MA name to make it unique across the schema allowing for
                //an attribute in two different MAs with different data types, etc.

                //our data will come back as XML data, we will need to parse it for what we need
                XmlDocument xmldoc = FIMConfiguration.GetConfigXML(maName, "ma_schema_xml");

                XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmldoc.NameTable);
                xmlnsManager.AddNamespace("dsml", "http://www.dsml.org/DSML");
                xmlnsManager.AddNamespace("ms-dsml", "http://www.microsoft.com/MMS/DSML");

                XmlNodeList attributes = xmldoc.SelectNodes("//dsml:directory-schema/dsml:attribute-type", xmlnsManager);

                //add each attribute found to the schema
                foreach (XmlNode attrib in attributes)
                {
                    string oid = attrib.SelectSingleNode("./dsml:syntax", xmlnsManager).InnerText;
                    type.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(maName + " - " + attrib.Attributes["id"].Value, FIMConfiguration.GetDataType(oid)));
                }

                schema.Types.Add(type);
            }

            return(schema);
        }
        public System.Collections.Generic.IList <ConfigParameterDefinition> GetConfigParameters(System.Collections.ObjectModel.KeyedCollection <string, ConfigParameter> configParameters, ConfigParameterPage page)
        {
            List <ConfigParameterDefinition> configParametersDefinitions = new List <ConfigParameterDefinition>();

            switch (page)
            {
            case ConfigParameterPage.Connectivity:
                //we have to configure the MAs being seletected in the Connectivity page so that the information
                //will be available to us when fetching the schema for the items selected
                configParametersDefinitions.Add(ConfigParameterDefinition.CreateLabelParameter("Enable provisioning for the following types:"));

                //look up MAs and list them as check boxes for provisioning enablement
                DataSet mas = FIMConfiguration.GetManagementAgents(null);

                foreach (DataRow ma in mas.Tables["Config"].Rows)
                {
                    string maName = ma["ma_name"].ToString();
                    string maType = ma["ma_type"].ToString();
                    string maList = ma["ma_listname"].ToString();

                    if (maType.Equals("FIM", StringComparison.InvariantCultureIgnoreCase) ||
                        maList.Equals("Provisioning Management Agent (Insight)", StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    //our data will come back as XML data, we will need to parse it for what we need
                    XmlDocument xmldoc = FIMConfiguration.GetConfigXML(maName, "ma_schema_xml");

                    XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmldoc.NameTable);
                    xmlnsManager.AddNamespace("dsml", "http://www.dsml.org/DSML");
                    xmlnsManager.AddNamespace("ms-dsml", "http://www.microsoft.com/MMS/DSML");

                    //TODO:  what happens when a sql column defines the object type?
                    XmlNodeList objectTypes = xmldoc.SelectNodes("//dsml:directory-schema/dsml:class", xmlnsManager);

                    foreach (XmlNode ot in objectTypes)
                    {
                        //add the object type as a selection
                        ConfigParameterDefinition conf = ConfigParameterDefinition.CreateCheckBoxParameter(maName + " - " + ot.Attributes["id"].Value.Replace(" - ", " _ "));
                        configParametersDefinitions.Add(conf);
                    }

                    //TODO:  what happens to the UI when we have a alot of entries?
                    configParametersDefinitions.Add(ConfigParameterDefinition.CreateDividerParameter());
                }

                break;

            case ConfigParameterPage.Global:
                break;

            case ConfigParameterPage.Partition:
                break;

            case ConfigParameterPage.RunStep:
                break;
            }

            return(configParametersDefinitions);
        }