Results 1 to 3 of 3

Thread: NT Passwords

  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    Wirral, Merseyside, Merseyside, England
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    NT Passwords

    I am setting up a database where I want to create an audit trail of amendments made to records. I would like to capture the NT logon ID of the user, rather than the Access database logon id (Windows NT, SP6a Access 97). This is so that the process is invisible to the user.

    Has anyone any code I could use?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: NT Passwords

    There is code in the Access 97 Developer's Handbook for this, and the same in the Access 2000 Developer's Handbook. Here's my modification of that code.

    Here's the WinAPI declaration:
    <pre>Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" ( _
    ByVal lpBuffer As String, nSize As Long) As Long</pre>


    ...And here's the function:
    <pre>Function FindUserName() As String
    ' This procedure uses the Win32API function GetUserName
    ' to return the name of the user currently logged on to
    ' this machine. The Declare statement for the API function
    ' is located in the Declarations section of this module.
    'Modified by Charlotte Foust 9/18/2000
    ' the result is one character longer
    ' than the name string itself if it contains a
    ' non-printing character.
    Dim strBuffer As String
    Dim lngSize As Long

    strBuffer = String(100, " ")
    lngSize = Len(strBuffer)

    If GetUserName(strBuffer, lngSize) = 1 Then
    FindUserName = Left(strBuffer, lngSize)
    If Asc(Right(FindUserName, 1)) <= 31 Then
    FindUserName = Left(FindUserName, lngSize - 1)
    End If
    Else
    FindUserName = "Name not available"
    End If
    End Function</pre>

    Charlotte

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    Wirral, Merseyside, Merseyside, England
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: NT Passwords

    Thanks its just what I needed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •