Solved

Remember Me Login Solution

Posted on 2004-08-22
8
242 Views
Last Modified: 2006-11-17
For history on this question see:
http://www.experts-exchange.com/Databases/MS_Access/Q_21102597.html

"" A suggestion from someone who does not use secure databases (so it can be taken with a grain of salt):

Using the "Environ("userName")" you could make a login screen with the option of "Remeber Me" it then stores the user name and login name in a table and when loading first checks the user name against the table to see if it has a login stored for that user, if not popup login screen. Users can then logout and re-login as another user on the same machine similar to EE.

I've got several scripts that I can share that I think would be useful in building such a system.  ""
0
Comment
Question by:StanKobrin
  • 6
  • 2
8 Comments
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11864533
   First, a question: Do you have a system for storing environment data(keys) in your database? For example, in the case of the "Remember Me" login system do you have a method built already to quickly store such info and pull it out when needed? I've built a system for this (not specifically for login settings, but in general for storing any key data in the local database for your program's use) and will post a link where you can download it from if you don't have one that you are using already.

Sam.
0
 

Author Comment

by:StanKobrin
ID: 11864574
No not really. I suppose it is something that I should have ins'nt it?

If you are willing, I would love to take a look at your system and see exactly how this is done!

Stan.
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11864711
OK Stan,

I will post a copy for download tomorrow. If you like it you can feel free to use it freely.

Sam.
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11871452
Hi Stan,
    I hope all is well. I finaly posted the sample I promised here:


    There are several things in this database that I created as samples for others in various EE threads, but the main thing you will need for this is the module named "sys_ini_utilities" and the two supporting tables "sys_ini" & "sys_inidim". These together are a system for recording/reading you database's environment keys. If you look at the code in the "sys_ini_utilities" module at the very top it gives a brief overview of the functions contained in it,b the basics of how it works are as follows:

    1.) The keys you record are stored in the "sys_ini" table.
    2.) If you want to stor more than 1 key value for a specific key
         (For example you build a form to get a path on the users)
         (machine and you want to store the last 5 user selected paths)
         then you manually make an entry an entry in the "sys_inidim"
         table, listing how many instances of the key to record
    3.) To record a key value use the "WriteIniKey" function, which
         has the following arguments:
               a.) iSection    -> (Group Name)
               b.) iKey         -> (Individual Key Name)
               c.) iValue       -> (Key Value)
         You will need to decide on a naming convention for the keys
         that you store so that you can easily find & record the needed
         values.
    4.) To read the value of a Key use the GetIniKey function with the
         following arguments:
               a.) iSection
               b.) iKey
         this will return the value of the key requested. For example:
               SavePath = GetIniKey("Paths", "Save")
         will return the value stored for the key in group "Paths" named
         "Save" to a variable named "SavePath".
    5.) To check if a key exists use CheckIniKey with the same
         arguments as GetIniKey (iSection & iKey). Returns a boolean

That is the basics of how that works. I will give an example of how it can be used for a login with "Remeber Me" in my next post.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11871465
Oops I forgot the link to the sample database:
    http://www.geocities.com/will_scarlet7/SampleMDB.html
0
 
LVL 15

Accepted Solution

by:
will_scarlet7 earned 500 total points
ID: 11871656
For a login system using the above system to save the info I built a form that is not bound to a data source with 3 controls:
      1.) Login Name (a combo box named "CmbLoginName" that gets it's values from a table containing a list of names allowed to use the system)
      2.) A check box (named "ChkRememberLogin" that the user can check if they want to auto login in the future)
      3.) A command button to close the form

In the code for the form I created a public variable called frmAutoLogin so that it will ignore the OnClose events reccording of login info when Auto Logging on to the database.

Then in the OnOpen even I put the following:
'********************************
Private Sub Form_Open(Cancel As Integer)
    'Get name of user currently signed on to system
    CurSystemUser = Environ("UserName")
    'First clear any previous user name
    WriteIniKey "CurLogin", CurSystemUser, ""
    'Set default AutoLogin State
    frmAutoLogin = False
    'If current system user has a AutoLogin preference saved already
    If CheckIniKey("AutoLogin", CurSystemUser) Then
        'If AutoLogin preference for current system user is true
        If GetIniKey("AutoLogin", CurSystemUser) = "True" Then
            'Record curent user login name
            WriteIniKey "CurLogin", CurSystemUser, GetIniKey("LoginAs", CurSystemUser)
            'Set AutoLogin state to "True"
            frmAutoLogin = True
            'Close login form
            DoCmd.Close
        End If
    End If
End Sub
'********************************
And in the OnClose event:
'********************************
Private Sub Form_Close()
    'If AutoLogin state was false
    If Not frmAutoLogin Then
        'If no login name provided, quit the database
        If IsNull(CmbLoginName) Then
            DoCmd.Quit
        Else
            'Record Login Name
            WriteIniKey "CurLogin", CurSystemUser, CmbLoginName
            'Record whether or not user wants to auto login
            '   in the future
            If ChkRememberLogin = -1 Then
                'AutoLogin for current system user set to "True"
                WriteIniKey "AutoLogin", CurSystemUser, "True"
                'Database login name for current system user
                WriteIniKey "LoginAs", CurSystemUser, CmbLoginName
            Else
                'AutoLogin for current system user set to "False"
                WriteIniKey "AutoLogin", CurSystemUser, "False"
            End If
        End If
    End If
End Sub
'********************************
For the command button simply:
'********************************
Private Sub CmdLogin_Click()
    DoCmd.Close
End Sub
0
 

Author Comment

by:StanKobrin
ID: 11884890
Hi Sam

This is quite a lot to digest. Your sample is keeping me busy at the moment :)

I am going to accept the question to award you the points, and will check back in with you in a few days as to my progress in implementing this. (I will create a dummy app just to learn the process)

Thanks for the samples and support!

Stan
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11885305
ThanX for the points and the grade Stan! Glad I could be a help.

Sam.

PS. While I realise it is complex at first, I've found that this program helps to simplify my programming work in lots of areas.
Feel free to post any questions here.

God bless!
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now