Click to See Complete Forum and Search --> : How can I get the User Name and Password of Users from LAN?


MilesNepo
July 5th, 2001, 03:37 AM
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.

jn8230
July 9th, 2001, 07:51 PM
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

jonelo
August 4th, 2003, 12:35 AM
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!!!