ANAVEM
Languagefr
Windows security monitoring dashboard showing Event Viewer with RDP session audit logs in a professional SOC environment
Event ID 4779InformationMicrosoft-Windows-Security-AuditingWindows

Windows Event ID 4779 – Microsoft-Windows-Security-Auditing: User Session Disconnected

Event ID 4779 logs when a user session is disconnected from a Terminal Services or Remote Desktop session, providing audit trail for remote access monitoring.

Emanuel DE ALMEIDAEmanuel DE ALMEIDA
18 March 20269 min read 0
Event ID 4779Microsoft-Windows-Security-Auditing 5 methods 9 min
Event Reference

What This Event Means

Event ID 4779 represents a fundamental component of Windows security auditing, specifically designed to track Terminal Services session disconnections. When a user's RDP session terminates—whether through network issues, deliberate disconnection, or administrative action—Windows logs this event to maintain a comprehensive audit trail of remote access activities.

The event structure includes critical forensic data: the target user account (both name and SID), the source network address, session ID, and logon ID that correlates with the original logon event. This correlation capability allows administrators to construct complete timelines of user activity from initial connection through disconnection.

Windows generates 4779 events on multiple systems simultaneously. The target server hosting the RDP session logs the event locally, while domain controllers record the event as part of centralized security auditing. This distributed logging ensures redundancy and provides multiple investigation paths during security incidents.

The event's significance extends beyond simple connection tracking. Security teams rely on 4779 patterns to identify suspicious behavior, such as rapid connection cycling, unusual access times, or connections from unexpected network locations. Combined with other security events, 4779 data helps construct comprehensive user behavior baselines and detect anomalous activities that might indicate compromised accounts or insider threats.

Applies to

Windows 10Windows 11Windows Server 2019/2022/2025
Analysis

Possible Causes

  • User manually disconnecting from Remote Desktop session using the X button or Start menu disconnect option
  • Network connectivity issues causing RDP session timeout or connection loss
  • Administrator forcibly disconnecting user sessions through Terminal Services Manager or PowerShell commands
  • Group Policy settings enforcing session time limits or idle timeout disconnections
  • Server shutdown or restart procedures terminating active RDP sessions
  • RDP client application crashes or unexpected termination
  • Windows Update installations requiring session disconnection for system changes
  • Security software or endpoint protection solutions terminating suspicious RDP connections
Resolution Methods

Troubleshooting Steps

01

Analyze Event Details in Event Viewer

Start by examining the specific 4779 event details to understand the disconnection context and gather forensic information.

1. Open Event ViewerWindows LogsSecurity

2. Filter for Event ID 4779 using the filter option or search functionality

3. Double-click the event to view detailed information including:

  • Subject Security ID and Account Name
  • Logon ID (correlates with logon events)
  • Session Name and Source Network Address
  • Additional Details tab for extended information

4. Note the timestamp and compare with related events like 4778 (session reconnected) or 4634 (logoff)

Pro tip: The Logon ID field allows you to correlate this disconnection with the original logon event (4624) to build a complete session timeline.

02

Query Events with PowerShell for Pattern Analysis

Use PowerShell to extract and analyze 4779 events for patterns, frequency, and correlation with other security events.

1. Query recent disconnection events:

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4779} -MaxEvents 50 | Select-Object TimeCreated, Id, @{Name='User';Expression={$_.Properties[1].Value}}, @{Name='SourceIP';Expression={$_.Properties[5].Value}}

2. Analyze disconnection patterns for specific users:

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4779} | Where-Object {$_.Properties[1].Value -like '*username*'} | Group-Object @{Expression={$_.Properties[5].Value}} | Sort-Object Count -Descending

3. Correlate with logon events to calculate session duration:

$logons = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624}
$disconnects = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4779}
$correlatedSessions = $disconnects | ForEach-Object {
    $logonId = $_.Properties[2].Value
    $matchingLogon = $logons | Where-Object {$_.Properties[7].Value -eq $logonId}
    if ($matchingLogon) {
        [PSCustomObject]@{
            User = $_.Properties[1].Value
            LogonTime = $matchingLogon.TimeCreated
            DisconnectTime = $_.TimeCreated
            Duration = $_.TimeCreated - $matchingLogon.TimeCreated
            SourceIP = $_.Properties[5].Value
        }
    }
}

Warning: Large event logs can impact system performance. Use -MaxEvents parameter to limit results during initial analysis.

03

Configure Advanced Auditing and Monitoring

Enhance 4779 event collection and analysis through advanced audit policy configuration and centralized logging setup.

1. Verify audit policy settings using Group Policy or local security policy:

Navigate to Computer ConfigurationWindows SettingsSecurity SettingsAdvanced Audit Policy ConfigurationLogon/Logoff

2. Enable detailed logon auditing:

auditpol /set /subcategory:"Logoff" /success:enable /failure:enable
auditpol /set /subcategory:"Other Logon/Logoff Events" /success:enable /failure:enable

3. Configure Windows Event Forwarding for centralized collection:

# On collector server
wecutil qc
# Create subscription for security events
wecutil cs subscription.xml

4. Set up custom event log size and retention:

wevtutil sl Security /ms:1073741824
wevtutil sl Security /rt:false

5. Create scheduled task for automated 4779 analysis:

$action = New-ScheduledTaskAction -Execute 'PowerShell.exe' -Argument '-File C:\Scripts\Analyze4779Events.ps1'
$trigger = New-ScheduledTaskTrigger -Daily -At '06:00'
Register-ScheduledTask -TaskName 'Daily4779Analysis' -Action $action -Trigger $trigger
04

Investigate Suspicious Disconnection Patterns

Perform advanced forensic analysis to identify potential security threats or policy violations based on 4779 event patterns.

1. Identify unusual disconnection frequencies:

$timeframe = (Get-Date).AddDays(-7)
$events = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4779; StartTime=$timeframe}
$suspiciousUsers = $events | Group-Object @{Expression={$_.Properties[1].Value}} | Where-Object {$_.Count -gt 100} | Sort-Object Count -Descending

2. Analyze off-hours access patterns:

$offHoursEvents = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4779} | Where-Object {
    $hour = $_.TimeCreated.Hour
    $hour -lt 6 -or $hour -gt 22 -or $_.TimeCreated.DayOfWeek -in @('Saturday','Sunday')
}

3. Check for rapid reconnection patterns (potential brute force):

$rapidReconnects = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=@(4778,4779)} | Sort-Object TimeCreated | Group-Object @{Expression={$_.Properties[1].Value}} | ForEach-Object {
    $userEvents = $_.Group | Sort-Object TimeCreated
    for ($i = 1; $i -lt $userEvents.Count; $i++) {
        $timeDiff = ($userEvents[$i].TimeCreated - $userEvents[$i-1].TimeCreated).TotalMinutes
        if ($timeDiff -lt 2) {
            [PSCustomObject]@{
                User = $_.Name
                Event1 = $userEvents[$i-1].Id
                Event2 = $userEvents[$i].Id
                TimeDifference = $timeDiff
                Timestamp = $userEvents[$i].TimeCreated
            }
        }
    }
}

4. Cross-reference with failed logon attempts:

$failedLogons = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625}
$disconnections = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4779}
$correlatedThreats = $disconnections | ForEach-Object {
    $disconnectTime = $_.TimeCreated
    $sourceIP = $_.Properties[5].Value
    $relatedFailures = $failedLogons | Where-Object {
        $_.Properties[19].Value -eq $sourceIP -and
        [Math]::Abs(($_.TimeCreated - $disconnectTime).TotalMinutes) -lt 30
    }
    if ($relatedFailures) {
        [PSCustomObject]@{
            SourceIP = $sourceIP
            DisconnectTime = $disconnectTime
            FailedAttempts = $relatedFailures.Count
            User = $_.Properties[1].Value
        }
    }
}
05

Implement Automated Alerting and Response

Deploy automated monitoring and response mechanisms for critical 4779 event patterns that may indicate security incidents.

1. Create custom Windows Performance Toolkit (WPT) data collector set:

$dataCollectorSet = New-Object -ComObject Pla.DataCollectorSet
$dataCollectorSet.DisplayName = "RDP Disconnection Monitor"
$dataCollectorSet.RootPath = "C:\PerfLogs\RDPMonitor"
$dataCollectorSet.Commit("RDPDisconnectMonitor", $null, 0x0003)

2. Configure SIEM integration using Windows Event Forwarding:

Create custom XML subscription file:

<Subscription xmlns="http://schemas.microsoft.com/2006/03/windows/events/subscription">
    <SubscriptionId>RDP-Disconnection-Monitor</SubscriptionId>
    <Query>
        <Select Path="Security">*[System[(EventID=4779)]]</Select>
    </Query>
    <Delivery Mode="Push">
        <Batching>
            <MaxItems>1</MaxItems>
            <MaxLatencyTime>1000</MaxLatencyTime>
        </Batching>
    </Delivery>
</Subscription>

3. Set up PowerShell-based alerting script:

# Register event subscription
Register-WmiEvent -Query "SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_NTLogEvent' AND TargetInstance.EventCode = 4779" -Action {
    $event = $Event.SourceEventArgs.NewEvent.TargetInstance
    $user = ($event.InsertionStrings)[1]
    $sourceIP = ($event.InsertionStrings)[5]
    
    # Check for suspicious patterns
    if ($sourceIP -notmatch '^(10\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[01])\.)') {
        Send-MailMessage -To "security@company.com" -From "alerts@company.com" -Subject "External RDP Disconnection Alert" -Body "User $user disconnected from external IP $sourceIP at $(Get-Date)" -SmtpServer "mail.company.com"
    }
}

4. Implement custom Windows Event Log channel for enhanced monitoring:

# Create custom event log
New-EventLog -LogName "RDPSecurity" -Source "RDPMonitor"

# Log custom security events
Write-EventLog -LogName "RDPSecurity" -Source "RDPMonitor" -EventId 1001 -EntryType Information -Message "Suspicious RDP disconnection pattern detected for user $user from IP $sourceIP"

Pro tip: Combine 4779 monitoring with network traffic analysis and endpoint detection tools for comprehensive RDP security coverage.

Overview

Event ID 4779 fires whenever a user session disconnects from a Terminal Services or Remote Desktop Protocol (RDP) session on Windows systems. This security audit event is part of the logon/logoff audit category and provides critical visibility into remote access patterns across your infrastructure.

The event captures essential details including the user account, session ID, source network address, and disconnection reason. Windows generates this event on both the target server receiving the RDP connection and domain controllers processing the authentication. This makes 4779 invaluable for tracking remote access compliance, investigating security incidents, and monitoring user behavior patterns.

Unlike logoff events, disconnections preserve the session state on the server while terminating the network connection. The session remains active in memory, allowing users to reconnect and resume their work. This distinction is crucial for understanding the difference between intentional logoffs and network-related disconnections in your environment.

Frequently Asked Questions

What's the difference between Event ID 4779 (disconnection) and 4634 (logoff)?+
Event ID 4779 indicates a session disconnection where the user session remains active on the server but the network connection terminates. The user can reconnect to resume their session. Event ID 4634 represents a complete logoff where the session is terminated and all associated processes are closed. Disconnections preserve session state while logoffs destroy it completely.
Why am I seeing multiple 4779 events for the same user session?+
Multiple 4779 events for the same session typically occur due to network instability causing repeated disconnections and reconnections. Check the Session Name and Logon ID fields to correlate events. If the Logon ID changes between events, these represent different sessions. Consistent network issues, VPN problems, or client-side connectivity problems often cause this pattern.
How can I correlate 4779 events with the original logon to calculate session duration?+
Use the Logon ID field in the 4779 event to correlate with Event ID 4624 (successful logon) or 4778 (session reconnected). The Logon ID remains consistent throughout the session lifecycle. Query both event types and match on Logon ID to calculate duration: logoff/disconnect time minus logon/connect time. This correlation helps identify unusually long or short sessions.
Can Event ID 4779 help detect potential security threats or unauthorized access?+
Yes, 4779 events are valuable for threat detection. Analyze patterns like disconnections from external IP addresses, off-hours access, rapid disconnect/reconnect cycles, or disconnections followed by failed authentication attempts. Unusual source networks, geographic anomalies, or disconnection patterns that deviate from user baselines can indicate compromised accounts or unauthorized access attempts.
What should I do if 4779 events are not appearing in my Security log?+
Verify that audit policy for Logon/Logoff events is enabled. Check Group Policy settings under Advanced Audit Policy Configuration → Logon/Logoff → Logoff. Ensure both Success and Failure auditing are enabled. On domain controllers, verify that 'Audit account logon events' is configured. Also check that the Security log has sufficient size and retention settings to capture these events without overwriting them quickly.
Documentation

References (2)

Emanuel DE ALMEIDA
Written by

Emanuel DE ALMEIDA

Senior IT Journalist & Cloud Architect

Microsoft MCSA-certified Cloud Architect | Fortinet-focused. I modernize cloud, hybrid & on-prem infrastructure for reliability, security, performance and cost control - sharing field-tested ops & troubleshooting.

Discussion

Share your thoughts and insights

You must be logged in to comment.

Loading comments...