Page 1 of 3 123 LastLast
Results 1 to 15 of 31

Thread: Verifying users

  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Verifying users

    I am wanting to give access to specific files by verifying the users ID, probably from AD, but haven't a clue how to go about this.

    HELP!!
    cheers

    Phil Carter

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Phil,

    Can't help you with Acvtive Directory but on a local machine you would capture the UserID as follows:

    Code:
    zUserName = Environ("USERNAME")
    Once captured you would then compare it against an array containing all valid users.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    3 Star Lounger HiTechCoach's Avatar
    Join Date
    Sep 2011
    Location
    Oklahoma City, OK
    Posts
    200
    Thanks
    0
    Thanked 31 Times in 30 Posts
    Warning: Environ("USERNAME") can easily be change by the user.

    I use this: http://access.mvps.org/access/api/api0008.htm


    FWIW: During testing I use Environ("USERNAME") because it is so easy to change and then reopen the database to change users. Before deployment I switch back to the API above. I have never been able to fool the API.


    Getting the current Windows user name lhat is logged on is great if the Windows users is also the database user. This allow for automatic log on or Single Sign On. I like to use a table is access to look up the permissions based on the Windows user name. If the Windows User name is not found tin the user table then they are not allow in the database.

    You may need to use AD if the database user may not be the user logged onto Windows or you need to check the user's AD security groups for permissions. If you do need to use AD, let me know and I will post some code.

    .I prefer to roll my own security model all in Access. I will use the Windows User name to log in but I have my own users and permissions tables that the Windows user name is verified against. This keeps the security groups in AD simple. It allows the Access sercuity to be robust and easily changed without any AD updates.
    Last edited by HiTechCoach; 2015-08-19 at 03:19.
    Boyd Trimmell aka HiTechCoach (Access Information here)
    Microsoft MVP - Access Expert
    "If technology doesn't work for people, then it doesn't work."

  4. The Following User Says Thank You to HiTechCoach For This Useful Post:

    Maudibe (2015-08-19)

  5. #4
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    RG hi again
    I decided to go with your suggestion but am having problems getting it to work.
    I have defined the variable zUserName,

    Dim zUserName As String

    zUserName = Environ("UserName")

    and used it like this

    Case OptSharon
    If zUserName = "Sharon Thomas" Or "Jen Ferguson" Then

    Selection.InlineShapes.AddPicture FileName:= _
    "P:\_IANZ\CorporateServices\BusinessServices\Graph ics\Signatures\Sharon Thomas.jpg" _
    , LinkToFile:=False, SaveWithDocument:=True

    With ActiveDocument.InlineShapes(ActiveDocument.InlineS hapes.Count)
    .LockAspectRatio = msoTrue
    .Width = CentimetersToPoints(2.5)
    End With
    Else
    MsgBox "You do not have permission to use this signature!", 48
    End

    What am I doing wrong?
    cheers

    Phil Carter

  6. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Phil,

    What is the username? Is it "OptSharon" or is it "Sharon Thomas" ?

    Generally you want something like this:

    Code:
    Select Case zUserName
          Case "Sharon Thomas","Jen Ferguson"
            ---   What you want done here   ---
          Case "Next User Name with different actions"
            .
            .
            .
          Case Else
                MsgBox "You do not have permission to use this signature!",  _
                            vbOkonly+vbCritical, _
                            "Msg Box Title Here!"
    End Select
    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. #6
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    RG
    The purpose of this is for the users or their assistants to select signatures to attach to documents. I have created a user form with 10 signatories listed and have used OptionButtons to select, hence the Case statements.
    The user, in this case, is Sharon and the secretary is Jen.
    cheers

    Phil Carter

  8. #7
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,634
    Thanks
    115
    Thanked 649 Times in 592 Posts
    If you do need to use AD, let me know and I will post some code.

    HiTechCoach,

    I would be very much interested in taking a look at your code to authenticate using the AD.

    Thanks,
    Maud

  9. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Phil,

    Ok if I understand your goal here's what I'd suggest.

    In your Form Activate event use code like this:
    Code:
    Private Sub UserForm_Activate()
    
       OptSharon.Visible = False
     '--- Repeat for each OptButton ---
    
      Select Case zUserName
          Case "Sharon Thomas"
              OptSharon.Visible = True
          Case "Jen Ferguson"
              OptSharon.Visible = True
    
          Case "Next User Name with different actions"
            .
            .
            .
          Case Else
                MsgBox "You do not have permission to use this Document!",  _
                            vbOkonly+vbCritical, _
                            "Msg Box Title Here!"
          Unload Me
    
      End Select
    
    End Sub
    For any given user the form will now only show those signatures they are authorized to use.

    Now for each Option button create a Click Event as follows:
    Code:
    Sub OptSharon_Click()
    
        Process signature here!
        Unload Me
    End
    Now when any user selects a signature by clicking the option button it is immediately processed and the form unloaded. Note you can have as many OptButtons under each case statement as necessary. So say a supervisor could have them all visible and pick any signature. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  10. The Following User Says Thank You to RetiredGeek For This Useful Post:

    bonriki (2015-08-24)

  11. #9
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Thanks RG
    Looks better than what I was proposing
    However, having got all the code in it now will not recognise any users and we just get the VBWarning with a blank userform in behind, which is correct because it has been instructed to not show anything until the user is verified.

    I have set myself as the "Supervisor"

    Mmmmmm!!!!!!!!
    cheers

    Phil Carter

  12. #10
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,180
    Thanks
    47
    Thanked 983 Times in 913 Posts
    Are you sure your users are named "Sharon Thomas" etc? Use names don't usually have spaces in them.

    cheers, Paul

  13. #11
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Yes
    Checked my username and it is of the same format "Phil Carter". As stated I have set myself as supervisor, not that I need to use the signatures, but because I need to verified that the links work.
    cheers

    Phil Carter

  14. #12
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Phil,

    Could you post your modified code? HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  15. #13
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Sure
    It is in the attached *.dotm, frmSigInsert
    Attached Files Attached Files
    cheers

    Phil Carter

  16. #14
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I've had a look at it and tidied the code up to remove the massive amounts of duplication. I generally prefer to use the properties of the controls themselves to make the VBA code a lot shorter. In this example I used the ControlTipText and the Tag properties on each option control to carry the changeable information. See attached file with the form frmSigInsert2

    Personally, I find the method of hiding option buttons an odd way to present these choices to the user. Users will see an oddly arranged list since unexplained gaps will appear in the spacing. This would be significantly improved by using a listbox instead. For even better usability, I would probably do this by using a dynamic ribbon which presents the available options on a ribbon button so there is no userform involved at all. I would most likely also change the methodology to store copies of each signature in the template itself (as building blocks) so that connection to the network drive is not required.
    Attached Files Attached Files
    Last edited by Andrew Lockton; 2015-08-25 at 20:27.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  17. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    bonriki (2015-08-25)

  18. #15
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts
    Thanks Andrew
    I can't see any difference in the way this performs. It still loads the blank form in the background and then pops the warning message. So my UserName is not being recognised.
    cheers

    Phil Carter

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •