Tuesday, December 17, 2013

RESOLVED : "Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics"

Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics
A closer look into this learned that this is linked to the new partitions feature.
It seems the UserInfo table is not correctly updated and the partition administrator is not updated correctly when you restore an existing DB or the Demo database.
If u check the userInfo table from SQL, what we find it that, not for all partition is our ID/SID configured properly.

To fix this, you can do the following.
  • Stop the AOS
  • Restore the database again
  • Start the AOS
  • Start a client and complete the partition initialiasation checklist
  • Close the client and execute the script below on the SQL database
  • Restart the client and reimport your license (if you were restoring the Microsoft demo data, the demo license is back in there)
  • Then compile / generate CIL / DB sync and you should be on track again!
The script for updating the UserInfo inforation is as follows:
DECLARE @NetworkDomain nvarchar(255); 
DECLARE @NetworkAlias nvarchar(80); 
DECLARE @SID nvarchar(124); DECLARE @InitialPartition BIGINT;  
SELECT @InitialPartition=Recid FROM PARTITIONS WHERE PARTITIONKEY=N'Initial' 
SELECT @NetworkAlias=NETWORKALIAS,@NetworkDomain=NETWORKDOMAIN,@SID=SID FROM USERINFO WHERE PARTITION=@InitialPartition AND ID = N'Admin' 
UPDATE USERINFO SET NETWORKDOMAIN=@NetworkDomain,NETWORKALIAS=@NetworkAlias

Monday, December 16, 2013

Debugging AX while still using restricted roles while being NON Admin- Ax 2012 / Dynamics Ax

Debugging AX while still using restricted roles (non-admin)

Debugging while being non admin to test certain functionality
1.       Close All AX instances

2.       Open AX Development Environment (ax32.exe -development)

3.       Open AX Application (ax32.exe)

4.       Add Role that you would like to test to your UserId

a.       System Administration > Common > Users

b.      Find yourself and double click to get to the detail window

c.       Assign role that you want to test

5.       Close AX Application

6.       Set break points in AX Development Environment

7.       Create a job and add this line

             SecurityUtil::sysAdminMode(false);
 
8.       From the AX Development Environment “Ctrl W” to open the application

9.       You are now in a reduced permission user and have the ability to debug. J
 

To get your environment back to full admin, re-execute the job in step 7 with a true.
GOt this from 

SID of user from active directory / AD

    AX 2012 stores user information in the UserInfo table . While creating a new user manually/sql server, we need to specify the SID of the user. The following X++ code fetches the SID of the user from AD/ registry.

    To get SID of user, without this user will not be able to login to ax, just user will be shown into user form

    xAxaptaUserManager Axmanage;

    Axdetails = Axmanage.getSIDFromName(this.UserId,this.NetworkDomain,UserAccountType::ADUser);

Insert into USERINFO table, Ax 2012

public void insert()
{
    UserInfo userInfo,userInfo1;
    xAxaptaUserManager Axmanage;
    xAxaptaUserDetails Axdetails;

    super();

    Axmanage = new xAxaptaUserManager();
select firstonly userinfo1;

    userInfo.accountType = UserAccountType::ADUser;

    userInfo.networkAlias = userinfo1.NetworkAlias;

    userInfo.networkDomain = userinfo1.NetworkDomain;

    userInfo.id = "USERID";

    userInfo.name = "USERNAME";

    userInfo.company = userinfo1.companyid;

    userInfo.enable = this.Enabled;

// To get SID of user, without this user will not be able to login to ax, just user will be shown into user form

    Axdetails = Axmanage.getSIDFromName(this.UserId,this.NetworkDomain,UserAccountType::ADUser);

    userInfo.sid = Axdetails.getUserSid(0);

    userInfo.insert();
}

SOLVED : The specified client configuration does not contain valid WCF settings AX 2012, AX 2009

"The specified client configuration does not contain valid WCF settings". We often encounter this error when we create new client configurations for Dynamics AX. These are the steps which i followed to solve.
                                    
Do the following to fix the issue:
   Navigate to : Computer> Programs> Administrative Tools 
  1. Open the .axc where this issue was being seen in the Microsoft Dynamics AX Configuration Utility.
  2. Click on the 'Connection' tab
  3. Click on the 'Refresh' button and wait for the process to complete.Click on the 'Configure Services' 

INSTALL DYNAMICS AX 2012 R2 without DOMAIN, personal laptop

Install Dynamics Ax 2012 R2 , without DOMAIN ACCOUNT , personal Laptop.
I Hope this helps you folks
First, Go to System Properties > Advanced Tab > Environment Variables > System Variables then click New.
Put "UserDnsDomain" on the Variable name. Put any value on the variable value.
run Registry Editor or regedit. go to
Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName
put any value on the value data.
Install AX.
Note: After Installing AX, change your ActiveComputerName in the Registry to your default computer name. Use the Computer Name in installing the AOS (computer name before changing the registry.)
then restart.
Hope it helps.

Thursday, December 12, 2013

AX 2012 R2 CU7 Faster Compilation, Really Fast !!

AX 2012 , latest cu7 brings about a major change in the the architecture of AX compilation and build. It uses AXBuild to compile the application faster.
 You can find it in the servers bin directory (C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin on my system) One of the parameters is the number of Workers to use, this allows the compiler to use all the cores available in your system instead of 1 the traditional compile uses. But if I understand the documentation correctly AxBuild.exe is even capable itself to decide the number of workers based on the configuration it runs on. So potentially no need to specify them.
AxBuild.exe can accomplish a full compile of all X++ code, into AX p-code, many times faster than the traditional compile that you start from the MorphX client menu. AxBuild.exe is run on the Application Object Server (AOS) tier at a cmd.exe command prompt. This topic explains what AxBuild.exe does and how to use it.



Wednesday, December 11, 2013


There are many times when we want to create a unique Serial number/ Code to use in Ax, The following job uses standard ax functions to create a serial number.



static void GenerateLicensekey(Args _args)
{ 
   str LicenceKey;
   int iConLen;
   int i,largestStr, conStrLength, j, pos;
   container  c;
  
   //returns a char from the string
    str getLicenceChar(str _fromStr, int position)
    { 
        return subStr(_fromStr, position,1);
    }
   
   c = ['1005','SER_','9001','1808'];

   iConLen = conLen(c);
   largestStr= strLen(conPeek(c,1));

    //get largest string
    for(i =2; i <= iConLen; i++)
    {
         conStrLength = strLen(conPeek(c,i));
 if( conStrLength > largestStr)
        {

            largestStr= conStrLength;
        }
     }

    //perform licence key generation
    for (i=1; i<=largestStr; i++)
    { 
        pos++;

        for(j=1; j<=iConLen; j++)
        { 
            if(pos <= strLen(conPeek(c,j)))
            {
               LicenceKey += getLicenceChar(conPeek(c,j),pos);
            }

            else
            {
                continue;
            }
        }
    }

 info(LicenceKey);
}