CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2001
    Posts
    12

    How can I get the User Name and Password of Users from LAN?

    I'd like to get the User Name and Password for Security purposes on my .mdb file. I need to validate if the User really exists.


  2. #2
    Join Date
    Sep 2000
    Location
    CA
    Posts
    25

    Re: How can I get the User Name and Password of Users from LAN?

    I do not know how (or if you can) get the user's password, but you can use the GetUserName API to retrieve the network login ID. Put the following in a code module:

    public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (byval lpBuffer as string, nSize as Long) as Long

    public Function MyGetUserName() as string
    Dim strUser as string
    Dim lngTemp as Long
    Dim lngResult as Long
    lngTemp = 255
    strUser = string(lngTemp, " ")
    lngResult = GetUserName(strUser, lngTemp)
    MyGetUserName = mid(strUser, 1, lngTemp - 1)
    End Function




    Then call the function like this:


    UserName = MyGetUserName




    Hope this helps,
    Jason



  3. #3
    Join Date
    May 2002
    Posts
    53

    how to have it in a loop?

    Hi jn8230!

    I found your code useful in getting the login name of PC in a LAN.
    I made a list box and place your codes in a module. Then on form load, I placed the following codes:

    Dim UserName As String

    UserName = MyGetUserName
    List1.AddItem UserName

    how do I make this code loop so that I could get all the names of the PCs in our LAN? We have almost 80 PCs here.
    I hope you can give some idea.

    Thank you!!!

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

Featured