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.
Printable View
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.
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
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!!!