Auditing and Monitoring AD Connector Login Events
This article will show you how to audit AD Connector login events to your Amazon WorkSpaces Personal environment. This can assist with security and with root cause analysis of issues.
Series: AD Connector and WorkSpaces (4 articles)
- …
- 4Auditing and Monitoring AD Connector Login Events This article
Overview
Customers use AD Connector from AWS Directory Service as part of a complete setup to enable Amazon WorkSpaces Personal . AD Connector proxies authentication traffic to your domain controllers, enabling you to use your on-premises domain without the need to set up another AD forest and make a two way trust.
AD Connector works by selecting a domain controller with the lowest latency it can find from the available Sites and Services every 15 minutes. If that domain controller goes offline, has replication issues, or is otherwise impaired, AD Connector will be nonfunctional until the next election cycle. This will block users from logging into Amazon WorkSpaces Personal. There is not any logging showing which domain controller AD Connector is using at a given point in time. This can make tracking down the root cause of such issues challenging. There is also no built-in logging for invalid password attempts for a user.
Customers have asked us for a way to audit failed WorkSpaces login attempts. Customers have also asked us for additional ways to diagnose issues with AD Connector, such as identifying which domain controller was processing login events at a point in time when an issue occurred. This can help with root cause analysis for outages.
This post shows how you can use a combination of Windows Event Forwarding, Windows Event Collection, and Group Policy, to audit and diagnose AD Connector.
If you create a dedicated EC2 Windows instance for this purpose running on a t3.medium instance type, the cost estimate is approximately $43.80 monthly, based on
us-east-1 pricing. This solution does not require a dedicated instance, but this article will use one for demonstration purposes.Walkthrough
In this blog, you will use built-in Windows tools to collect advanced security audit logs from your domain controllers on one central logging computer. You can then review all logs in one central location.
The overview of the process will look like this:
- You will create a new EC2 Windows instance on a
t3.mediuminstance. This instance will be joined to the same Active Directory domain as your WorkSpaces.
- Next, you will create a Group Policy for your domain controllers which will enable additional audit logging for login events.
- You will create a Windows Event Log Collection Subscription on that new instance, in order to receive those advanced login events.
- You will then use Group Policy to configure your domain controllers to forward the advanced login events to the collector server.
- Lastly, you will intentionally generate an invalid login attempt to one of your WorkSpaces, so that you can see an example event log entry.
Prerequisites
For this walkthrough, you should have the following prerequisites:
- A pre-existing AD Connector setup with WorkSpaces Personal.
- Your domain needs WinRM enabled and preconfigured. The Event Log Forwarding depends on this already being in place.
- See Enabling Windows Remote Management with Amazon WorkSpaces and Amazon AppStream 2.0 if you have not yet configured WinRM.
- Permissions to create a new EC2 instance, joined to your Active Directory domain.
- Familiarity with Group Policy and Active Directory
- Permissions to create Group Policy in your domain which will apply to domain controllers.
Optional Prerequisite: Create an IAM role for SSM Fleet Manager
This section is optional. If you are going to connect to the EC2 instance with RDP, you can skip this. This step is only required if you are going to connect with AWS Systems Manager Fleet Manager. If you already have a role that grants these permissions, you can use that, and skip this step. These steps create a role and policy with minimal permissions .
- From the IAM console , choose Roles, then choose Create role.
- On the Select trusted entity page, select AWS service. Select EC2 in the Service or use case dropdown menu. Under choose a use case for the specified service, select EC2. Then choose Next.
- On the Add permissions page, select Next without choosing any policies. You will create the IAM policy in a later step.
- On the Name, review, and create page, enter a name and description for the role. The name can be something like “SSMConnectionRole”. Optionally, add tags to the role. Select Create role.
- In the list of IAM roles, find the role you just created and select it.
- Select the Add permissions dropdown menu and choose Create inline policy.
- In the resulting Specify Permissions page, select the JSON tab. Delete the pre-existing contents of the JSON policy editor and replace them with the JSON below, and then choose Next.
- Enter a policy name, such as SSMConnectionInline, and select Create policy.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ssm:UpdateInstanceInformation", "ssmmessages:CreateControlChannel", "ssmmessages:CreateDataChannel", "ssmmessages:OpenControlChannel", "ssmmessages:OpenDataChannel" ], "Resource": "*" } ]}You now have an IAM role that you can attach to your EC2 Windows Event Collector instance. The role will permit you to connect to the instance with SSM Fleet Manager.
Create the Windows Event Collector EC2 instance
- From the EC2 console , select Instances (running) then select Launch Instances.
- Provide a name for your instance, such as: WindowsEventLogCollector
- From the Quick Start section, select Windows then select Microsoft Windows Server 2022 Base from the Amazon Machine Image (AMI) dropdown.
- Under Instance Type select
t3.medium. If you desire, you may use a larger instance type, but the pricing example in the overview is based ont3.mediumin theus-east-1region.
- Key pair (login): Select a key pair you have access to or select Create a new key pair to create a new one.
- In the Network Settings section, use the following options:
- VPC: Choose the VPC for your Amazon WorkSpaces.
- Subnet: Choose a private subnet your WorkSpaces VPC.
- Auto-assign public IP: disabled
- Firewall (security groups): Choose the Select existing security group radio button and select an existing Security Group with default outbound rules, which permits access to the internet. The VPC default security group will work.
- Configure storage: Expand this to 40 GB. Encryption is optional based on your organization’s policies.
- Expand the Advanced Details tab.
- In the Domain join directory dropdown, select the AD Connector. If you have multiple unique Fully Qualified Domain Names, select the directory your WorkSpaces use.
- Optional: If you plan to connect to the instance with SSM Fleet Manager, you must attach an IAM role with the relevant permissions. Select the IAM instance profile drop down menu. Choose an appropriate role. This could be a pre-existing one in your account. Otherwise, it will be the one you created in the section Optional Prerequisite: Create an IAM role for SSM Fleet Manager.
- Select Launch instance.
The instance will take approximately 10-15 minutes to create and become accessible.
Connect to the EC2 instance
Begin by logging into your new EC2 instance with your preferred method. You can use RDP if you have access to the subnet through a VPN or Direct Connect setup. You can also use SSM Fleet Manager. To use SSM Fleet Manager:
- Select the instance in the EC2 console
- Select the “Actions” drop down menu in the top right
- Select Connect
- Select the “RDP Client” tab, and then the “Connect using Fleet Manager” radio button
- Select the “Fleet Manager Remote Desktop” button on the bottom.
- When prompted for credentials, enter them in a domain format. You can use either
domain\usernameorusername@domain.tldas the format.
Whether you use an RDP client or SSM Fleet Manager, be sure to log into the instance using your domain credentials. You will need permissions to create Group Policy in your domain. If your organization’s policies require you to log in with a non-privileged domain user, and elevate to launch specific MMCs, follow those procedures as required.
Install the Group Policy Management MMC
Now that you have connected to the instance, open an Administrator PowerShell prompt. Enter the following command:
Install-WindowsFeature -Name GPMC This will install the Group Policy Management features.
After this command completes, enter
gpmc.msc in the PowerShell window and press Enter to launch the Group Policy Management window. You will use this MMC in subsequent sections.Do not close the PowerShell window, as you will need it in a subsequent section.
Enable auditing of login events
In this section, you will enable audit logging for accounts which is not enabled by default in Active Directory.
When you have Kerberos Authentication auditing enabled, the Security Event Logs of your Domain controllers will log 3 additional event IDs:
- You will see this event on all successful logins. When a user logs into the WorkSpaces client on an AD Connector directory, the AD Connector service requests a Kerberos Ticket Granting Ticket to facilitate the login.
- 4771 - Kerberos pre-authentication failed .
- You will see this on unsuccessful logins, such as user entering the wrong password.
Using the Group Policy Management MMC –
gpmc.msc – complete the following steps.- In the left column, expand the Forest folder, then Domains, and then the domain name. You should see a list of your OUs.
- Right select the “Domain Controllers” OU. Select “Create a GPO in this domain, and Link it here…” Enter a name for your Group Policy, such as “AD Audit Logging” and press Enter.
- Right select your new Group Policy Object and select “Edit…”
- In the resulting Group Policy Management Editor window, expand Computer Configuration, Policies, Windows Settings, Security Settings, Advanced Audit Policy Configuration, Audit Policies, and then select the Account Logon section.
- Select “Audit Kerberos Authentication Service” in the right section, and select the Success and Failure boxes. Select OK to close the properties window.
You can now close the Group Policy Management Editor. Do not close the overall Group Policy Management MMC.
Create the Event Log Subscription
In this section, you will create the Subscription for your Event Log forwarding. This is the listener side of the equation.
- Open
eventvwr.msc
- Right-select “Subscriptions” in the left column and choose “Create Subscription…”
- Enter a name and description, such as “AD Connector Events” and “Collects event logs related to AD Connector user login activity.”
- For “Destination log:” choose “Forwarded Events”.
- For the Subscription type and source computers section:
- Choose the “Source computer initiated” radio button.
- Choose “Select Computer Groups”
- In the resulting window, select “Add Domain Computers”.
- Type “Domain Controllers” into the box and press “Check Names”. It should underline. Press OK, and then OK a second time to close the window.
- Press "Select Events…”
- In the query filter, choose:
- By log: Security
- Under the "includes/excludes Event IDs" box, enter 4768,4771,4772
- Check all 5 boxes at the top as well - Critical, Warning, Verbose, Error, and Information.
- Select “OK” to close the query filter box.
- Select “OK” to finalize the Subscription Properties box.
Create the Event Log Forwarding Group Policy
In this section, you will create a Group Policy which enables Event Log Forwarding for your Kerberos and account audit events. This policy will ensure those events are forwarded to your Windows Event Log collection server. Since the events you are forwarding are written into the Security event log, it’s also necessary to expand the permissions of the NETWORK SERVICE. This is because by default, NETWORK SERVICE does not have permissions to read the Security event log. This is slightly complex to do on domain controllers, as there’s no way to modify local users and groups on a domain controller. The Group Policy you create will manage this.
Copy the below text into a text editor such as Notepad.
Server=http://REPLACEME:5985/wsman/SubscriptionManager/WEC,Refresh=60 In your pre-existing PowerShell window, run the following command. This will retrieve your computer’s full hostname and fully qualified domain name, and copy it directly into your clipboard.
[System.Net.Dns]::GetHostByName($env:computerName).HostName | clip Now that the computer’s hostname is on your clipboard, select REPLACEME in the text editor section, and paste in the computer’s hostname. The fully formed string should resemble this:
Server=http://EC2AMAZ-IJ1P3E1.example.com:5985/wsman/SubscriptionManager/WEC,Refresh=60 You will need this string in the below steps.
Using the Group Policy Management MMC –
gpmc.msc – complete the following steps.- In the left column, expand the Forest folder, then Domains, and then the domain name. You should see a list of your OUs.
- Right select the “Domain Controllers” OU. Select “Create a GPO in this domain, and Link it here…” Enter a name for your Group Policy, such as “AD Connector Event Log Forwarding” and press Enter.
- Right select your new Group Policy Object and select “Edit…”
- In the resulting Group Policy Management Editor window, expand Computer Configuration, Policies > Administrative Templates > Windows Components > Event Forwarding, and then select the Configure target Subscription Manager section.
- In the resulting window, choose the Enabled radio button. In the bottom left section, you will see SubscriptionManagers and a Show… button to the right. Select the Show… button.
- In the resulting Show Contents window, you will see a blank Value column. Paste the string you crafted above, into this field. Then select OK on the Show Contents and Configure target Subscription Manager windows.
- In the Group Policy Management Editor window, expand the Event Log Service section in the left column, and select the Security folder.
- In the right column, select Configure log access.
- In the resulting Configure log access window, select the Enabled radio button. In the “Log Access” field in the bottom left, paste the following string:
O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x5;;;BA)(A;;0x1;;;S-1-5-32-573)(A;;0x1;;;NS) You can now close the Group Policy Management Editor as well as the Group Policy Management MMC.
This string is enabling the
NT AUTHORITY\NETWORK SERVICE account to read the Security event log, which it doesn’t have permissions to do by default. If you would like to see this in a more human readable format, you can use the ConvertFrom-SddlString PowerShell cmdlet (available in PowerShell 7 and beyond) to read this. Here is the output of that command:PS C:\Users\dan1> ConvertFrom-SddlString -Sddl "O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x5;;;BA)(A;;0x1;;;S-1-5-32-573)(A;;0x1;;;NS)"
Owner : BUILTIN\AdministratorsGroup : NT AUTHORITY\SYSTEMDiscretionaryAcl : {NT AUTHORITY\SYSTEM: AccessAllowed (ChangePermissions, CreateDirectories, Delete, GenericExecute, ListDirectory, ReadPermissions, TakeOwnership), NT AUTHORITY\NETWORK SERVICE: AccessAllowed (ListDirectory), BUILTIN\Administrators: AccessAllowed (CreateDirectories, ListDirectory), BUILTIN\Event Log Readers: AccessAllowed (ListDirectory)}SystemAcl : {}RawDescriptor : System.Security.AccessControl.CommonSecurityDescriptor
This Group Policy will take effect within the normal intervals for Group Policy check-ins. You can use
gpupdate /force in an administrative PowerShell or Command Prompt window on each domain controller to ensure this happens immediately. The default refresh interval is every 90 minutes, with a randomized offset of up to 30 minutes.Testing
After the Group Policy has replicated to your domain controllers (or has been manually updated), your AD Connector’s Kerberos audit log events will be forwarded to the EC2 instance you created in this blog.
The log events will be visible in
eventvwr.msc under the Forwarded Events section.You can test for one of these events by logging into your WorkSpaces. The event will note whether the attempt was successful or unsuccessful. This will indicate a bad password attempt or a successful password attempt. Below is an example of a login event where an incorrect password was supplied.
A very key detail in this example is that the
Network Information field is showing you an IPv4 address of 10.0.0.24 . This is not the IP address of the end user’s device, where the connection attempt came from. It is the IP address of one of your two AD Connector instances.The below event log entry lets you see two key things as a result:
- An incorrect password attempt was made on behalf of this particular user.
- The login attempt was processed by the domain controller
EC2AMAZ-J1QL8QP.corp.example.com.
Log Name: SecuritySource: Microsoft-Windows-Security-AuditingDate: 4/25/2024 9:48:31 PMEvent ID: 4771Task Category: Kerberos Authentication ServiceLevel: InformationKeywords: Audit FailureUser: N/AComputer: EC2AMAZ-J1QL8QP.corp.example.comDescription:Kerberos pre-authentication failed.
Account Information: Security ID: S-1-5-21-2691045397-3057245523-3271568740-1140 Account Name: Dan2
Service Information: Service Name: krbtgt/CORP.EXAMPLE.COM
Network Information: Client Address: ::ffff:10.0.0.24 Client Port: 53308
Additional Information: Ticket Options: 0x800010 Failure Code: 0x18 Pre-Authentication Type: 2
Here is an example of a successful user login.
Log Name: SecuritySource: Microsoft-Windows-Security-AuditingDate: 5/9/2023 12:56:17 AMEvent ID: 4768Task Category: Kerberos Authentication ServiceLevel: InformationKeywords: Audit SuccessUser: N/AComputer: EC2AMAZ-J1QL8QP.corp.example.comDescription:A Kerberos authentication ticket (TGT) was requested.
Account Information: Account Name: Dan2 Supplied Realm Name: CORP.EXAMPLE.COM User ID: CORP\Dan2
Service Information: Service Name: krbtgt Service ID: CORP\krbtgt
Network Information: Client Address: ::ffff:10.0.0.24 Client Port: 46672
Additional Information: Ticket Options: 0x800010 Result Code: 0x0 Ticket Encryption Type: 0x12 Pre-Authentication Type: 2Rollback
To remove this setup, you will simply delete the two Group Policy Objects you created. The settings in these GPOs will roll back upon deletion.
Rolling back the Event Log Forwarding Group Policy
The Event Log Forwarding Group Policy does not persist, so deleting it will be sufficient to roll it back.
Using the Group Policy Management MMC –
gpmc.msc – complete the following steps.- In the left console, expand Forest, Domains, and your domain Fully Qualified Domain Name. Locate the Organization Unit you identified in the previous section.
- In your Domain Controllers OU, you will see the AD Audit Logging GPO you created previously. Right select this and choose Delete.
You can now close the Group Policy Management Editor. Do not close the overall Group Policy Management MMC.
You can confirm that the policy rolled back with two checks.
Perform these checks after connecting to a domain controller:
- Open an admin PowerShell prompt
- Run
gpupdate /force
- Run
wevtutil gl securityin order to validate that thechannelAccessvalue has returned to its default.
- For reference, the default value is:
O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x5;;;BA)(A;;0x1;;;S-1-5-32-573)
- Now open the Event Viewer –
eventvwr.msc
- In the left column, expand Applications and Services Logs > Microsoft > Windows > Eventlog-ForwardingPlugin and select Operational.
- In the right section, you should see a fresh entry for Event ID 103, showing that the subscription is unsubscribed.


Rolling back the auditing Group Policy
The auditing Group Policy does not persist, so deleting it will be sufficient to roll it back.
Using the Group Policy Management MMC –
gpmc.msc – complete the following steps.- In the left console, expand Forest, Domains, and your domain Fully Qualified Domain Name. Locate the Organization Unit you identified in the previous section.
- In your Domain Controllers OU, you will see the AD Audit Logging GPO you created previously. Right select this and choose Delete.
You can now close the Group Policy Management Editor and the Group Policy Management MMC.
You can validate that the Audit Policy has changed by running a
gpupdate /force on a domain controller and looking at the Security event log in the Event Viewer. You should see Event 4179, indicating an Audit Policy Change, showing the events were removed.
Conclusion
In this article, you learned how to collect Kerberos audit events relating to AWS AD Connector at scale across your Active Directory fleet. You also learned how to aggregate them on a central server, using built-in Windows features.
If you need to retrospectively understand which domain controller was processing AD Connector logins at a specific point in time, collecting these events makes this possible. This also helps you check on how many invalid login attempts are made for individual end users.
Series: AD Connector and WorkSpaces (4 articles)
- …
- 4Auditing and Monitoring AD Connector Login Events This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article