+ Reply to Thread
Results 1 to 2 of 2

Get User Name - Active Directory

Hybrid View

  1. #1
    Registered User
    Join Date
    06-02-2007
    Posts
    7

    Get User Name - Active Directory

    Hi,
    I am working on project, where I need to send automated mails from users desk.
    While sending I need to add the line Regards, <Logged in Name>.
    But i am able to get the logged user, but the problem is the log id in out office is the empno, And the variale Environ("USERNAME") is giving me the emp id.But I want the name which is stored in the active directory.
    E.g: 012012, in the Active Directry the name is stored partik leonard.
    How do i get the Name.
    Thanks,
    Jai

  2. #2
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808
    That made no sense what so ever but i use this to get the username of the perosn logged on to a computer:

    'place this at the very top of any module
    Private Declare Function GetUserName Lib "advapi32.dll" _
        Alias "GetUserNameA" (ByVal lpbuffer As String, _
                              nsize As Long) As Long
    
    'i place this in a userform_initialise but put it where you like
    Dim lpbuff As String * 25
    Dim ret As Long
    Dim StrName As String
    Dim StrSheet As String
    StrSheet = FrmNew.CBAccType.Value
    ret = GetUserName(lpbuff, 25)
    StrName = Left(lpbuff, InStr(lpbuff, Chr(0)) - 1)
    FrmNew.TxtKID.Value = StrName ' this line just populatd the userform but you could put it in a cell if you wanted
    I hope that helps if not sorry buddy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1