Config Overview

The Uplift Config system works by providing a convenient way to place an App.config file in the FIM Extensions folder. This may be used as any other config file, with appSettings and connectionStrings, as well as custom sections for the LogWriter, Mail, and Provision helpers.

Because it is a custom object populated using System.Xml.Linq it does not produce a full .NET System.Configuration class, so custom config sections will not work without edits to the Uplift source code.

Config Class

SoftwareIDM.Uplift.Config is a static class used to access configuration values. Because it is a static class that abstracts the details of loading the correct App.config file, configuration values may be accessed conveniently without hacking the AppDomain.

Config has several public properties:

  • App – This is an instance reference to a SoftwareIDM.Uplift.Configuration object. This object has a useful subset of the interface of System.Configuration.ConfigurationManager, but without the same AppDomain constraints. Because of this, you can use Config.App.* anywhere you would ordinarily use ConfigurationManager.*
  • ADConst – This instance provides a set of predefined constants used for common AD constants, including the most common constants used with the userAccountControl attribute, as well as the six possible values for groupType.
  • ExeConfigPath – Setting the ExeConfigPath will cause the library to load the App.config file from the specified location.
  • Map – This is an instance reference that holds a collection of xml files that can be used to lookup environment data.

Config Initialization

Because Rules Extension code does not execute in the context of the FIM Extensions folder, it is recommended to initialize the Config system with the file path to the App.config file. This should be done in the constructor or Initialize method of the Rules Extension or Metaverse Extension class. The configuration will be loaded once and will be available until synchronization completes. This is illustrated in the provided ExampleExtension.

public ExampleExtension() {
    Config.ExeConfigPath = @"C:\Program Files\Microsoft Forefront ...\Extensions\App.config";
}

If the provided path consists of only a file name with no ‘\’ characters the file name will be prepended with the FIM extensions directory. If Config.App is accessed without providing the ExeConfigPath the Uplift library will attempt to load …\Extensions\App.config.

Map Files

XML Mapping files may be used as a lookup table to convert from a known key value to another value. For example, one might use an xml map file to lookup the correct Active Directory OU for a user based on a location code/id from their HR feed.

Because Config.Map reads each xml file into a dictionary in a single pass, it is most appropriate for use with moderately sized files where lookups are primarily by key value and very low latency is desired. For working with larger files, or when complex query scenarios are required it is more appropriate to use the SqlHelper class.

Config.Map supports three public methods.

void Load(string name, string path) Loads an xml file and makes the root XElement available in the public xmls dictionary to perform System.Xml.Linq queries against.

void Add(string name, string path, string element, string key, bool xmlIsAttributes) Adds a new map file reference.

  • name – The name to refer to the xml file by (see Get)
  • path – The location of the xml file
  • element – The name of the element that corresponds to individual rows/records in the xml file
  • key – The key field that is being mapped.
  • xmlIsAttributes – If true, then the data is read off xml attributes on element. If false, the data is read off of sub-elements.

void Get(string name, string key, string field) Looks up a value in the xml file.

  • name – The name of the xml file (See Add)
  • key – The key value to lookup in the file
  • field – The name of the attribute or element containing the desired lookup value.

Example

// Example of a mapping XML file
/*
<locations>
  <location postalCode="1001" ou="OU=New York,DC=fabrikam,DC=com" />
  <location postalCode="60606" ou="OU=Chicago,DC=fabrikam,DC=com" />
</locations>
*/
Config.Map.Add("Locations", @"C:\Program Files\Microsoft Forefront ...\Extensions\locations.xml",
    "ou", "postalCode", true);

Config.Map.get("Locations", "60606", "ou");

Copyright © SoftwareIDM