Move Dynamics AX database to different Domain/machine.

How to move database from Machine 1 to Machine 2, they both have different User and Domain ?

Steps are very simple:

1. Attached the database,
2. Add your AX login to the database you attached.
3. Open the “userinfo” table from sql server
4. Find the row with ‘Admin’ Id
5. Update the following columns
5.1 SID with your machine SID
5.2 NetworkDomain with your network domain,
5.3 NetworkAlias with your AX logged in user.
6. Now start the AX

First ways to get SID using registry path.
If you dont know how to get the SID, Here are the steps for this too.

The SID can be fetched from registry editor. for this open command prompt from Start manu, type “Regedit” and press enter key.

Please note in the above mentioned window (Registry Editor) in the path specified path : HKEY_USERS\S-1-5-21-1494175365-1026638594-2087099728-XXXX.. This first big key is your user’s SID

Second ways to get SID is using the Ntdsutil command line util,

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2008, Windows Server 2008 R2

Ntdsutil.exe is a command-line tool that provides management facilities for Active Directory Domain Services (AD DS) and Active Directory Lightweight Directory Services (AD LDS). You can use the ntdsutil commands to perform database maintenance of AD DS, manage and control single master operations, and remove metadata left behind by domain controllers that were removed from the network without being properly uninstalled. This tool is intended for use by experienced administrators.

Ntdsutil.exe is built into Windows Server 2008 and Windows Server 2008 R2. It is available if you have the AD DS or the AD LDS server role installed. It is also available if you install the Active Directory Domain Services Tools that are part of the Remote Server Administration Tools (RSAT).

1. Go to Run > cmd
2. Type ntdsutil and press Enter
3. ntdsutil prompt opens (ntdsutil: )
4. Type group membership evaluation and press Enter
5. Group membership evaluation prompt opens
6. Type run DOMAIN <User> and press Enter
7. A .tsv file will be created in C:\Documents and Settings\<User> OR <User>.DOMAIN
8. Open .tsv file and copy the first SID appear in the file OR the SID associated to your User Name

Reflections : Changing properties of AOT objects in code

Few days back i was working to update some properties of dynamics ax objects, objects count was quite high and manually doing that work could be hectic. i decided to use the reflection and i found it real powerful as it has lots of area where needs playing.

My scenario was simple where i need to find objects on my own criteria and then update the properties for those objects.

like i have to find out all those classes which starts with ‘XXX’

static void FindClassStartsWithXXX(Args _args)
 {
   UtilIdElements utilId;
 ;
   while select utilId where utilid.recordType == UtilElementType::Class
   && utilId.name like 'XXX*'
   {
     print utilId.name;
   }
   pause;
 }

i also have to update properties of selected objects, like here i am updating the name property of the class.

static void RenameXXXObjectsToYYY(Args _args)
 {
   TreeNode  node = TreeNode::findNode(@'\Classes\XXXClass');
   str oldName;
   str newName;
   #Properties
   ;
   oldName = node.AOTgetProperty(#PropertyName);
   newName = strdel(oldName,1,3);
   node.AOTsetProperty(#PropertyName, "YYY"+newName);
   node.AOTsave();
   node.treeNodeRelease();
   node = null;
 }

There are a couple of things to explain here. First of all the macro #Properties contains the names of all properties you can read and write. These are the same as what you get in the property window. Use the macro instead of literal strings, it’s safer and doesn’t violate best practices.

Next you can see there is a set of methods to get and set properties. After modifying anything you need to save the changes, just like you would when changing an AOT object in the property window. TreeNode works just like doing it manually. You can do a lot more fun stuff with the TreeNode API.

Also, if you have questions or ideas for articles don’t hesitate to let me know .

Design Pattern used in Dynamics Ax

I have found the good resource of design patters used in Microsoft Dynamics Ax.

Design Pattern Dynamics ax

%d bloggers like this: