The Infolog

A blog of Dynamics AX development tips and tricks

Skip to: Content | Sidebar | Footer

Storing passwords in AX

23 July, 2015 (13:46) | Dynamics AX | By: Howard Webb

I needed to store a password in AX today and as it has been a while and I forgot, I thought I would post a blog to reference the next time. While there is a password stringEDT we should really be using a CryptoBlob as this will store the password as binary data and will not be readable by a human.

With the field added to our table it is then best to create an edit method on the table for the password allowing ease of use in multiple forms. We will use the standard framework to encrypt (and later decrypt) the password. We will return an empty string if the password is not set, a string of fixed length if there is a password and it has not just been set and finally a string of the correct length if it has just been set in the field:

 

 

We will then add the field to the form, remembering to set the PasswordStyle property to yes:

 

 

 

This will then store the password as an encrypted blob in the database.

 

To unencrypt it we can use the WinAPIServer class again:

 

password = cryptoblob2str(WinAPIServer::cryptUnProtectData(BobTheBlob));

 

Print Friendly, PDF & Email

Comments

Comment from Kanoa
Time 31st January 2018 at 15:21

I ran into issues when the batch server was different than the

Comment from Kanoa
Time 31st January 2018 at 15:22

I ran into issues when the batch server was different than the server in which the encrypted password was stored. Please be aware of this if using this method.

Write a comment