Here is how you can store encrypted passwords in D365FO:
1. Preferably create a new table specifically for this purpose
Create a new field of type container and EDT EncryptedField called "Password"
2. Overwrite update and insert methods of the table:
1 2 3 4 5 6 7 8 9 10 11 12 | public void update() { Global::handleEncryptedTablePreUpdate(this); super(); Global::handleEncryptedTablePostUpdate(this); }public void insert() { Global::handleEncryptedTablePreInsert(this); super(); Global::handleEncryptedTablePostInsert(this); } |
3. Add edit method to the table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public edit Password passwordEdit(boolean _set, Password value) { System.Exception ex; Password password = ''; try { password = Global::editEncryptedField(this, value, fieldNum(VKParameters, Password), _set); } catch (ex) { boolean exceptionNested = false; while (ex != null) { exceptionNested = true; ex = ex.InnerException; } if (_set) { warning(strFmt("Failed to save the '%1'. Please try again.", fieldId2PName(tableNum(VKParameters), fieldNum(VKParameters, Password)))); } else { warning(strFmt("Failed to read the '%1'. Please clear and re-enter it.", fieldId2PName(tableNum(VKParameters), fieldNum(VKParameters, Password)))); } } return password; } |
To decrypt stored password you can use the same passwordEdit method:
1 | Info(parameters.passwordEdit(false, '')); |
Password EDT allows you to store only up to 20 chars, change it if you need more.
Standard example:
- System administration / Setup / Email / Email parameters / SMTP settings
- SysEmailParameters form
- SysEmailSMTPPassword table

No comments:
Post a Comment