Results 1 to 17 of 17

Thread: Retrieve Username of User on Remote Computer

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Retrieve Username of User on Remote Computer

    Hey guys, looking for a way to get the username of a user on a remote computer on a network of WinXP machines, anyone know how?

    Basically my plan is scan my class room to get everyones usernames, and then when I get net send spammed I'll know who it came from.

    I've had a try of a few examples on here, but I'm not 100% sure if they're what I'm after.
    http://vbnet.mvps.org/index.html?code/network/


    Thanks inadvance.

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

    Re: Retrieve Username of User on Remote Computer

    Hey there PC

    This may be a place to start. I use it to load a ComboBox in my NetSend app:
    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.     If Not (objDomain Is Nothing) Then Set objDomain = Nothing
    24.     If Not (objUser Is Nothing) Then Set objUser = Nothing
    25.  
    26.     MsgBox "Description: " & Err.Description & vbCrLf & _
    27.         "Number: " & Err.Number, vbInformation + vbOKOnly, App.Title & " - Error"
    28.  
    29. End Sub




    Bruce.

  3. #3

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Retrieve Username of User on Remote Computer

    Its Robert the Bruce! I haven't seen you in a while!

    Yeah, that'll come in handy.

    It seems that I might need to be an adminstrator to get the username of a remote computer. Most of the examples seem to work for my computer, but if I change it to another computer, I get an error.

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Retrieve Username of User on Remote Computer

    This might help steer you in the right direction...not sure where to go with it but

    if you go to search:
    pick computers
    the enter the computer name in the network..it will return the user name

    not sure how you could do this in VB
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Retrieve Username of User on Remote Computer

    Obtaining Workstation User Logon Information
    That example seems to work, but it returns all users that have logged on for a while it seems, but it seems to list the current user last.

    Edit: I guess theres a problem though that it won't be able to tell you if someone is logged onto the computer or not.
    Last edited by Pc_Madness; Mar 15th, 2005 at 08:43 PM.

  6. #6
    Member
    Join Date
    Dec 2004
    Posts
    39

    Re: Retrieve Username of User on Remote Computer

    Dear Brute Fox,
    Why i can't run your code? I get the error : Run-time Error(-2147463168) Automation Error when i tried to compile it. Do i need to add any references?

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Retrieve Username of User on Remote Computer

    dglienna, did you not see the following in the code you posted?

    VB Code:
    1. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    2. ' Copyright ©1996-2005 VBnet, Randy Birch, All Rights Reserved.
    3. ' Some pages may also contain other copyrights by the author.
    4. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    5. ' Distribution: You can freely use this code in your own
    6. '               applications, but [HL="#FFFF80"]you may not reproduce
    7. '               or publish this code on any web site[/HL],
    8. '               online service, or distribute as source
    9. '               on any media without express permission.
    10. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

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

    Re: Retrieve Username of User on Remote Computer

    Oops. I have it on my system, but I didn't read the exclusions. This has become a sore point. i tried to link to it the other day, but it was just the same link that PC Madness had in the first post, and the thread was removed. I asked if I should have posted the code, and was told "After I tested it to see if it worked."
    It says that I can use it in my own application, so by creating a form and a few controls makes it my own.

    Does that mean that I can post it?

    - P C - It's the 5th one on the page.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Retrieve Username of User on Remote Computer

    Quote Originally Posted by Randy Birch
    ... or distribute as source
    ' on any media without express permission.
    No you cant without permission.

    Best thing to do is to link to the page I suppose?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: Retrieve Username of User on Remote Computer

    I tried that yesterday, and was blasted because it was the same link that PC posted when he started the thread. I clicked the link that was five links down on the posted page, and the link was the same! Now I posted it and was blasted again.

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

    Re: Retrieve Username of User on Remote Computer

    Quote Originally Posted by laisengchew
    Dear Brute Fox,
    Why i can't run your code? I get the error : Run-time Error(-2147463168) Automation Error when i tried to compile it. Do i need to add any references?


    Nope. What OS are u using?





    Bruce.

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Retrieve Username of User on Remote Computer

    Well I am late getting into this one but if its a duplicate link then there is no point posting it.

    If you find something else thats worthy then post it if its legal.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: Retrieve Username of User on Remote Computer

    He obviously linked to the page that had all of the links, but no particular program, and I tried to link to a link that was linked to. The page that I tried to link to HAD the code that I then tried to post on it.


    IT IS THE FIFTH LINK ON THE PAGE.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Retrieve Username of User on Remote Computer

    Chill, David. You dont have to yell! I know its the fifth link on the page. I was referring to you posting a different link that
    points to a different article or code sniplette. There is no point in posting a direct link to the same on in the original
    first post.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: Retrieve Username of User on Remote Computer

    My point is that I didn't realize it pointed to the first page and not the second.
    There is no way to link to the correct page. That's why I yelled. Not to you, but to PC Madness, so he can find it.

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Retrieve Username of User on Remote Computer

    Regardless, its not that hard to say PC_Madness, look at the 5th link on that page? You did it on an earlier post.
    I dont appreciate yelling, no matter who its directed at.

    This is what you should have done - Enumerating the User List and Obtaining User Info
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: Retrieve Username of User on Remote Computer

    That's what I thought that I was doing. I keep forgetting the I have a copy link in Fx. That is the solution. Sorry about losing my cool. It's just been hard helping this time.

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