FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How do you handle User Access on your FW App
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 06:49 AM

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?


:idea::idea::idea:

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 153
Joined: Tue Aug 05, 2014 09:48 AM
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 08:44 AM

Simple logig is enable/disable Menu Item according to user's rights

Regards, Greetings



Try FWH. You will enjoy it's simplicity and power.!
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 09:02 AM
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?

:-)
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 09:41 AM
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 (fw): Select all Collapse
   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 (fw): Select all Collapse
   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.
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How do you handle User Access on your FW App
Posted: Sat Aug 18, 2018 03:43 PM
Validating a user is not difficult .. first of all I use the function WnetGetUser:

Code (fw): Select all Collapse
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
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: How do you handle User Access on your FW App
Posted: Wed Aug 22, 2018 03:50 AM

Dear Gentlemen Mr. Marc and Mr. Rick,

Thanks for the great Idea :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.


:wink::wink::wink:

Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15

Continue the discussion