FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Password protected access to menu. Advice ?
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 12:56 AM
Marc,

Yes this can all be done. You would do it in the save method.

Code (fw): Select all Collapse
CLASS TCustomer from TRecord
    Method Save()
endclass

Method Save() Class TCustomer
    ::Updated:= date()

     // Compare all the data in ::aBuffer (new) with ::aBuffer (old)
     // Collect an array of fieldnames or numbers containing the different data
     // Loop through the array and make a string of the fieldnames and old and new data
     // Write the array to a log file.

Return super:Save()

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 04:20 AM
Enrico,

If I well understood what you want to get, isn't this better?


Well, yes you could do it that way, but then you can't use methods.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 07:44 AM
Sure you can!

Code (fw): Select all Collapse
#include "fivewin.ch"


function main()

    TUser():name:= "JBott"

    msgInfo(TUser():name)
    msgInfo(TUser():GetName())

    return nil


class TUser
    classdata name as char

    method GetName()
endclass

method GetName() class TUser

    return ::name


EMG
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 01:33 PM

To All

I use the WNetGetUser() function to extract the logged in User Id on the workstation and save it to a Public variable xLogin .. I use xLogin to find the UserID stored in my security table to assign permissions as you saw earlier .. If there is no match .. I force a manual login.

You could also assign the value of WNetGetUser() to an object like Enrico mentions :

TUser():name:= WNetGetUser()

Basically I am leveraging SSO ( single sign on ) with WNetGetUser() ... a valuable tool and selling point to many Corporations .. the user logs into their workstation via a Corporate network account and WNetGetUser() extracts that UserId value from the workstation .. bounce that against your application security table table to apply permissions in your program.

Rick Lipkin

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 02:26 PM

Rick,

You do not request a pasword is there is a match ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 02:30 PM

Enrico,

Well, I did not know that! Thanks.

Rick,

I note that my WNetGetUser() returns only my first name. What happens if I attach to another network that already has someone with the same first name?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 05:11 PM

James

WNetGetUser() returns the Profile User Id ( or login name ) of the current user.. My Guess is your Profile name on your computer is ( just ) James. IN a network environment .. when a person first logs into a machine with their Corporate Credentials .. a new Profile is made .. and that becomes their default Profile.

My Personal Computer's profile name is "Rick Lipkin" and that is what WNetGetUser() returns ..

In a network environment when I am logged into my Corporate computer my UserId is "Lipkinrm" .. and that is the current Logged in user WNetGetUser() returns.

Rick

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 05:12 PM

Marc

If there is a match .. there is no need to ask for a second login .. hence the term "SSO" Single Sign On.

Rick Lipkin

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Password protected access to menu. Advice ?
Posted: Sat May 13, 2017 02:31 PM

Rick,

So what does WNetGetUser() return when you log your personal computer into your corporate network? Does it stop returning "Rick Lipkin" and start returning "Lipkinrm"?

If so, then it means that if you login to an app on your personal computer you cannot rely on it to always return the same login name. I am sure if that is a problem, just trying to understand.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Password protected access to menu. Advice ?
Posted: Sat May 13, 2017 07:47 PM

James

You are correct .. WNetGetUser() returns the current 'logged in' profile Userid .. so I have two entries in my software depending on which machine or profile I currently am logged into .. one for 'Rick Lipkin' and one for 'LipkinRm'

Rick Lipkin

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Password protected access to menu. Advice ?
Posted: Sun May 14, 2017 04:13 PM

Rick,

Thanks for all the clarifications.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion