Results 1 to 22 of 22

Thread: Determine computer name where user is logon

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Determine computer name where user is logon

    OS: Windows 98
    Server OS: Linux 9 + Samba 3
    VB6

    I wrote a small program where a user can send message using mailslots (winpopup style) problem is if a person send a message using computer name, it is ok. But when a user send a message using the username the message is not sent.

    for instance, if user "USER1" logon to computer "PC01" and another user send a message using "USER1". The message will not be sent. But if the user will use "PC01" to send message, the message will be received by "USER1" on "PC01".

    I was able to determine if computer is online by using IsDestinationReachable() but I can't determine the computer name where a user logon.

    I need to determine the computer name where a user is logon because i think mailslot uses \\"computername"\mailslot\messngr.

    Please help, I've been searching for this on the net for days now. Thanks in advance.

  2. #2
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: Determine computer name where user is logon

    is this what you need?

    VB Code:
    1. Private Declare Function GetComName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    2.  
    3. Private Sub Command1_Click()
    4. Dim com_name As String
    5. Dim length As Long
    6.  
    7.     com_name = Space$(256)
    8.     length = Len(com_name)
    9.     GetComName com_name, length
    10.     com_name = Left$(com_name, length)
    11.  
    12.     MsgBox "[" & com_name & "]"
    13. End Sub
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    thank you for your reply but it's not what im looking for, GetComputerName() is used to get the computer name of the current system

    What Im looking for is how to get the computer name of a user where he is logged in.

    example is if a user would send message to "USER1" the system must determine first on what computer is "USER1" logged in so I can user the computer name on the mailslot \\"computername"\mailslot\messngr.

    what I want to achieve is to :
    Determine on what computer a user is logged in on a network environment.

    Thanks, I appreciate your help.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    Any suggestions please ? Is this Impossible on Win98 OS ?

  5. #5
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Determine computer name where user is logon

    Does this help:
    VB Code:
    1. MsgBox Environ("COMPUTERNAME")

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Determine computer name where user is logon

    Actually, its probably the same as GetComp API

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Determine computer name where user is logon

    Your after the Server end right?

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Determine computer name where user is logon

    I think he needs the computername of the machine that he is sending the message to. Just like Net Send, you specify the computername you are sending TO not the one you are at.

  9. #9
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Determine computer name where user is logon

    I reread the original. Try mosding this to get the User matched to CompName!
    VB Code:
    1. Private Sub Load_Users()
    2. Dim objDomain As Object
    3. Dim objUser As Object
    4.  
    5. On Error GoTo Err_Handler
    6.  
    7.     Set objDomain = GetObject("WinNT://" & Environ$("USERDNSDOMAIN"))
    8.     Set objUser = GetObject(objDomain.Schema)
    9.  
    10.     objDomain.Filter = Array("User")
    11.  
    12.     For Each objUser In objDomain
    13.         cboUsers.AddItem objUser.Name
    14.     Next
    15.  
    16.     Set objDomain = Nothing
    17.     Set objUser = Nothing
    18.  
    19. Exit Sub
    20.  
    21. Err_Handler:
    22.  
    23.     Screen.MousePointer = vbNormal
    24.  
    25.     If Not (objDomain Is Nothing) Then Set objDomain = Nothing
    26.     If Not (objUser Is Nothing) Then Set objUser = Nothing
    27.  
    28.     MsgBox "Description: " & Err.Description & vbCrLf & _
    29.         "Number: " & Err.Number, vbInformation + vbOKOnly, App.Title & " - Error"
    30.  
    31. End Sub

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    Thank you for your reply. I tried the code, and get this error

    File name or class name not found during Automation operation Number 432

    at this line

    Code:
    Set objDomain = GetObject("WinNT://" & Environ$("USERDNSDOMAIN"))

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    Quote Originally Posted by Bruce Fox
    Actually, its probably the same as GetComp API
    Getcomputername API is for the current system. What I need is the computer name of the user where I am sending the message. Some users use the username instead of the computer name when sending messages.

    mailslot uses //computername/mailslot/messngr to send message that's why I need to know the "computer name" of the recipient.

    Thanks for the help, I appreciate it.

    Any more suggestions please.

  12. #12
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Determine computer name where user is logon

    Not sure if this applies with mailslots... but if I'm not mistaken, winpop is based on dos command net. With net, you can get the names used by the local machine with net name, the pc name and the active profile name. net user lists all users including non active profiles.

    I'ts possible to net send msgs with net using the active user/profile name instead of the computer name since net does the mapping. UNfortunately I dont know the API for net.

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    Quote Originally Posted by leinad31
    Not sure if this applies with mailslots... but if I'm not mistaken, winpop is based on dos command net. With net, you can get the names used by the local machine with net name, the pc name and the active profile name. net user lists all users including non active profiles.

    I'ts possible to net send msgs with net using the active user/profile name instead of the computer name since net does the mapping. UNfortunately I dont know the API for net.
    Thank you for your help. I think Windows 98 Net command doesn't recognize NET SEND and NET NAME

  14. #14
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Determine computer name where user is logon

    Quote Originally Posted by kenchix1
    OS: Windows 98
    My appologies kenchix1,
    I should have read closer.... the example I provided will (as far as I know) only work
    for an NT based OS (Y2K/XP).
    Sorry

  15. #15
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: Determine computer name where user is logon

    does theapp needs the name for anything but display? if not then just let the user type in his name and the app will recognize the user and show his name
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    Quote Originally Posted by Bruce Fox
    My appologies kenchix1,
    I should have read closer.... the example I provided will (as far as I know) only work
    for an NT based OS (Y2K/XP).
    Sorry
    No problem. your help is appreciated.

    Quote Originally Posted by wiz126
    does theapp needs the name for anything but display? if not then just let the user type in his name and the app will recognize the user and show his name
    The application needs the name for the mailslot which is the \\computername\mailslot\messngr. If a user types in a username instead of computer name, the message will not be sent because the system will use the username on the computername portion of the string, which leads to nothing. That's why I need to locate the recipients computer so I can get his computername.
    Thanks for the help.

  17. #17
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Determine computer name where user is logon

    Broadcast it on the domain... and change the info of the datagram. Include a "header" in the message portion that contains the user name. So during a broadcast, each recipient does an adiitional check against the username in the header to see if it is really addressed to him since the sender couldnt identify the specific computer.

    In the case that the computer name is known, the "header" could be left blank or still has a user name... whichever is easier to code.

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    Quote Originally Posted by leinad31
    Broadcast it on the domain... and change the info of the datagram. Include a "header" in the message portion that contains the user name. So during a broadcast, each recipient does an adiitional check against the username in the header to see if it is really addressed to him since the sender couldnt identify the specific computer.

    In the case that the computer name is known, the "header" could be left blank or still has a user name... whichever is easier to code.
    wouldn't that cause too much traffic on the network ? aside from it, I don't know how to broadcast a message.

    thank you for the info.

    (Im still stuck on this problem)

  19. #19
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Determine computer name where user is logon

    there is one way i have been able to resolve this problem (it is not the best, trust me)

    my office has over 70 computers with oses ranging from win 98 to win xp sp2.

    what i did was create a server module which would record which user has logged into which computer. this is done by having a small client sending information to the server module on logon. this way, i was able to trace who was logged in where.

  20. #20
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Determine computer name where user is logon

    He wanted to do it like winpop... and he's concerned with traffic. A server would need to check every once in awhile if its list is correct or up to date.

  21. #21

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    20

    Re: Determine computer name where user is logon

    I've been searching for weeks now but still can't find a solution on how to solve this problem. the nearest possible solution that I saw was to broadcast a name query via UDP port 137 posted by somebody two years ago. but how ?

    i just hope those winpopup programmers that knows how to determine a computer name of a certain user on the network are not from other planets.

  22. #22
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Determine computer name where user is logon

    Have you tried this name?

    \\*\mailslot\name
    Retrieves a client handle to all mailslots with the specified name in the system's primary domain.

Posting Permissions

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



Click Here to Expand Forum to Full Width