Link to home
Start Free TrialLog in
Avatar of tracyms
tracyms

asked on

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
Avatar of Malli Boppe
Malli Boppe
Flag of Australia image

I don't think you can do it through a batch script you need to write a VB script.
ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tracyms
tracyms

ASKER

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
Avatar of tracyms

ASKER

Thanks!