MIIS/ILM/FIM Code Experiment: Dynamics AX Management Agent (part 2)


Hello!

Today I'm going to talk about the Dynamics AX Management agent, specifically, the connection made in the functions for Import and Export. 

The Dynamics AX Management Agent I created utilizes the Extensible Connectivity Management Agent available in MIIS, ILM and FIM.  You can use the extensible connectivity management agent to connect to virtually anything as long as you have a way to connect.  In this example, we will hook the Microsoft.Dynamics.BusinessConnectorNet Namespace, which is available with an installation of the Dynamics AX client. In order to connect to the Dynamics AX instance, you need to set up the client and establish a connection configuration.  You set up the connection configuration using the AX configuration utility.  The string name of the configuration you set up is going to be utilized in the setup of the MA.  I use the variable name "Configuration" as a configuration parameter in the MA. 

The import method, GenerateImportFile() and the export connection method, BeginExport() will use the Configuration information to connect to Dynamics AX. 

Both methods take advantage of a global variable I set up

Axapta ax = new Axapta();

The import method looks like this:



public void GenerateImportFile(string filename, string connectTo, string user, string password, ConfigParameterCollection configParameters, bool fullImport, TypeDescriptionCollection types, ref string customData)
{
String domain = user.Remove(user.IndexOf(@"\"));
String username = user.Remove(0, user.IndexOf(@"\") + 1)
\\ The string "user" comes in from the management agent as DOMAIN\username
System.Net.NetworkCredential creds = new System.Net.NetworkCredential(username, password, domain);
ax.LogonAs(username, domain, creds, "", "", "", configParameters["Configuration"].Value);
\\ Seems redundant to pass the NetworkCredential in as well as username and domain in LogonAs
\\ The three nulls in LogonAs are company, language and objectServer;
\\ all of which are defined in the AX configuration,
\\ which is pulled from the management agent as one of the configParameters.
... insert code here...

}

Creating the connection for BeginExport is identical

public void BeginExport(string connectTo, string user, string password, ConfigParameterCollection configParameters, TypeDescriptionCollection types)

{
String domain = user.Remove(user.IndexOf(@"\"));
String username = user.Remove(0, user.IndexOf(@"\") + 1);
System.Net.NetworkCredential creds = new System.Net.NetworkCredential(username, password, domain);
ax.LogonAs(username, domain, creds, "", "", "", configParameters["Configuration"].Value);
...insert code here...
}

Seems pretty straightforward, right?   Until next time...

--Shawn

 This posting is provided "AS IS" with no warranties, and confers no rights.

Skip to main content