Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    User Logged in? (All)

    I need a test to see if the person identified by their LAN (Windows Domain) username is trying to start Word on a PC after already logging in and starting Word on another PC.

    Anybody?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: User Logged in? (All)

    Are your Normal or global templates stored on the network server in a user-specific folder? If so, could you sniff the lock file for their name and try to match it up with their username?

  3. #3
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: User Logged in? (All)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> Kevin

    OK let me try to understand what your situation is:

    1) User log in to a network.
    2) User starts MS-Word
    3) User moves to another PC and logs in the network
    4) User starts MS-Word again on the PC in step 3.

    I guess you can detect their logins from multiple PCs via network security or configurations. I don't know what network you are using, but the Admin should be able to help.

    Now as to what they do on the other PC, well you also have some sort of task tracking so if you can match up their logins with their tasks, then you can see if they are using multiple sessions of MS-Word.

    So now if you tell us what you are trying to accomplish, then maybe we can answer you better if there is a better way.

    Wassim <img src=/S/compute.gif border=0 alt=compute width=40 height=20>
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    Right after I posted this thought came to mind. (Great minds think alike!) The one piece of info I would like is the computername where the user is first logged in. I won't get that by this technique. It would be nice to dispaly a message like this:

    "Your username: 'LSMITM' is already logged in and running Word on the computer named: HQ121."

    This is not a common situation, but I wasted about a half hour yestereay troubleshooting a Normal.dot sharing violation error when a user logged exited Word. Turns out she was logged in on another PC and running Word there too.

    Now, some purist Wordite will chime in that I should just leave the Normal.dot on the C: (WHERE IT BELONGS!) and let users log in as many times as they want; but that is not an option with roaming users and Word 97 (I'm assuming Word 2000 and 2002 "cache" normal.dot down the Documents and Settings folder so that the roaming profile feature can move it up to the server for the next login -- regardless of the PC used to log in). Are you still with me here?

    But I don't trust our implementation of NT roaming profiles. Our LAN people only turn it on for certain users. So, in light of Office 97's many "roaming user" shortcomings -- I should post the list of my discoveries -- Normal.dot needs to be on the LAN. I know I could use a login script to pull normal down, but I have little control over the LAN stuff and don't trust the powers that be to maintain MY login script code.

    Don't get me started....
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    You understand the situation. I'm sure there's an API somewhere that will get me the info.

    See my post to Jefferson for more detail on the issue. But suffice it to say, I want users to use Word 97 on only one PC at a time. The problem I'm trying to prevent is probably not a problem with later versions of Word.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: User Logged in? (All)

    I wouldn't jump to the conclusion that this problem is solved in later versions of Word. Unfortunately I can't test your scenario at the moment, but the fundamental problem is that the Normal template is being shared, and Word documents don't share worth a hoot. A search of the MS knowledge base does give any assurances either. The party line seems to be that the path for the Workgroup is stored in the user profile on the workstation (if you are running WinNT/2000 workstations). I think the suggestion of copying it down to the local workstation may make sense - but you have to be concerned about two users trying to use the same workstation without shutting down Word as well. Not a pretty sight in general. Have you considered making a Read-Only template, and not letting them save changes to their normal.dot file in general?
    Wendell

  7. #7
    JustCallMeAl
    Guest

    Re: User Logged in? (All)

    Here is how you can get the user name, which I use:

    <pre>Declare Function WNetGetUser Lib "mpr.dll" _
    Alias "WNetGetUserA" (ByVal lpName As String, _
    ByVal lpUserName As String, lpnLength As Long) As Long

    Public Const NoError = 0 'The Function call was successful

    Function gGetUserName() As String
    '************************************************* ******************************
    ' Name: gGetUserName
    '
    ' Passed Variables (explanatory terms):
    ' None.
    '
    ' Purpose: Get the network username of the person logged on the
    ' computer
    '
    ' Actions: Run the API, WNetGetUser
    ' Test for an error
    ' Return the username
    '
    ' Function Return: The username
    '
    ' Called Procedures:
    ' None.
    '
    ' Called From: gLoggingErrors
    '************************************************* ******************************

    '-------------------------------------------
    'Define a local constant, Buffer size for the return string.
    '-------------------------------------------
    Const lpnLength As Long = 255

    '-------------------------------------------
    'Variable Declaration
    '-------------------------------------------
    Dim status As Integer
    Dim lpName As String
    Dim lpUserName As String

    '-------------------------------------------
    'Assign the buffer size constant to lpUserName.
    '-------------------------------------------
    lpUserName = Space$(lpnLength + 1)

    '-------------------------------------------
    'Get the log-on name of the person using product.
    '-------------------------------------------
    status = WNetGetUser(lpName, lpUserName, lpnLength)

    '-------------------------------------------
    'See whether error occurred.
    '-------------------------------------------
    If status = NoError Then
    'This line removes the null character. Strings in C are null-
    'terminated. Strings in Visual Basic are not null-terminated.
    'The null character must be removed from the C strings to be used
    'cleanly in Visual Basic.
    lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
    End If

    '-------------------------------------------
    'Return the username
    '-------------------------------------------
    gGetUserName = lpUserName

    End Function</pre>


    Here is to get the computer name, which I don't use (code is from API guide:

    <pre>Declare Function GetComputerName
    Lib "kernel32" Alias "GetComputerNameA"
    (ByVal lpBuffer As String, nSize As Long) As Long

    Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim strString As String
    'Create a buffer
    strString = String(255, Chr$(0))
    'Get the computer name
    GetComputerName strString, 255
    'remove the unnecessary chr$(0)'s
    strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
    'Show the computer name
    MsgBox strString
    End Sub</pre>


    Hope that helps.

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    I appreciate your time on this, but you misunderstood. I want the username and computer name from PC 1 available in a message box on PC 2. The user is logged in on both PCs. PC 2 needs to display the message.

    But you have given me an idea that just popped into my head. There's really nothing wrong with a user logging in twice or three times or whatever -- except when they run Word: two instances of Word cannot read AND write to the same Normal.dot. So, when User Instance 1 starts Word, the code could write the username and computername to a file in, say, the UserTemplates folder (which is pointed to their LAN home folder). If the same user tries to start Word on another PC, check for that file. If it exists, read the username and computername and display message. Bingo!

    Somebody tell Jefferson we have the answer. BTW, here's the easiest way to get the username and computername (as long as the client is NT or W2k or XP):

    strComputername = Environ("Computername")
    strUsername = Environ("Username")

    Not that the API is bad, but if you're not supporting 9x clients, this is prettier.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    User's gotta have full rights to their normal. Don't want to change that. Formatted autotext and autocorrect, little macros and such -- user's should always have those features at the beckon call.

    Look at my response to BigAl. Huston, we have a solution!

    Wendell, thanks for your thoughts. You help me think.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  10. #10
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: User Logged in? (All)

    Kevin,

    How, and when, do you plan to delete this file?

    I can see you getting into a situation where the user can't start Word from anywhere except the PC they were working on when it last crashed!

    StuartR

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    Good point; let's think this through:

    The idea is to allow a user logged in more than once to start only one Word session on that first logged in PC. If user logs in twice, second PC will not be able to run Word -- my code will not only put up a message, but will end with application.quit. Or I could give a warning and a prediction of a forthcoming sharing violation error and let them continue. The second instance would not create the "file".

    So, PC 2,3,4 etc. will never create the "file".

    Scenario 1: PC 1 crashes. User restarts PC and starts Word.
    Word discovers the "File". Word checks the username and computername. Continue test. If username & computername in file match current username and computername, everything is Okey doeky.

    Scenario 2: PC 1 crashed. User goes to PC 2 and logs in. Starts Word, Word finds "file". Username matches, computername does not. Now what?

    Attempt to delete the file. If file deletes, recreate it...

    OOHHHH. Never mind. Forget the "file" business. How about this:

    Whenever a user starts Word, code checks permissions on Normal.dot. If a write to normal.dot suceeds, PC 1/Username is ok. If PC2/Username starts Word, the permissions check will result in "access denied." Display message and/or bail out. How's that?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  12. #12
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: User Logged in? (All)

    Can you somehow get a macro create a file and leave it open? If so then you could try to delete this file from the next session - if it is still open then the original word instance presumably hasn't disappeared yet.

    StuartR

  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    Why not just use the normal.dot as that file? If a second session can't "open for write" we quit the session.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  14. #14
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: User Logged in? (All)

    Opening Normal.dot for write just makes me nervous. Wasn't the original problem you were trying to solve how Word behaves when 2 sessions both try to update normal.dot?

    StuartR

  15. #15
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Logged in? (All)

    Well, don't be nervous. The LAN OS handles the file sharing and reports to Windows. I'll test it. There might even be a FSO method that would calm your nerves. <img src=/S/hairy.gif border=0 alt=hairy width=15 height=15>
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Page 1 of 2 12 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
  •