Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: NT User name


Message #1 by "peter pennells" <ppenn@b...> on Thu, 17 Jan 2002 09:16:01
I want to save the NT user name into an Access database as the creator of 

a record - can any assist me and tell where the user detail file is kept

Many thanks

Peter
Message #2 by brian.skelton@b... on Thu, 17 Jan 2002 10:04:28
Peter



Here's an API call you can use to get the users Network name:



Private Declare Function apiGetUserName Lib "advapi32.dll"_ 

Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long



This is how to use it:



Function OSUserName() 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

        OSUserName = Left$(strUserName, lngLen - 1)

    Else

        OSUserName = ""

    End If

End Function





> I want to save the NT user name into an Access database as the creator 

of 

> a record - can any assist me and tell where the user detail file is kept

> Many thanks

> Peter

  Return to Index