Windows Identity

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone tell me how I can get the name of the current user logged into
windows and put it in a text box in my data access page?
 
Thank you for the reply.
Im pretty new at this whole coding thing. can you tell where i need to put
this code? do I put it as an onclick event in the scripting or as a module??
 
So after I finished posting the last message I went back and actually read
the top of the page and saw what to do.
I made a new module and called it Username and pasted the following code:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function

Then I went to my data access page and put in the following code in the HEAD
section in Script editor

<SCRIPT language=vbscript event=onafterupdate for=CustomerName>
<!--

TellerID.value=fOSUserName()
-->
</SCRIPT>

TellerID is my message box I want the Windows User name in.
I am on a Novell network and everybodys windows username is the same as
thier novell username. So I just want to get the Windows name.
 
Back
Top