return login name (ND DESCRIPTION) ?

Local time
Today, 12:10
Joined
Aug 3, 2005
Messages
66
sorry about typo in TITLE (must read : return login name (AND DESCRIPTION)

Hello,

In my company we use the Employee's Employee-Number as a Windows login name. This is registered in the Domain along with the Employee's Real Name.

So at the Windows(XP) login screen the user enters his/her Employee-Number (eg, 123ABC) and a password.

In the user's Start Menu, it then display the Real Name (eg. John Doe)

I use the following code in a Module to get the Windows Login Name.
No problem with that.

How do I change(add to) this code to ALSO get the user's Real Name from Windows ? Is this possible ?

Thank you kindly.

Jamie.

Here's the code:
Code:
Option Compare Database

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of Dev Ashish at The Access Web


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 = ""
    End If
End Function
 
Last edited:
Hi;

Test and adapt

Code:
Function MostraCompletoPCUser()
 Dim domain
  domain = Environ$("COMPUTERNAME")
  EnumUser domain
End Function
 
Sub EnumUser(strDomain)
  Dim Computer, User
  Set Computer = GetObject("WinNT://" & strDomain)
  Computer.Filter = Array("User")
  For Each User In Computer
    With User
      Debug.Print ("Name    :" & .Name)
      Debug.Print ("Fullname  :" & .FullName)
      Debug.Print ("Description :" & .Description)
    End With
  Next
  Set User = Nothing
  Set Computer = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom