Page 1 of 1
How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 6:49 am
by fraxzi
Dear All,
How do you manage user privilege to access certain menu item / edit fields, etc. on your FW?
What is best suited structure? I dunno if I am asking the right question, help me out here.
Any Idea?
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 8:44 am
by bpd2000
Simple logig is enable/disable Menu Item according to user's rights
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 9:02 am
by fraxzi
bpd2000 wrote:Simple logig is enable/disable Menu Item according to user's rights
Hi,
User menu/item is fine.. but what about get objects you define each object per user?
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 9:41 am
by Marc Venken
I have a xbrowse for users previliges for menu's etc..
When they login I read these into a array for granting access to things.
Code: Select all
aTPloegen := ArrTranspose( oRs:GetRows() )
for i = 1 to len(aPloegen)
aadd(aToegang,aTploegen[ 6+I ][1]) // 6 = aantal velden in de browse
next
I use a simple loop for showing the buttons that are relevant for that user :
Code: Select all
lFirsttime:= .T.
for i = 1 to len(aPloegen)
if aToegang[i]
nMove+=30
if aPloegTypes[i] .and. lFirsttime
lFirsttime:= .F.
nMove:=30
nTop:= 90
nLeft:= 1195
endif
@ nTop+nMove,nLeft BTNBMP aBtn[i] OF oDlg SIZE 80, 25 NOBORDER PROMPT aPloegen[i] 2007 ACTION (oRs:SetFilter( "ploeg2018 = ? and exlid = ?", { ::cCaption, .F. } ), oBrw[oFld:nOption]:GoTop(), oBrw[oFld:nOption]:Refresh(),oBrw[oFld:nOption]:setfocus(),oPloeg:refresh(),oBrw[oFld:nOption]:maketotals() ) font oBold CENTER
endif
next
Or I disable the buttons itself
I also make groups of users for easy access to parts of the program.
There are surely better ways, but this is simple... Maybe there will come better sollutions.
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 3:43 pm
by Rick Lipkin
Validating a user is not difficult .. first of all I use the function WnetGetUser:
Code: Select all
xLOGIN := UPPER( WNetGetuser() )+space(15) // fivewin function
xLOGIN := SUBSTR(xLOGIN,1,15)
Take the results of xLogin and search your user table .. if you find a match .. like Marc mentions .. grant roles to that user based on your logic .. the only time I force a login is if the search for xLogin is not found ...
WNetGetUser() returns the value of the user ( Rick Lipkin ) currently logged into their computer .. Assign the roles to variables :
xRead = "Y"
xWrite = "Y"
xMgr = "Y' ... etc
Then interrogate your variables in your menus or modules and enable or disable as appropriate.
Rick Lipkin
Re: How do you handle User Access on your FW App
Posted: Wed Aug 22, 2018 3:50 am
by fraxzi
Dear Gentlemen Mr. Marc and Mr. Rick,
Thanks for the great Idea
I got it sorted now.. defining :nID for each object I wish to control (enable/disable) defined in user table..
iterate these objects based also on defined :nID of Dialog/Window..
Before I used to define menu to access dialogs.. now I control object access per user.. great for multi-user-multi-task level control.