Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read network user name? 1

Status
Not open for further replies.

seenoorao

Programmer
Sep 6, 2005
8
US
Hi,

Can I read the current network/system user name (and password) in MS Access/ VBA programe? If yes how?

Here i do not want to get the Access user name (which I know i can get using CurrentUser function)

What i want to achieve is, i want to get the name/user id of the person who is logged in to Windows XP machine and depending on the person who is logged into the machine i want to allow or block certain functionality in my .mdb programatically.

I think what i am asking is for windows authentication in my access mdb database. is this possible?


~seenoo rao
 
environ("username") = user name
environ("hostname") = computer name

I do not know how to get passwords since that would be a security breach.
 
thanks for the quick help, gmp. It's working for username but for hostname it returns "" (blank) string. anyidea why?
 
I had tried this environ("computername"). this gives me local machine name? is there any way i can find out to which domain the user is logged on to?
 
Environ("USERDOMAIN")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You can also try:
Code:
Public Function gfGetLogin() As String
    gfGetLogin = gfGetUserDomain & "\" & gfGetUserName
End Function

Public Function gfGetUserName() As String
    Dim WSHNetwork

    Set WSHNetwork = CreateObject("WScript.Network")
    gfGetUserName = WSHNetwork.username
    Set WSHNetwork = Nothing
End Function

Public Function gfGetUserDomain() As String
    Dim WSHNetwork

    Set WSHNetwork = CreateObject("WScript.Network")
    gfGetUserDomain = WSHNetwork.userdomain
    Set WSHNetwork = Nothing
End Function

Public Function gfGetComputerName() As String
    Dim WSHNetwork

    Set WSHNetwork = CreateObject("WScript.Network")
    gfGetComputerName = WSHNetwork.computername
    Set WSHNetwork = Nothing
End Function

"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top