Page 2 of 2
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 12:56 am
by James Bott
Marc,
Yes this can all be done. You would do it in the save method.
Code: Select all | Expand
CLASS TCustomer from TRecord
Method Save()
endclass
Method Save() Class TCustomer
::Updated:= date()
// Compare all the data in ::aBuffer (new) with ::oTable: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
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 4:20 am
by James Bott
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
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 7:44 am
by Enrico Maria Giordano
Sure you can!
Code: Select all | Expand
#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
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 1:33 pm
by Rick Lipkin
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
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 2:26 pm
by Marc Venken
Rick,
You do not request a pasword is there is a match ?
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 2:30 pm
by James Bott
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
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 5:11 pm
by Rick Lipkin
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
Re: Password protected access to menu. Advice ?
Posted: Fri May 12, 2017 5:12 pm
by Rick Lipkin
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
Re: Password protected access to menu. Advice ?
Posted: Sat May 13, 2017 2:31 pm
by James Bott
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
Re: Password protected access to menu. Advice ?
Posted: Sat May 13, 2017 7:47 pm
by Rick Lipkin
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
Re: Password protected access to menu. Advice ?
Posted: Sun May 14, 2017 4:13 pm
by James Bott
Rick,
Thanks for all the clarifications.
James