Search code examples
axaptadynamics-ax-2012-r3domaincontroller

Reading user's information in Active Directory from Dynamics AX using specific domain controller


We have a few domain controllers that can be used to read AD users information.

When domain name "mydomain.co.uk" is being used as AD domain, any of those few domain controllers are being picked to serve the purpose.

However, if changes in AD haven't been propagated across all domain controllers, no results are being returned.

To address the issue I've decided to always point to a specific domain controller, which is "dc1.mydomain.co.uk".

In C# that's easily done with something like this:

new PrincipalContext(ContextType.Domain, 
                    "dc1.mydomain.co.uk:389", 
                    "OU=Groups,DC=mydomain,DC=co,DC=uk", 
                    domainUsername, 
                    domainPassword)

However in X++ only "mydomain.co.uk" works:

static void validateDomain(Args _args)
{
    xAxaptaUserManager          Axmanage;
    NetworkDomain               networkDomain = "";

    // Works
    networkDomain = "mydomain.co.uk";

    // Does not work
    networkDomain = "dc1";
    networkDomain = "dc1.mydomain.co.uk";
    networkDomain = "dc1.mydomain.co.uk:389";
    networkDomain = "LDAP://dc1.mydomain.co.uk:389/";

    Axmanage = new xAxaptaUserManager();

    info(strFmt("%1", Axmanage.validateDomain(networkDomain)));
}

How can I achieve same functionality with xAxaptaUserManager in MS Dynamics AX 2012 R3, if possible?


Solution

  • We're not on your network, so we can't really test everything, but if xAxaptaUserManager, which is a kernel class doesn't work, but you are able to do it in C#...just create an assembly "helper" that you call from AX.

    See below links:

    https://learn.microsoft.com/en-us/dynamicsax-2012/developer/how-to-add-a-reference-to-a-net-assembly

    https://learn.microsoft.com/en-us/dynamicsax-2012/developer/net-interop-from-x