Dynamics AX
  RSS Feed  LinkedIn  Twitter
Want to turn you're data into a true asset? Ready to break free from the report factory?
Ready to gain true insights that are action focused for truly data informed decisions?
Want to do all of this across mutliple companies, instances of Dynamics and your other investments?
Hillstar Business Intelligence is the answer then! (www.HillstarBI.com)

Hillstar Business Intelligence for Microsoft Dynamics AX and NAV on Mobile, Desktop, Tablet


Let us prove to you how we can take the complexity out of the schema and truly enable users to answer the needed questions to run your business! Visit Hillstar Business Solutions at: www.HillstarBI.com

Thursday, June 07, 2007

.Net BC Custom App, One Step Back! [Connection]

At the request of one of my readers, let me take a step back and talk about the Business Connector and how to make a successful connection to a Dynamics AX instance through it.

So to set this up let's talk about some important things here. One the Business Connector Proxy. This is the account that is used to start a BC session, in which all "connections" for the shared application pool for IIS go through.

In the EP example you supply this in the Business Connector Proxy form, and then the Applicaiton Pool that is running the SharePoint Portal EP site, Idenity must be the supplied Business Connector Proxy account that was setup in the Dynamics AX form. In our example, we have a standard Application pool. [Because we assume a single site for the IIS, for simple implementation of our custom site.] Since this is the case, then the First person to logon to the custom site can be used as the Business Connector Proxy account, and then all other user connection coming in with use the BC Proxy account, as long as that user account is active and does not time out. If that account does, then the next person to logon will assume the BC proxy account. You can see this in the Online users form. Admin > Online Users.

To achieve this, 2 things must happen. (1) The users using this application must have rights to logon as Business Proxy Account. (2) In your connection code you must make use of a Network credenitals object, and use the LogonAs() method. Let take a look at some sample connection code below:

Example Connection Code:

// Declartions
public Axapta objDAXCn;
System.Net.NetworkCredential nc;

// Make use of Declartions
nc = new System.Net.NetworkCredential(UserId, passwd, NetworkDomain);
objDAXCn = new Axapta();
objDAXCn.LogonAs(userId, NetworkDomain, nc, StartCompany, "", FQAOSInstance, "");
objDAXCn.Refresh();

Session["objDAXCn"] = objDAXCn;

Now lets take and break this down. First we have the declartions. We declar for an Axapta object, and then a NetworkCredential object. These are used as part of forming our connection for the given ASP.net session. Next we take and declare new for the given nc variable and then set it equal to passed in variables. Could be from a login scsreen. The nc is set then, and we move to setting the Connection object [Axapta] to a new instance. Next we perform the .LogonAs() [And not .Logon()] with passing the:

1. userId - From the passed in login screen
2. NetworkDomain - possible Global.asax global variable
3. nc - The given network credentials that will be used for the .Net BC Proxy account. [Unless a session already exists for the instance, then the existing BC Account is made use of]
4. StartCompany - What Dynamics AX company to start in
5. ""
6. FQAOSInstance - The Full name of the Dynamics AX instance. Example: "instanceName@ServerName:PortNumber"
7. ""

After this we perform a refresh and then set a session variable equal to the Open connection so it can be reused throughout the Site session for the given user. [performance helper].

So that is a good breakdown and coverage of making a connection via the .Net BC. YOu can get fancy with this for pooling, multiple Application Pools, single sessions, shared sessions, etc. etc. For now this will give you what you need, and your application should drive you to be as complex, Only as it needs to be. [Always use KISS method]

Well check back as we continue down this path!

Find a job at: www.DynamicsAXJobs.com

Labels: , , , , ,

4 Comments:

Blogger Ludovico said...

Thank you for the reply! :)

I'll take a look at that, but from what I understand that way the first user that log in to axapta via BC is always the user that invoke business logic, also for other user in other session. (until the session expire)

Anyway, I'll make some try!

2:32 AM  
Blogger jopx said...

Is it really necessary to use the LogonAs method in ASP.Net? Why can't we just use the Logon method?

12:48 PM  
Blogger brandon said...

jopx,

You do not have to make use of the LogonAs() method, you can use the Logon method. However the issue is the code executing under the Business Connector Proxy vs. the user id context with the LogonAs() method.

There is a way around this, using the RunsAs() within DAX X++ code. Check that out, with the Logon() and you can design your code.. check into it.

-Brandon

9:02 AM  
Blogger Mani said...

It works fine when i use a Asp.net application but when i use it in a webservice it doesn't work.

9:42 PM  

Post a Comment

Links to this post:

Create a Link

<< Home


Copyright 2005-2011, J. Brandon George - All rights Reserved