Getting windows user name

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

    Getting windows user name

    (This was also posted to comp.database.m s-access before I realized this was
    the hep group.)

    Lets say that my WinXP computer has two users: Michael and Kathryn. One or
    the other logs into the computer and opens up an Access database (I happen
    to be using 2002). There is no security on the database -- just click on the
    shortcut and you're in.

    I want to be able to determine who opened that database by knowing who
    logged into the computer.

    Is there a way to get the windows user name?

    I have another question, and this one may be a bit off-topic, but I'll run
    it up the flagpole.

    I want to leave the above-named database open all the time, such that
    whenever anybody logs in at the windows login screen, the database will be
    up and running. In the actual application there may be as many as twenty
    people accessing the same application, and I don't want twenty instances of
    the program running -- one for each user. Can I have that database display
    on the screen of all users? (Specifically, I would like to use Windows Fast
    User Switching to change users.)

    In most situations, I could resolve these issues using Access' security
    features. This is a unique application, though, and the users won't be able
    to log into the database themselves.

    Thanks!

    Mike



  • Allen Browne

    #2
    Re: Getting windows user name

    Windows user name:


    The multi-user approach you suggest is not recommended. Instead, split the
    database, and give each user their own local copy of the front end. More
    info on this approach:


    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Mike Turco" <miketurco@yaho o-nospam4me.com> wrote in message
    news:aGWYc.1745 18$sh.173430@fe d1read06...[color=blue]
    > (This was also posted to comp.database.m s-access before I realized this
    > was
    > the hep group.)
    >
    > Lets say that my WinXP computer has two users: Michael and Kathryn. One or
    > the other logs into the computer and opens up an Access database (I happen
    > to be using 2002). There is no security on the database -- just click on
    > the
    > shortcut and you're in.
    >
    > I want to be able to determine who opened that database by knowing who
    > logged into the computer.
    >
    > Is there a way to get the windows user name?
    >
    > I have another question, and this one may be a bit off-topic, but I'll run
    > it up the flagpole.
    >
    > I want to leave the above-named database open all the time, such that
    > whenever anybody logs in at the windows login screen, the database will be
    > up and running. In the actual application there may be as many as twenty
    > people accessing the same application, and I don't want twenty instances
    > of
    > the program running -- one for each user. Can I have that database display
    > on the screen of all users? (Specifically, I would like to use Windows
    > Fast
    > User Switching to change users.)
    >
    > In most situations, I could resolve these issues using Access' security
    > features. This is a unique application, though, and the users won't be
    > able
    > to log into the database themselves.[/color]


    Comment

    • Mike Turco

      #3
      Re: Getting windows user name


      "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
      news:413491c9$0 $5220$5a62ac22@ per-qv1-newsreader-01.iinet.net.au ...[color=blue]
      > Windows user name:
      > http://www.mvps.org/access/api/api0008.htm
      >
      > The multi-user approach you suggest is not recommended. Instead, split the
      > database, and give each user their own local copy of the front end. More
      > info on this approach:
      > http://members.iinet.net.au/~allenbrowne/ser-01.html
      >[/color]

      Hi Allen,

      I'm not sure that splitting the database is the way to go. I have a single
      computer that will be used by several different people. I want to use Fast
      User Switching to log people in-and-out of the system. The system gets a lot
      of use and I don't want the lines to get any worse. I can't create a network
      to reduce wait time because the database controls a single, unique
      instrument. Having users log in-and-out of Access isn't an option because I
      have to close and re-open Access, which is time consuming. I want to use
      Windows fast user switching feature if I can.

      I am reading your post as suggesting that each user have their own front
      end. That would mean that as many as twenty users each have a copy of Access
      open. That sounds, to me, like a pretty big load on the computer.

      Thanks for your help.

      Mike


      Comment

      • Trevor Best

        #4
        Re: Getting windows user name

        Mike Turco wrote:
        [color=blue]
        > "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
        > news:413491c9$0 $5220$5a62ac22@ per-qv1-newsreader-01.iinet.net.au ...
        >[color=green]
        >>Windows user name:
        >> http://www.mvps.org/access/api/api0008.htm
        >>
        >>The multi-user approach you suggest is not recommended. Instead, split the
        >>database, and give each user their own local copy of the front end. More
        >>info on this approach:
        >> http://members.iinet.net.au/~allenbrowne/ser-01.html
        >>[/color]
        >
        >
        > Hi Allen,
        >
        > I'm not sure that splitting the database is the way to go. I have a single
        > computer that will be used by several different people. I want to use Fast
        > User Switching to log people in-and-out of the system. The system gets a lot
        > of use and I don't want the lines to get any worse. I can't create a network
        > to reduce wait time because the database controls a single, unique
        > instrument. Having users log in-and-out of Access isn't an option because I
        > have to close and re-open Access, which is time consuming. I want to use
        > Windows fast user switching feature if I can.
        >
        > I am reading your post as suggesting that each user have their own front
        > end. That would mean that as many as twenty users each have a copy of Access
        > open. That sounds, to me, like a pretty big load on the computer.
        >
        > Thanks for your help.
        >
        > Mike
        >
        >[/color]
        Prepare yourself, it doesn't work like that, each fast switched user
        will have their own copy of Access loaded into memory so even if you can
        get around any locking problems of them all opening the same database
        directly they will still be using nearly 100MB RAM just for the logon
        session and a copy of Access with no database loaded (I just tested this
        under XP, the second msaccess.exe is only using 2MB, couldn't open the
        same database BTW), loadin a database will increase this useage,
        regardless of if it's a shared or separate copy as it will be another
        instance.

        What I did in a similar situation, 4 guys in a warehouse, 1 computer (A
        P75 with Win 3.11, 95 was still coming of age) was to implement my own
        security, just user name and password when entering a form. I did this
        for the reason you specify, too long to load up Access for each user.

        --

        \\\\\\
        \\ \\ Windows is searching
        \ \ For your sig.
        \ \ Please Wait.
        \__\

        Comment

        • Mike Turco

          #5
          Re: Getting windows user name


          "Trevor Best" <nospam@localho st> wrote in message
          news:4135bee5$0 $12322$afc38c87 @auth.uk.news.e asynet.net...[color=blue]
          > Mike Turco wrote:
          >[color=green]
          > > "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
          > > news:413491c9$0 $5220$5a62ac22@ per-qv1-newsreader-01.iinet.net.au ...
          > >[color=darkred]
          > >>Windows user name:
          > >> http://www.mvps.org/access/api/api0008.htm
          > >>
          > >>The multi-user approach you suggest is not recommended. Instead, split[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > >>database, and give each user their own local copy of the front end. More
          > >>info on this approach:
          > >> http://members.iinet.net.au/~allenbrowne/ser-01.html
          > >>[/color]
          > >
          > >
          > > Hi Allen,
          > >
          > > I'm not sure that splitting the database is the way to go. I have a[/color][/color]
          single[color=blue][color=green]
          > > computer that will be used by several different people. I want to use[/color][/color]
          Fast[color=blue][color=green]
          > > User Switching to log people in-and-out of the system. The system gets a[/color][/color]
          lot[color=blue][color=green]
          > > of use and I don't want the lines to get any worse. I can't create a[/color][/color]
          network[color=blue][color=green]
          > > to reduce wait time because the database controls a single, unique
          > > instrument. Having users log in-and-out of Access isn't an option[/color][/color]
          because I[color=blue][color=green]
          > > have to close and re-open Access, which is time consuming. I want to use
          > > Windows fast user switching feature if I can.
          > >
          > > I am reading your post as suggesting that each user have their own front
          > > end. That would mean that as many as twenty users each have a copy of[/color][/color]
          Access[color=blue][color=green]
          > > open. That sounds, to me, like a pretty big load on the computer.
          > >
          > > Thanks for your help.
          > >
          > > Mike
          > >
          > >[/color]
          > Prepare yourself, it doesn't work like that, each fast switched user
          > will have their own copy of Access loaded into memory so even if you can
          > get around any locking problems of them all opening the same database
          > directly they will still be using nearly 100MB RAM just for the logon
          > session and a copy of Access with no database loaded (I just tested this
          > under XP, the second msaccess.exe is only using 2MB, couldn't open the
          > same database BTW), loadin a database will increase this useage,
          > regardless of if it's a shared or separate copy as it will be another
          > instance.
          >
          > What I did in a similar situation, 4 guys in a warehouse, 1 computer (A
          > P75 with Win 3.11, 95 was still coming of age) was to implement my own
          > security, just user name and password when entering a form. I did this
          > for the reason you specify, too long to load up Access for each user.[/color]

          What you're saying makes sense.

          Another issue here is that the database controls an instrument through USB,
          and that may add a whole new level of headache if I create a setup that is
          more complex than what it needs to be.

          Thanks,

          Mike


          Comment

          • Troy Liggins

            #6
            Re: Getting windows user name

            If you are still interested in how to get the current logged on user
            the following code will do so.

            'Declared Globally
            Private Declare Function GetUserNameAPI Lib "advapi32.d ll" _
            Alias "GetUserNam eA" (ByVal lpbuffer As String, _
            nSize As Long) As Long

            Public Function GetUserName() As String
            Dim sBuffer As String
            Dim lSize As Long

            ' Space for dll parameters
            sBuffer = Space$(255)
            lSize = Len(sBuffer)

            Call GetUserNameAPI( sBuffer, lSize)

            If lSize > 0 Then
            ' Remove empty spaces
            GetUserName = Left$(sBuffer, lSize - 1)
            Else
            ' Return empty if no user is found
            GetUserName = vbNullString
            End If

            End Function

            "Mike Turco" <miketurco@yaho o-nospam4me.com> wrote in message news:<aGWYc.174 518$sh.173430@f ed1read06>...[color=blue]
            > (This was also posted to comp.database.m s-access before I realized this was
            > the hep group.)
            >
            > Lets say that my WinXP computer has two users: Michael and Kathryn. One or
            > the other logs into the computer and opens up an Access database (I happen
            > to be using 2002). There is no security on the database -- just click on the
            > shortcut and you're in.
            >
            > I want to be able to determine who opened that database by knowing who
            > logged into the computer.
            >
            > Is there a way to get the windows user name?
            >
            > I have another question, and this one may be a bit off-topic, but I'll run
            > it up the flagpole.
            >
            > I want to leave the above-named database open all the time, such that
            > whenever anybody logs in at the windows login screen, the database will be
            > up and running. In the actual application there may be as many as twenty
            > people accessing the same application, and I don't want twenty instances of
            > the program running -- one for each user. Can I have that database display
            > on the screen of all users? (Specifically, I would like to use Windows Fast
            > User Switching to change users.)
            >
            > In most situations, I could resolve these issues using Access' security
            > features. This is a unique application, though, and the users won't be able
            > to log into the database themselves.
            >
            > Thanks!
            >
            > Mike[/color]

            Comment

            Working...