Sunday 4 December 2011

Use of XML in MIIS


It is useful to use some kind of initialization or configuration file to control the behavior of a .dll file without having to recompile it. You can do this by providing an XML file of parameters that are read in the Initialize sub of a management agent or metaverse .dll assembly (any initialization file   will be sufficient, but XMLworks best).


------------------------------------------------------------------------------------------------------------
Needed Import statment:

Imports System.Xml
Imports Microsoft.Win32
Imports Microsoft.Win32.Registry
Imports Microsoft.Win32.RegistryKey
------------------------------------------------------------------------------------------------------------
Public Sub UseRuleExtensionsConfig(ByVal filename As String)

            Dim RuleExtensions_config_file As String = "\" + filename
            Dim config As XmlDocument = New XmlDocument
            Dim rnode, node As XmlNode
           
        ' Call registry to get the path for MIIS which is "C:\Program Files\Microsoft Identity Integration Server\"
        ' Then load the file "RuleExtensions_config.xml" which is actually save in MaData folder

        Dim regKey As Microsoft.Win32.RegistryKey
            regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\miiserver\Parameters", False)
            config.Load(regKey.GetValue("Path") & "MaData\" & filename)

            rnode = config.SelectSingleNode("rules-extension-properties/management-agents/SASDOM0001_UsersAndGroups")
            node = rnode.SelectSingleNode("useShortNames")
            ShortNames = node.InnerText

            rnode = config.SelectSingleNode("rules-extension-properties/account-provisioning/sasdom0001")
            node = rnode.SelectSingleNode("groups/departments/groupPrefix")
            sasdom0001DeptPrefix = node.InnerText
           
End Sub
------------------------------------------------------------------------------------------------------------
Call Sub routine:

Const RuleExtensions_config_file = "RuleExtensions_config.xml"
UseRuleExtensionsConfig(RuleExtensions_config_file)

------------------------------------------------------------------------------------------------------------

Contents of XML file:

<rules-extension-properties>
    <management-agents>
        <SASDOM0001_UsersAndGroups>
            <useShortNames>yes</useShortNames>
        </SASDOM0001_UsersAndGroups>
    </management-agents>

    <account-provisioning>
        <sasdom0001>
            <groups>
                <departments>
                    <GroupsOU>OU=DEPARTMENTS,OU=GROUPS</GroupsOU>
                    <groupPrefix>DEPT_</groupPrefix>
                </department>
            </groups>
        </sasdom0001>
    </account-provisioning>

</rules-extension-properties>

------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment