Thanks for your answer, it seems the right way to do this.
I tried but it gives error when the user tries to login
Could not open the company.
While opening company 'test', the following error occured: 'Sorry, the current permissions prevented the action. (TableData User Property Read: System Application)'
AL stack trace:
"Azure AD User Mgmt. Impl."(CodeUnit 9017).Run - System Application by Microsoft
"Azure AD User Mgmt. Impl."(CodeUnit 9017).OnRun(Trigger) line 5 - System Application by Microsoft
"Azure AD User Management"(CodeUnit 9010).OnRun(Trigger) line 2 - System Application by Microsoft
"System Initialization Impl."(CodeUnit 151).Init line 9 - System Application by Microsoft
"Company Triggers"(CodeUnit 2000000003).OnCompanyOpen(Event) line 2
Date and time: Thu, 09 Mar 2023 11:53:32 GMT
Azure AD tenant: undefined
Operation: 1095cbdce8d6499a96955e14099c252c
even though i give the table User rmid permissions , also all codeunits execute permission