Book Image

Microsoft Dynamics AX 2012 R2 Administration Cookbook

By : Simon Buxton
Book Image

Microsoft Dynamics AX 2012 R2 Administration Cookbook

By: Simon Buxton

Overview of this book

<p>Microsoft Dynamic is a powerful ERP solution for global enterprises to support industry-specific and various operational business processes. This single solution enhances various aspects of manufacturing, retail, service, and public sector industries. Due to its intriguing capabilities such as finance and supply chain management, business intelligence and reporting, and project management, it is one of the most widely used solutions, having been adopted by many organizations across the globe. If you are one of those who help organizations in administering this unique solution, this book should be in the tool belt of any AX developer to ensure compliance and simplify the ongoing management of the system.</p> <p>Providing administrators who are involved in system administration and management with clear guidance on many administration tasks, this book is packed with systematic instructions of hands-on examples and in-depth explanations Even for experienced users, this book will serve as a great source of reference by providing new ways of working with Microsoft Dynamic through the book's easy-to-follow approach.</p> <p>This hands-on guide looks at key administration tasks, explaining not only how each task is performed, but also why. You will be provided with practical guidance that will allow you to safely take advantage of the advanced technology in Dynamics AX 2012 in order to simplify and automate the ongoing management while maintaining compliance.</p> <p>This practical book simplifies user management operations by automating the tasks of hiring new people—joining up HR and security roles through organizational hierarchies. In-depth explanations teach you about AX licensing and how to make the most of your license.</p> <p>Management of models and the model store (including installing hotfixes and addons), as well as details of how they work are provided, along with practical guidance on the procedures required to reduce risk and downtime.</p> <p>This book guides you through the key tasks in reporting and BI through in-depth knowledge of the Batch Framework and Alerting. Finally, important tasks in performance, system monitoring, and troubleshooting are provided with in-depth guidance and further reading.</p> <p>With this comprehensive guide, you will be armed with all the tools and instructions you need to both manage the system and make better decisions as your company’s requirements evolve.</p>
Table of Contents (21 chapters)
Microsoft Dynamics AX 2012 R2 Administration Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a Claims (flexible authentication) user


This method allows the access of Dynamics AX to users and services that are not a part of your Active Directory.

Getting ready

There are two main reasons to use Claims users: allowing external users (including suppliers and customers) to access the Enterprise portal and allowing external applications or web services access to the AX AIF (Application Integration Framework) services with non-Active Directory accounts. An example of this is a mobile application that requires access to AX services but cannot log in to the domain. You cannot use basic authentication with the AIF. Unless you want to write a set of proxy services to act as intermediaries, you need some way of accessing AX without using Active Directory accounts.

Note

These users cannot log in to the AX client application directly. It is typically used to allow external parties (customers, suppliers, and so on) access to the Enterprise portal (SharePoint) or web services without creating Active Directory accounts.

The following example is for a mobile application that does not support the Active Directory accounts.

How to do it…

The method is the same as creating an Active Directory user, except for the following fields:

User Id

This is a unique ID, but you should create a strict standard that allows you to identify these accounts. If this is a series accounts for a warehouse management application, perhaps we could use WM001.

Alias

This is the user ID of the external user that the user or service uses to log in with, often an email address.

Domain

This is the name of the authentication provider. When your application logs in to the AX AIF service, it uses this, along with the user ID as the LogonAsUser property (this is explained later in the chapter).

Account type

This is a Claims user.

Note

For Claims users, no validation of the details entered is performed when the record is saved or enabled.

If the account is for an external party, it may be governed by that party (for example, using Active Directory Federated Services (ADFS). The purpose here is to inform AX that we trust this membership provider (the Domain field) to authenticate the user (the Alias field).

Where we do control the usernames (for example, in the internal applications), we should be careful while choosing the naming conventions, as these can't easily be changed later (if at all).

Closing the form will save the record and complete the task.

How it works…

In your mobile application (this is not restricted to mobile devices, AIF HTTP integration ports would also use Claims users), the users log in with a user ID and password. Once they have logged in, they are classed as authenticated in your application. When this application tries to access AX, it will do so with the application's user account. Since you have entered these details within AX as a claims user, AX will trust that your application has authenticated the user.

There's more…

Here we will provide a working example of a sample mobile application logging in as a Claims user with the following assumptions:

  • AIF is installed and functioning

  • Visual Studio 2012 is installed (although for this test, any version that can connect to WCF services is sufficient)

  • Users have the knowledge of how to create a simple Windows console project

Creating a Claims user

We can create a claims user with the following details:

User Id

CU001

Alias

[email protected]

Domain

myAppAuthProvider

Account type

Claims user

We can configure an InventItem Service inbound AIF port by performing the following steps:

  1. Navigate to System administration | Setup | Services and Application Integration Framework.

  2. Click on Inbound ports. In the Inbound ports form, click on New and complete the form as follows:

    Some of the fields are discussed in the following table:

    Port name

    This is the unique identifier of the port. Naming of these ports is important. A good tip is to use the module or a functional area as the first part of the port name.

    Description

    This is the description of the port.

    Adapter

    Retain the default values in this field.

    URI

    Leave this field with the default value.

    Note

    The other fields are not important to this task, so we will not be covering them at this stage.

  3. Next, click on Service operations and move InventItemService.find to the left-hand side pane:

  4. Click on Close, and in the Inbound ports form, click on Activate.

The system will produce an InfoLog message listing the services that were started. At the end, it should state The port 'ItemsPort' was deployed successfully.

The Inbound ports form will now display the web service definition (WSDL) URI of the port. In my case, this is http://ZEUS:8101/DynamicsAx/Services/ItemsPort.

Creating a Visual Studio application

We can create a Visual Studio application by performing the following steps:

  1. Open Visual Studio 2012 and create a Windows Console C# application.

  2. On the project tree, right-click on References and select Add Service Reference, the following form will be opened:

  3. In the Address field, insert the WSDL URI from the Inbound ports form and click on Go.

  4. Enter a useful namespace for our reference and click on OK.

  5. Open the code file, Program.cs, so that we can write the application.

    Note

    The first part of the program is to declare our security context, which is the important part we are trying to demonstrate with Claims users.

    The first few lines of code of the Program.cs file are as follows:

    // Set up the call context to use our Claims user
    ItemReference.CallContext context = new ItemReference.CallContext();
    context.Company = "HHF";
    context.LogonAsUser = "MyAppAuthProvider\\[email protected]";
    context.Language = "en-gb";

    You should remember that our user has the MyAppAuthProvider domain and the alias . This is used as domain\alias when the application logs in to AX.

    The following code snippet is purely to demonstrate that the Claims user can log into AX and read the port we configured earlier:

    ItemReference.AxdItem myItem = new ItemReference.AxdItem();
                
    ItemReference.ItemServiceClient client = new ItemReference.ItemServiceClient();
    ItemReference.QueryCriteria criteria = new ItemReference.QueryCriteria();
    ItemReference.CriteriaElement itemIdCriteria = new ItemReference.CriteriaElement();
    itemIdCriteria.DataSourceName = "InventTable";
    itemIdCriteria.FieldName = "ItemId";
    itemIdCriteria.Operator = ItemReference.Operator.Range;
    itemIdCriteria.Value1 = "A";
    itemIdCriteria.Value2 = "Z";
    
    criteria.CriteriaElement = new ItemReference.CriteriaElement[1];
    criteria.CriteriaElement[0] = itemIdCriteria;
    try
    {
        myItem = client.find(context, criteria);
        if (myItem != null && 
            myItem.InventTable != null &&
            myItem.InventTable.Length > 0)
        {
            foreach (ItemReference.AxdEntity_InventTable item in 
                     myItem.InventTable)
            {
                Console.WriteLine(
                   String.Format("Item Id {0} - {1}", item.ItemId, 
                                 item.NameAlias));
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(String.Format("Error {0}", e.Message));
    }
  6. Finally, run the application in the debug mode (press F5).

The result

The result of this is that the application logs in to AX as the Claims user, not as the Active Directory user. You will also note that no password is required, as AX does not have its own cryptography and we trust that the application has already done the authentication for us.

Flexible (Claims) authentication is a much welcomed new feature for AX 2012. In the past, we had to write proxy services to do this authentication for us, and for the Enterprise portal, we had to add the external users as the Active Directory accounts in our domain.