How do you handle User Access on your FW App

Post Reply
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

How do you handle User Access on your FW App

Post 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?
: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
User avatar
bpd2000
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: How do you handle User Access on your FW App

Post by bpd2000 »

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

Try FWH. You will enjoy it's simplicity and power.!
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: How do you handle User Access on your FW App

Post 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?

:?:
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
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: How do you handle User Access on your FW App

Post by Marc Venken »

I have a xbrowse for users previliges for menu's etc..

Image

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.
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: How do you handle User Access on your FW App

Post 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 ...

Image

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
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: How do you handle User Access on your FW App

Post by fraxzi »

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
Post Reply