[Solved] Base - Startup forms based on authentication

Creating a macro - Writing a Script - Using the API

[Solved] Base - Startup forms based on authentication

Postby gkick » Sat Jan 11, 2020 10:49 pm

Hi,

Playing around with this for some time but not getting anywhere.
Frontend opens calling backend authentication, if the user is SA I want to open the admin form, if its somebody else I want to open a specific user form

The following will actually open both ?

Code: Select all   Expand viewCollapse view
Sub choose()
   If CURRENT_USER = SA Then
         Call OpenAdmin
   End If
   
   If CURRENT_USER <> SA Then
         Call OpenLogInOut
   End if
End Sub


Does not matter if I use "SA" or SA or USER, CURRENT_USER or SESSION_USER
Same result if I use else instead of 2 ifs

In addition the procedure runs prior to the authentication prompt even though its called from the setup (from the splitdb) procedure which sets the authentication prompt for the user name to a null string.

The setup macro is called from the documents on open event. (See attached link)

https://www.dropbox.com/s/qj48930vgfdye ... B.rar?dl=0

Logins SA no password or joe pw pass
Any idea how I can solve this, thks and happy 2020 to all !
Last edited by gkick on Sun Feb 02, 2020 3:24 pm, edited 1 time in total.
Libre Office 6.2 on Windows 10 HSQL 2.5 backend
gkick
 
Posts: 250
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

Re: Base - startup forms based on authentication

Postby Villeroy » Sun Jan 12, 2020 12:16 pm

Create your own log-in dialog.
Code: Select all   Expand viewCollapse view
If oLogInDialog.execute() = 1 then
sUser = oLogInDialog.Name_Input.getString()
sPwd = oLogInDialog.Password_Input.getString()

on error goto errLogin
  oCon = oDB.getConnection(sUser, sPwd)
on error goto 0

Select case sUser
Case in "SA", "Admin", "Master", "Superman"
  sForm = "Admin Form"
Case in "Mickey", "Dickie", "Pluto", "Donald"
sForm = "User Form"
Case else
  sForm = "Readme Form"
End select
else
  msgbox "Log-In canceled"
endif
exit sub
errLogin:
Msgbox "Invalid login"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28433
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Base - startup forms based on authentication

Postby gkick » Sun Jan 12, 2020 11:01 pm

Thank you, this will replace the setup macro to avoid the primary login ? Will get cracking!

mfg
GK
Libre Office 6.2 on Windows 10 HSQL 2.5 backend
gkick
 
Posts: 250
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests