Password protected access to menu. Advice ?

Re: Password protected access to menu. Advice ?

Postby James Bott » Fri May 12, 2017 12:56 am

Marc,

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

Code: Select all  Expand view
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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Password protected access to menu. Advice ?

Postby James Bott » Fri May 12, 2017 4: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Password protected access to menu. Advice ?

Postby Enrico Maria Giordano » Fri May 12, 2017 7:44 am

Sure you can!

Code: Select all  Expand view
#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
User avatar
Enrico Maria Giordano
 
Posts: 8522
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Password protected access to menu. Advice ?

Postby Rick Lipkin » Fri May 12, 2017 1: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
User avatar
Rick Lipkin
 
Posts: 2657
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Password protected access to menu. Advice ?

Postby Marc Venken » Fri May 12, 2017 2:26 pm

Rick,

You do not request a pasword is there is a match ?
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1397
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Password protected access to menu. Advice ?

Postby James Bott » Fri May 12, 2017 2: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Password protected access to menu. Advice ?

Postby Rick Lipkin » Fri May 12, 2017 5: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
User avatar
Rick Lipkin
 
Posts: 2657
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Password protected access to menu. Advice ?

Postby Rick Lipkin » Fri May 12, 2017 5: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
User avatar
Rick Lipkin
 
Posts: 2657
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Password protected access to menu. Advice ?

Postby James Bott » Sat May 13, 2017 2: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Password protected access to menu. Advice ?

Postby Rick Lipkin » Sat May 13, 2017 7: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
User avatar
Rick Lipkin
 
Posts: 2657
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Password protected access to menu. Advice ?

Postby James Bott » Sun May 14, 2017 4:13 pm

Rick,

Thanks for all the clarifications.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests

cron