Log user on opening

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • diverdon99

    Log user on opening

    I have a database that is using an audit table that logs the machine and
    user to each record change. My problem is that more than 1 user uses the
    same login, (this will not change!) hence the audit trail is valueless whn
    trying to identify an individual.
    I need a login form that will validate a user against a stored table of
    passwords and then add that username to any audited entries made during that
    session.
    Any ideas to solve this are most welcome.

    Thanks
    Diverdon


  • xzzy

    #2
    Re: Log user on opening

    snag their NT login name and box name to determine who is who

    John Bickmore



    "diverdon99 " <diverdon99@yah oo.co.uk> wrote in message
    news:brds4a$e8r $1@hercules.bti nternet.com...[color=blue]
    > I have a database that is using an audit table that logs the machine and
    > user to each record change. My problem is that more than 1 user uses the
    > same login, (this will not change!) hence the audit trail is valueless whn
    > trying to identify an individual.
    > I need a login form that will validate a user against a stored table of
    > passwords and then add that username to any audited entries made during[/color]
    that[color=blue]
    > session.
    > Any ideas to solve this are most welcome.
    >
    > Thanks
    > Diverdon
    >
    >[/color]


    Comment

    • Betty

      #3
      Re: Log user on opening


      "xzzy" <mrbikejoc1@com cast.net> wrote in message
      news:wVvCb.5273 26$Tr4.1453524@ attbi_s03...[color=blue]
      > snag their NT login name and box name to determine who is who
      >
      > John Bickmore
      > www.BicycleCam.com
      > www.Feed-Zone.com[/color]

      How is that done? Can you give a code example?

      -- Betty "Boop" Martin


      Comment

      • Alan Lane

        #4
        Re: Log user on opening

        Hi Betty:

        Here is how I do it. It works for me. Your mileage may vary.

        First, create a global variable name, g_strUserName, to hold the network
        name value that you will use in multiple places in your code. Then, use the
        following function, which I got from http://www.mvps.org/access/

        Function GetUserName() As String

        Dim ret As Long
        Dim cbusername As Long

        g_strUserName = ""
        g_strUserName = Space(256)
        cbusername = Len(g_strUserNa me)
        ret = WNetGetUser(ByV al 0&, g_strUserName, cbusername)

        If ret = 0 Then ' Success - strip off the null.
        g_strUserName = Left(g_strUserN ame, InStr(g_strUser Name, Chr(0)) - 1)
        Else
        g_strUserName = ""
        End If

        GetUserName = g_strUserName

        End Function

        Note that, in order for this to work, you must put:

        Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUse rA" (lpName As Any,
        ByVal pUserName$, pnLength&)

        at the top of your module.

        Good luck.

        Alan


        Comment

        • diverdon99

          #5
          Re: Log user on opening

          Thats how I get the 'alleged' logged on use, but the problem is that a
          number of people use the same NT logon. I need to record the actual user
          after them logon through a user form or similar and write this name into a
          transaction (audit) file.
          We have a policy that only staff members can have a logon and as is common
          we have a lot of temps that need to be logged on. Thats how duplicate NT
          (User) logons happen.

          Diverdon



          "Alan Lane" <awelane@nether e.com> wrote in message
          news:s7xCb.1137 $jK3.394@twiste r.socal.rr.com. ..[color=blue]
          > Hi Betty:
          >
          > Here is how I do it. It works for me. Your mileage may vary.
          >
          > First, create a global variable name, g_strUserName, to hold the network
          > name value that you will use in multiple places in your code. Then, use[/color]
          the[color=blue]
          > following function, which I got from http://www.mvps.org/access/
          >
          > Function GetUserName() As String
          >
          > Dim ret As Long
          > Dim cbusername As Long
          >
          > g_strUserName = ""
          > g_strUserName = Space(256)
          > cbusername = Len(g_strUserNa me)
          > ret = WNetGetUser(ByV al 0&, g_strUserName, cbusername)
          >
          > If ret = 0 Then ' Success - strip off the null.
          > g_strUserName = Left(g_strUserN ame, InStr(g_strUser Name, Chr(0)) -[/color]
          1)[color=blue]
          > Else
          > g_strUserName = ""
          > End If
          >
          > GetUserName = g_strUserName
          >
          > End Function
          >
          > Note that, in order for this to work, you must put:
          >
          > Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUse rA" (lpName As[/color]
          Any,[color=blue]
          > ByVal pUserName$, pnLength&)
          >
          > at the top of your module.
          >
          > Good luck.
          >
          > Alan
          >
          >[/color]


          Comment

          • Mike MacSween

            #6
            Re: Log user on opening

            "diverdon99 " <diverdon99@yah oo.co.uk> wrote in message
            news:brekru$q51 $1@titan.btinte rnet.com...[color=blue]
            > Thats how I get the 'alleged' logged on use, but the problem is that a
            > number of people use the same NT logon. I need to record the actual user
            > after them logon through a user form or similar and write this name into a
            > transaction (audit) file.[/color]

            That's easy. Use Windows NT users and groups properly. If you can't be
            bothered to do that then just used Access security. I assume that this is
            all about using an Access database.


            Comment

            • Betty

              #7
              Re: Log user on opening


              "Alan Lane" <awelane@nether e.com> wrote in message
              news:s7xCb.1137 $jK3.394@twiste r.socal.rr.com. ..[color=blue]
              > Hi Betty:
              >
              > Here is how I do it. It works for me. Your mileage may vary.
              >
              > First, create a global variable name, g_strUserName, to hold the network
              > name value that you will use in multiple places in your code. Then, use[/color]
              the[color=blue]
              > following function, which I got from http://www.mvps.org/access/
              >
              > Function GetUserName() As String
              >
              > Dim ret As Long
              > Dim cbusername As Long
              >
              > g_strUserName = ""
              > g_strUserName = Space(256)
              > cbusername = Len(g_strUserNa me)
              > ret = WNetGetUser(ByV al 0&, g_strUserName, cbusername)
              >
              > If ret = 0 Then ' Success - strip off the null.
              > g_strUserName = Left(g_strUserN ame, InStr(g_strUser Name, Chr(0)) -[/color]
              1)[color=blue]
              > Else
              > g_strUserName = ""
              > End If
              >
              > GetUserName = g_strUserName
              >
              > End Function
              >
              > Note that, in order for this to work, you must put:
              >
              > Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUse rA" (lpName As[/color]
              Any,[color=blue]
              > ByVal pUserName$, pnLength&)
              >
              > at the top of your module.
              >
              > Good luck.
              >
              > Alan
              >[/color]


              Thanks, Alan!



              Comment

              • diverdon99

                #8
                Re: Log user on opening

                Mike,

                Can you explain a little further on NT Users and Groups property, I must be
                missing something obvious here.
                All the reading on Access security has suggested that it is a last resort as
                it is difficult to set up and the risk of locking yourself out is high.

                Here is the code that I use to get the logon and more than 1 person can
                logon under the same name, therefore the audit trail has not identified the
                individual person but rather the logged in person. This is why I thought
                the route to go would be to have the user select their name from a dialog or
                form then store this in a global variable and write this to the audit table
                on an event change.
                Whilst I thought this is the way to go, I am short on the knowledge for
                implementation.


                'Code Start *************** ****
                Option Explicit

                Private Const conMod As String = "ajbAudit"
                Declare Function wu_GetUserName Lib "advapi32" Alias "GetUserNam eA" (ByVal
                lpBuffer As String, nSize As Long) As Long

                Function NetworkUserName () As String
                Dim lngStringLength As Long
                Dim sString As String * 255

                lngStringLength = Len(sString)
                sString = String$(lngStri ngLength, 0)

                If wu_GetUserName( sString, lngStringLength ) Then
                NetworkUserName = Left$(sString, lngStringLength )
                Else
                NetworkUserName = "Unknown"
                End If
                End Function

                Diverdon


                "Mike MacSween" <mike.macsween. nospam@btintern et.com> wrote in message
                news:3fdaf2e4$0 $52881$5a6aecb4 @news.aaisp.net .uk...[color=blue]
                > "diverdon99 " <diverdon99@yah oo.co.uk> wrote in message
                > news:brekru$q51 $1@titan.btinte rnet.com...[color=green]
                > > Thats how I get the 'alleged' logged on use, but the problem is that a
                > > number of people use the same NT logon. I need to record the actual[/color][/color]
                user[color=blue][color=green]
                > > after them logon through a user form or similar and write this name into[/color][/color]
                a[color=blue][color=green]
                > > transaction (audit) file.[/color]
                >
                > That's easy. Use Windows NT users and groups properly. If you can't be
                > bothered to do that then just used Access security. I assume that this is
                > all about using an Access database.
                >
                >[/color]


                Comment

                • Mike MacSween

                  #9
                  Re: Log user on opening

                  "diverdon99 " <diverdon99@yah oo.co.uk> wrote in message
                  news:brf9ht$2bc $1@sparta.btint ernet.com...[color=blue]
                  > Mike,
                  >
                  > Can you explain a little further on NT Users and Groups property, I must[/color]
                  be[color=blue]
                  > missing something obvious here.[/color]

                  What I meant was that if you're using a shared NT logon then you have 2
                  choices:

                  1. Stop. And use NT logons for what they're meant for - i.e. robust
                  security, giving users/groups access to certain resources, denying them
                  access to other resources and so on. Why are your temps sharing a log on?
                  Because nobody has the NT knowledge to create new users? That isn't very
                  difficult knowledge to gain, and somebody in your organisation ought to have
                  it.

                  2. Carry on with your shared NT logon (which I think is a bad idea). And use
                  another method to track the 'real' user. And I can't see any point in
                  writing your own system when MS have done it for you - Access users and
                  groups:



                  I've just set up security for the first time. Wasn't that hard. A few blips
                  along the way.

                  Mike


                  Comment

                  • Tony Toews

                    #10
                    Re: Log user on opening

                    "diverdon99 " <diverdon99@yah oo.co.uk> wrote:
                    [color=blue]
                    >We have a policy that only staff members can have a logon and as is common
                    >we have a lot of temps that need to be logged on. Thats how duplicate NT
                    >(User) logons happen.[/color]

                    Like Mike states that policy of not granting logons to temps is stupid, shortsighted
                    as doesn't allow for any accountability as to what temp did what.

                    Tony
                    --
                    Tony Toews, Microsoft Access MVP
                    Please respond only in the newsgroups so that others can
                    read the entire thread of messages.
                    Microsoft Access Links, Hints, Tips & Accounting Systems at

                    Comment

                    Working...