Canonical name (CN) instead of Username

How can I change this logon script to show the canonical name (i.e. John Smith) instead of %USERNAME% -  using windows 2003 standard, thanks.

@echo %DATE% - Logon From: %COMPUTERNAME%,

 User Name: -----> %USERNAME%, LogonTime: %TIME%  >>

\\SERVER\Monitoring$\%username%.log
LVL 1
tracymsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Farhan KaziConnect With a Mentor Systems EngineerCommented:
Try if this works for you!

NET USER "%USERNAME%" /DOMAIN |FIND /I "Full Name"  >>\\SERVER\Monitoring$\%username%.log

Open in new window

0
 
Malli BoppeCommented:
I don't think you can do it through a batch script you need to write a VB script.
0
 
tracymsAuthor Commented:
Thanks farhankazi,

You were close and pointed me in the right direction, I got it working with the following:

for /f "Tokens=2*" %%m in ('net user %USERNAME% /domain ^| find "Full Name"' ) do set fname=%%n
@echo %DATE% - Logoff From: %COMPUTERNAME%, User Name: %fname%, Logoff Time: %TIME%  >> \\SERVER\Monitoring$\%username%.log
In order for this script to display the first and last name of the domain user, you need to add their first and last name to "Display Name" in the user's properties in Active Directory - under the General tab.

Resource:
http://jsifaq.com/SF/Tips/Tip.aspx?id=5458
0
 
tracymsAuthor Commented:
Thanks!
0
All Courses

From novice to tech pro — start learning today.