Dear All,
I was still having the same problem, and I browsed the Net to find a viable solution, and I came accros my old unsolved post.
So this time I ensured that better did my homework.
I will share here the solution I applied that fulfilled my goal.
It might interest some else.
I first want to say that I worked with the recent versions of those involved programs, and I did not attempted to see if a similar solution could have been devised for the old version I used in the past.
My actual environment is as below
Rocky Linux 8.5
postfix 3.5
dovecot 2.3
MariaDB 10.5
roundcubemail 1.4.12
roundcube password plugin configured to interact directly with the database table to keeps the sha512-crypt encrypted user passwords.
It appeared that the relevant settings to have in roundcubemail are two below
$config['auto_create_user'] = false;
$config['user_aliases'] = true;
$config['password_force_new_user'] = true;
With the above, obviously new users will not be auto created, and they will be able to log in with identities present in the identities table. But still, those new users will have to exist in the virtual emails table with valid password.
The last one will force new users to change their passwords at next login and prevent them to perform any other action before.
So with the below bash commands I am able to easily automate the provisioning of users and allow a valid user to log in on roundcubemail.
Code:
DVL_Virtual_Local_Part='foobar'
DVL_Virtual_Domain_Name='example.com'
DVL_Password_MariaDB_roundcube='roundcube_password'
DVL_Virtual_User_ID="$( echo "INSERT INTO users (username, mail_host, created, preferences) VALUES ('${DVL_Virtual_Local_Part,,}@${DVL_Virtual_Domain_Name,,}', 'localhost', NOW(), 'a:1:{s:15:\"newuserpassword\";b:1;}') RETURNING user_id" | mariadb -ss --user=roundcube --password="${DVL_Password_MariaDB_roundcube}" roundcube | tee /dev/tty )"
DVL_Virtual_Identity_ID="$( echo "INSERT INTO identities (user_id, email, name, organization, standard, changed) VALUES (${DVL_Virtual_User_ID}, '${DVL_Virtual_Local_Part,,}@${DVL_Virtual_Domain_Name,,}', '${DVL_Virtual_Local_Part^}', '${DVL_Virtual_Domain_Name^}', 1, NOW()) RETURNING identity_id" | mariadb -ss --user=roundcube --password="${DVL_Password_MariaDB_roundcube}" roundcube | tee /dev/tty )"
In order to not post a long reply to this old thread, I have occulted some aspects and configurations that one might stumble across when trying to reuse what I present here for example.
Just let me know and I will be glad to help if I can.
Finally, I will mark this thread as SOLVED.