Description: If you need to store passwords in AX there
are some application objects, classes and attributes that you can use.
This post details the steps you can take to allow entry of a password in a
form, which will be stored in the database.
Add the password field to your
table. This field should be of type ‘CryptoBlob’ which is a container that
contains binary data:
Add an edit method for the password to your table:
For Check Record is Exist in the table or not create exist method in table for check record.
Step
1: Create Table Name it “A_PasswordTable”. And Insert Filed in Table.
- Expand AOT Node.
- Open Data Dictionary Node.
- Select Tables and right Click Select New Table.
- Name it “A_PasswordTable”.
- Now open table in Insert Some Data in A_PasswordTabletable.
Step
2: Now Create Form and Name it “A_PasswordForm”. And Add List box and
StringEdit Controls in Design Node.
- Expand AOT Node.
- Select Form Node and Right Click Select New Form and Name it “A_PasswordForm”.
- Now Drag and Drop Table in Form DataSource.
- Design your Form like below.
Add an edit method for the password to your table:
edit Password editPassword(boolean _set = false, Password _pwd = '') { CryptoBlob cryptoBlob = connull(); ; if (_set) { this.Password = WinapiServer::cryptProtectData(str2cryptoblob(_pwd)); } return (this.Password == connull()) ? '' : 'xxxxxxxx'; }
- Drag and drop the edit method to your form and ensure that the attribute ‘PasswordStyle’ is set to ‘Yes’:
static Password getPassword(UserId _userId) { CryptoBlob cryptoBlob = A_PasswordTable::find(_userId).Password; ; return (cryptoBlob == connull()) ? '' : cryptoblob2str(WinapiServer::cryptUnProtectData(cryptoBlob)); }
For
finding Record in table Create find Method in Table.
public static A_PasswordTable find(UserName _userName,boolean _forUpdate = false) { A_PasswordTable PasswordTable; ; if (_userName) { PasswordTable.selectForUpdate(_forUpdate); selectfirstonly PasswordTable where PasswordTable.UserName == _userName; } return PasswordTable; }
For Check Record is Exist in the table or not create exist method in table for check record.
public static boolean exist(UserName _userName) { ; return (select RecId from A_PasswordTable where A_PasswordTable.UserName == _userName).RecId != 0; }
1 comments:
commentsNice explained bhai
ReplyThanks for comments.....