Copy password

3
The UserManagement.Account object has previously been specialized in the project I'm working on. We want to undo that specialization, but just deleting the specialized object also deletes the values from UserManagement.Account and System.User. To solve this I want to copy the relevant data from the specialized object to a new UserManagement.Account object; however, this goes wrong with the password. In Microflows you can't use the password and set it on a new object. With Java setValue() it seems to rehash the string, because the passwords have changed afterwords. Is there any way to copy the hashed string in Mendix?
asked
3 answers
4

I temporarily store the hashed value in a string with a java action. Then i use a java action to set this hash string as the password

        this.UserObject = UserObject;
    this.PasswordHash = PasswordHash;
}

@Override
public Boolean executeAction() throws Exception
{
    // BEGIN USER CODE
    IMendixObjectMember<?> m = this.UserObject.getMember(getContext(), "Password");
    ((MendixHashString) m).setHash(getContext(), PasswordHash);
    return true;
answered
2

Remove the specialization but don't remove the the objects. The specialized objects are also in the user and account table. Password data is stored there.

If this procedure failes update the account table and change the column submetaobjectname to 'Administration.Account' with a SQL query directly in the database. If the database is in the cloud, download the database, restore, change the colomn values, create a backup again and upload to the cloud.

Always keep backups for every step as fallback scenario!

Edit1: if this fails, store the hashes from the administration@account table in a file or somewhere else, update the database and recover the hashes. Match on name.

answered
0

The following steps work:

  • Download backup from PROD
  • Copy system$user to e.g. Excel file
  • Run MF to replace all specialized objects with normal accounts
  • Run SQL-script to alter passwords with previously saved data
  • Backup local data from PGAdmin
  • Upload backup to MendixCloud again

However this seems like a massive detour just because Mendix doesn't allow hashed strings to be copied, but instead re-hashes them whenever you set the value. Which in itself is again a detour because you can't delete a specialization with the data in the general object staying intact.

Anybody with hint on how to copy hashed strings using Java?

answered