Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Location
    Virginia
    Posts
    16

    Question Unanswered: Obtain Novell User Name in Access?

    I'm trying to pull the Novell user name into Access to use as the username for the database. I used CurrentUser() and it gave me Admin, but I am not logged in as Admin.

    Thanks.

  2. #2
    Join Date
    Nov 2001
    Posts
    336
    Here are code for two functions: fOSUserName(), fOSMachineName() :


    Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Private Declare Function apiGetComputerName Lib "kernel32" Alias _
    "GetComputerNameA" (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 = ""
    End If
    End Function

    Function fOSMachineName() As String
    'Returns the computername
    Dim lngLen As Long, lngX As Long
    Dim strCompName As String
    lngLen = 16
    strCompName = String$(lngLen, 0)
    lngX = apiGetComputerName(strCompName, lngLen)
    If lngX <> 0 Then
    fOSMachineName = Left$(strCompName, lngLen)
    Else
    fOSMachineName = ""
    End If
    End Function

    Igor

  3. #3
    Join Date
    Oct 2002
    Location
    Virginia
    Posts
    16
    Thank you so much! That worked great!

  4. #4
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67
    There is a simple one line code for this work as well.

    Environ$("UserName")
    Cheers

  5. #5
    Join Date
    Nov 2001
    Posts
    336
    Nice tip.
    I tried it on my PC, which has Microsoft Networking and it didn't work. Also existence of this variable may heavily rely on your login script.

    Igor

Posting Permissions

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