Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Active Directory and UserName

Hi,

I was wondering, is there way to retrieve the Display Name as shown under
Active Directory, from VBA if the only available info is the logon Username?

I'm running Windows2000 & above, Office 2000, Server2003 Std.

Thanks
Augustus
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Active Directory and UserName

Here is the NT username. Not sure if this is what you want, but I think so...

Option Explicit


Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


Public Function ReturnNTUserName() As String

' Returns the NT Domain User Name

Dim rString As String * 255, sLen As Long, tString As String
Dim NWUserName As String

tString = ""

On Error Resume Next
sLen = GetUserName(rString, 255)
sLen = InStr(1, rString, Chr(0))
If sLen 0 Then
tString = Left(rString, sLen - 1)
Else
tString = rString
End If
On Error GoTo 0

NWUserName = Left(Right(tString, Len(tString) - 1), Len(tString) - 2)
ReturnNTUserName = UCase(Left(tString, 1)) + NWUserName +
Right(UCase(tString), 1)

End Function



"augustus" wrote:

Hi,

I was wondering, is there way to retrieve the Display Name as shown under
Active Directory, from VBA if the only available info is the logon Username?

I'm running Windows2000 & above, Office 2000, Server2003 Std.

Thanks
Augustus

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel active directory James Setting up and Configuration of Excel 0 April 6th 05 09:00 PM
Active directory users Dr Alric Excel Programming 5 October 27th 04 03:13 PM
active directory? Tim[_39_] Excel Programming 0 August 15th 04 08:34 AM
Active Directory Ulf Nilsson Excel Programming 2 April 27th 04 07:08 AM


All times are GMT +1. The time now is 07:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"