大网数据广告活动
账户与安全

How to track users logon/logoff

· 52CE 我爱测

Describes how to track users logon/logoff.

This article describes how to track users logon/logoff.

Applies to:   Windows Server 2003
Original KB number:   556015

This article was written by Yuval Sinay, Microsoft MVP.

Summary

The following article will help you to track users logon/logoff.

Tips

Option 1

  1. Enable Auditing on the domain level by using Group Policy:

    Computer Configuration/Windows Settings/Security Settings/Local Policies/Audit Policy

    There are two types of auditing that address logging on, they are Audit Logon Events and Audit Account Logon Events.

    Audit "logon events" records logons on the PC(s) targeted by the policy and the results appear in the Security Log on that PC(s).

    Audit "Account Logon" Events tracks logons to the domain, and the results appear in the Security Log on domain controllers only.

  2. Create a logon script on the required domain/OU/user account with the following content:

    echo %date%,%time%,%computername%,%username%,%sessionname%,%logonserver% >>

  3. Create a logoff script on the required domain/OU/user account with the following content:

    echo %date%,%time%,%computername%,%username%,%sessionname%,%logonserver% >>

Note: Please be aware that unauthorized users can change this scripts, due the requirement that the SHARENAME$ will be writeable by users.

Option 2

Use WMI/ADSI to query each domain controller for logon/logoff events.

Community Solutions Content Disclaimer

Microsoft corporation and/or its respective suppliers make no representations about the suitability, reliability, or accuracy of the information and related graphics contained herein. All such information and related graphics are provided "as is" without warranty of any kind. Microsoft and/or its respective suppliers hereby disclaim all warranties and conditions with regard to this information and related graphics, including all implied warranties and conditions of merchantability, fitness for a particular purpose, workmanlike effort, title and non-infringement. You specifically agree that in no event shall Microsoft and/or its suppliers be liable for any direct, indirect, punitive, incidental, special, consequential damages or any damages whatsoever including, without limitation, damages for loss of use, data or profits, arising out of or in any way connected with the use of or inability to use the information and related graphics contained herein, whether based on contract, tort, negligence, strict liability or otherwise, even if Microsoft or any of its suppliers has been advised of the possibility of damages.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
- Supported versions of Windows Client · Source date 02/12/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。