Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show user's first and last name

Status
Not open for further replies.

brian32

Vendor
Mar 20, 2005
35
US
Hi.

I have a simple script that displays the current user's logon name, like jdoe for John Doe:

Set objNetwork = WScript.CreateObject("WScript.Network")
MsgBox objNetwork.UserName

How do I display the current user's first and last name instead of their logon name?

Running XP Pro in a Windows 2003 Active Directory domain. Thanks.
 
Have to make sure user is logging on to the domain and then like this.
[tt]
dim sdn
with createobject("NameTranslate")
.init 1,objNetwork.UserDomain
.set 3,objNetwork.UserDomain & "\" & objNetwork.UserName
sdn=.get(1)
end with

with getobject("LDAP://" & sdn)
msgbox .givenname & " " & .sn
end with
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top