Windows Authentication with AWS Managed Microsoft AD

Most companies don’t want a separate SQL password for each person. They want people to sign in with the same Windows account they use for everything else, with access following their AD groups. RDS SQL Server Windows authentication gives you that by joining the instance to AWS Managed Microsoft AD.

You’ll create a Managed AD domain, add a user and a group with the AWS CLI, join saat-sql to the domain and map the group to a SQL login, then sign in as that user from a domain-joined Windows server. Along the way you’ll fix the two errors nearly everyone hits the first time.

TimeYou needBy the end you can
150 minutes (most of it waiting for the directory and domain joins)You need Lessons 42 to 44 finished (saat-sql, Start-SqlLab.ps1, Stop-SqlLab.ps1), plus saat-vpc, saat-ec2-ssm-profile and your laptop signed in as saat-admin. The session costs about USD 1, because Managed AD Standard runs two domain controllers at about USD 0.15 an hour and there’s a small Windows instance too. Everything gets deleted at the end.You’ll create AWS Managed Microsoft AD, manage users and groups through the Directory Service Data API, join RDS for SQL Server to a domain with the correct IAM role, create Windows logins for AD groups, and troubleshoot name and Kerberos problems.

What it is, in one line

RDS SQL Server Windows authentication lets domain users and groups from AWS Managed Microsoft AD log in to SQL Server with their Windows identity instead of SQL passwords.

In Simple Words

The office ID card

In a big office nobody hands you a separate key for every room. You get one ID card, the security desk knows which rooms your department can enter, and if you change departments your access changes the same day. Here Managed AD plays the security desk, your Windows account is the ID card, and a SQL login for an AD group says “anyone from this department may read the shop data”. There’s one catch: the card reader only trusts your card when you come in through the official door with the building’s real name over it. Walk in by a side door with a different sign and it refuses you, which is why the server name matters so much for Kerberos.

Engineer's View

How Windows authentication works on RDS

AWS Managed Microsoft AD runs real Windows Server domain controllers in two subnets you pick (Standard or Enterprise edition), and AWS manages and patches them. You look after users and groups with the usual AD tools from a domain-joined machine, or with the Directory Service Data API (aws ds-data) once you’ve enabled directory data access. It can also trust an on-premises AD, so people keep the accounts they already have.

To join the instance to the domain, RDS uses an IAM role that trusts rds.amazonaws.com and carries the AmazonRDSDirectoryServiceAccess policy. After that RDS has a domain endpoint, instance-id.domain-fqdn, with the Kerberos service principal registered, and clients have to connect to that name. If they use the rds.amazonaws.com endpoint or an IP, Kerberos fails and the login is refused as coming from an untrusted domain.

Inside SQL Server you create logins FROM WINDOWS with the NetBIOS short name (SAAT\Group). Granting access to groups instead of people means access reviews happen in AD. The same directory can also serve FSx for Windows File Server (Lesson 22), EC2 domain joins and Amazon WorkSpaces.

How it works, step by step

This is what happens when SAAT\priya opens a connection.

1The client asks the domain for a ticket

winad01 is joined to corp.saatvedha.lab, so when priya connects to saat-sql.corp.saatvedha.lab, Windows asks a domain controller for a Kerberos ticket for that SQL Server service.

How a Windows login reaches RDS SQL Server through Managed AD and Kerberos

2SQL Server checks the ticket

Because saat-sql is in the same domain, it can check the ticket without ever seeing priya’s password.

3Group membership decides access

priya belongs to SaatShopReaders, which has a login and db_datareader in SaatShop. Take her out of the group and her access goes too.

4Line up the pieces

These four things all have to be right together:

Pieces of RDS SQL Server Windows authentication: Managed AD, directory role, logins, client

When it fails, it’s usually because one piece is slightly off: the wrong short domain name in CREATE LOGIN, a client connecting with the wrong server name, or the RDS role not being there.

✅ Checkpoint: You can explain what Managed AD and the RDS directory role do, why logins are created for groups, and why clients have to use the domain FQDN endpoint.

Hands-on lab: log in to RDS SQL Server as a domain user

Before you run any command, double-check it

Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.

Sign in, start the SQL lab and set the names:

cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json
.\Start-SqlLab.ps1

1Create the Managed AD domain

Paste this whole block. The directory normally takes 20 to 40 minutes to become Active:

$adPw = aws secretsmanager get-random-password --password-length 20 --exclude-punctuation --require-each-included-type --query RandomPassword --output text
$dir = aws ds create-microsoft-ad --name corp.saatvedha.lab --short-name SAAT --password $adPw --edition Standard --vpc-settings "VpcId=$($v.VpcId),SubnetIds=$($v.PrivateA),$($v.PrivateB)" --tags Key=course,Value=saatvedha-aws --query DirectoryId --output text
do { Start-Sleep 60; $stage = aws ds describe-directories --directory-ids $dir --query "DirectoryDescriptions[0].Stage" --output text; $stage } until ($stage -in 'Active', 'Failed')
$dns = (aws ds describe-directories --directory-ids $dir --query "DirectoryDescriptions[0].DnsIpAddrs" --output text) -split '\s+'
"$dir $($dns -join ' ')"

You should see something like this:

Creating
Creating
Active
d-9f67a1b2c3 10.20.11.207 10.20.12.84

You now have two domain controllers running in saat-private-a and saat-private-b, and their IP addresses act as the domain’s DNS servers. The Admin password sits in $adPw for this session only. In production you’d put it straight into Secrets Manager.

2Add a user and a group with the CLI

Paste this whole block:

aws ds enable-directory-data-access --directory-id $dir
Start-Sleep 60
aws ds-data create-user --directory-id $dir --sam-account-name priya --given-name Priya --surname Shah | Out-Null
$userPw = aws secretsmanager get-random-password --password-length 20 --exclude-punctuation --require-each-included-type --query RandomPassword --output text
aws ds reset-user-password --directory-id $dir --user-name priya --new-password $userPw
aws ds-data create-group --directory-id $dir --sam-account-name SaatShopReaders | Out-Null
aws ds-data add-group-member --directory-id $dir --group-name SaatShopReaders --member-name priya
aws ds-data list-group-members --directory-id $dir --sam-account-name SaatShopReaders --query "Members[].SAMAccountName" --output text

You should see this:

priya

You managed the directory without any Windows server. Teams that already have AD usually set up a trust instead, so people keep their on-premises accounts.

3Join saat-sql to the domain and create the login

Paste this whole block. The join restarts saat-sql and takes 10 to 20 minutes:

'{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "rds.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }' | Set-Content rds-ds-trust.json
aws iam create-role --role-name saat-rds-ds-role --assume-role-policy-document file://rds-ds-trust.json --query Role.RoleName --output text
aws iam attach-role-policy --role-name saat-rds-ds-role --policy-arn arn:aws:iam::aws:policy/service-role/AmazonRDSDirectoryServiceAccess
Start-Sleep 15
aws rds modify-db-instance --db-instance-identifier saat-sql --domain $dir --domain-iam-role-name saat-rds-ds-role --apply-immediately --query "DBInstance.DBInstanceStatus" --output text
Start-Sleep 60
aws rds wait db-instance-available --db-instance-identifier saat-sql
aws rds describe-db-instances --db-instance-identifier saat-sql --query "DBInstances[0].DomainMemberships[0].[Domain,Status,FQDN]" --output text
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "CREATE LOGIN [SAAT\SaatShopReaders] FROM WINDOWS"
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -d SaatShop -Q "CREATE USER [SAAT\SaatShopReaders] FOR LOGIN [SAAT\SaatShopReaders]; ALTER ROLE db_datareader ADD MEMBER [SAAT\SaatShopReaders];"

You should see something like this:

saat-rds-ds-role
modifying
d-9f67a1b2c3      joined  corp.saatvedha.lab

saat-sql is now a member of corp.saatvedha.lab and anyone in SaatShopReaders can read SaatShop. Because you gave access to a group and not to a person, the business can manage who’s in it.

RDS SQL Server Windows authentication lab output: domain joined and SAAT\priya reading orders
Domain membership and priya reading orders should look something like this.

4Log in as priya from a domain-joined server

Paste this whole block. It launches winad01, joins it to the domain through Systems Manager and then tests the login, which takes about 20 minutes:

aws iam attach-role-policy --role-name saat-ec2-ssm-role --policy-arn arn:aws:iam::aws:policy/AmazonSSMDirectoryServiceAccess
$dsEp = aws ec2 create-vpc-endpoint --vpc-id $v.VpcId --vpc-endpoint-type Interface --service-name com.amazonaws.ap-south-1.ds --subnet-ids $v.PrivateA --security-group-ids $v.EndpointSg --private-dns-enabled --query VpcEndpoint.VpcEndpointId --output text
$winAmi = aws ssm get-parameter --name /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-Base --query Parameter.Value --output text
$win = aws ec2 run-instances --image-id $winAmi --instance-type t3.medium --subnet-id $v.PrivateA --security-group-ids $v.AppSg --iam-instance-profile Name=saat-ec2-ssm-profile --metadata-options HttpTokens=required --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=winad01},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=45}]' --query "Instances[0].InstanceId" --output text
do { Start-Sleep 30; $p = aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$win" --query "InstanceInformationList[0].PingStatus" --output text } until ($p -eq 'Online')
@{ directoryId = @($dir); directoryName = @('corp.saatvedha.lab'); dnsIpAddresses = $dns } | ConvertTo-Json | Set-Content join.json
aws ssm create-association --name AWS-JoinDirectoryServiceDomain --targets "Key=InstanceIds,Values=$win" --parameters file://join.json | Out-Null
do { Start-Sleep 30; $j = aws ssm describe-instance-associations-status --instance-id $win --query "InstanceAssociationStatusInfos[?Name=='AWS-JoinDirectoryServiceDomain'] | [0].Status" --output text } until ($j -in 'Success', 'Failed')
do { Start-Sleep 30; $p = aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$win" --query "InstanceInformationList[0].PingStatus" --output text } until ($p -eq 'Online')
$test = @'
$pw = ConvertTo-SecureString 'PW_HERE' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('SAAT\priya', $pw)
$job = Start-Job -Credential $cred -ArgumentList 'SERVER_HERE' -ScriptBlock {
  param($srv)
  $cn = New-Object System.Data.SqlClient.SqlConnection("Server=$srv;Database=SaatShop;Integrated Security=SSPI;Encrypt=True;TrustServerCertificate=True")
  try { $cn.Open(); $cmd = $cn.CreateCommand(); $cmd.CommandText = "SELECT SUSER_NAME() + ' reads ' + CAST(COUNT(*) AS varchar(10)) + ' orders' FROM dbo.Orders"; $cmd.ExecuteScalar() }
  catch { $_.Exception.Message } finally { $cn.Close() }
}
$job | Wait-Job -Timeout 90 | Receive-Job
'@
function Test-WinLogin([string]$Server) {
  $script = $test -replace 'PW_HERE', $userPw -replace 'SERVER_HERE', $Server
  @{ commands = @($script -split "`r?`n") } | ConvertTo-Json | Set-Content win-test.json
  $cmd = aws ssm send-command --document-name AWS-RunPowerShellScript --instance-ids $win --parameters file://win-test.json --query Command.CommandId --output text
  do { Start-Sleep 10; $st = aws ssm get-command-invocation --command-id $cmd --instance-id $win --query Status --output text 2>$null } until ($st -in 'Success', 'Failed', 'TimedOut')
  aws ssm get-command-invocation --command-id $cmd --instance-id $win --query StandardOutputContent --output text
}
Test-WinLogin 'saat-sql.corp.saatvedha.lab'

You should see something like this:

SAAT\priya reads 3 orders

priya signed in with Kerberos and read the orders through her group. The test runs PowerShell on winad01 as priya with .NET’s built-in SQL client, so the server doesn’t need any extra tools. If you prefer, you can connect with Fleet Manager’s Remote Desktop as SAAT\priya and use SSMS.

SSMS connected as SAAT\priya with Kerberos authentication reading three orders
Here’s the same test in SSMS over Fleet Manager Remote Desktop, with priya signed in through Kerberos and reading the orders.

✅ Checkpoint: corp.saatvedha.lab is Active, saat-sql shows joined, SAAT\SaatShopReaders has a login with db_datareader, and SAAT\priya read 3 orders from winad01.

Break It, Then Fix It

These are the two errors almost everyone sees on day one with Windows authentication.

1Break it: the wrong domain name in CREATE LOGIN

Use the first part of the DNS name in place of the short name:

sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "CREATE LOGIN [CORP\SaatShopReaders] FROM WINDOWS"

You’ll get an error like this:

Msg 15401, Level 16, State 1, Server EC2AMAZ-ABC123, Line 1
Windows NT user or group 'CORP\SaatShopReaders' not found. Check the name again.

SQL Server expects the NetBIOS short name you picked when you created the directory (SAAT), and not the first label of the DNS name (corp). In companies the two are often different, so this error comes up a lot. Fix: look up the short name and use that:

aws ds describe-directories --directory-ids $dir --query "DirectoryDescriptions[0].[Name,ShortName]" --output text

You should see this:

corp.saatvedha.lab      SAAT

2Break it: connect with the RDS endpoint name

Run the same login test again, this time with the normal RDS endpoint:

$rdsEp = aws rds describe-db-instances --db-instance-identifier saat-sql --query "DBInstances[0].Endpoint.Address" --output text
Test-WinLogin $rdsEp

You should see something like this:

Exception calling "Open" with "0" argument(s): "Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication."
Windows authentication problems: wrong domain short name and untrusted domain login
Both problems and their fixes should look something like this.

Kerberos looks for a service registered under whatever name you connect to. The rds.amazonaws.com name isn’t in the domain, so Windows falls back to a method that RDS won’t accept for domain logins.

App teams run into this when they copy the endpoint straight from the console. Fix: for Windows authentication always use saat-sql.corp.saatvedha.lab (instance name plus domain), as you did in step 4.

Now clean up, leaving the domain first and then deleting the directory:

sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -d SaatShop -Q "DROP USER [SAAT\SaatShopReaders];"
sqlcmd -S "127.0.0.1,11433" -U saatadmin -C -Q "DROP LOGIN [SAAT\SaatShopReaders];"
aws rds modify-db-instance --db-instance-identifier saat-sql --disable-domain --apply-immediately --query "DBInstance.DBInstanceStatus" --output text
aws ec2 terminate-instances --instance-ids $win | Out-Null
Start-Sleep 60
aws rds wait db-instance-available --db-instance-identifier saat-sql
aws ds delete-directory --directory-id $dir --query DirectoryId --output text
aws ec2 delete-vpc-endpoints --vpc-endpoint-ids $dsEp | Out-Null
aws iam detach-role-policy --role-name saat-ec2-ssm-role --policy-arn arn:aws:iam::aws:policy/AmazonSSMDirectoryServiceAccess
aws iam detach-role-policy --role-name saat-rds-ds-role --policy-arn arn:aws:iam::aws:policy/service-role/AmazonRDSDirectoryServiceAccess
aws iam delete-role --role-name saat-rds-ds-role
Remove-Item rds-ds-trust.json, join.json, win-test.json
.\Stop-SqlLab.ps1

✅ Checkpoint: You fixed Msg 15401 with the right short domain name, and the untrusted-domain login by using the domain FQDN. saat-sql has left the domain, the directory, winad01, the endpoint and the role are deleted, and saat-sql is stopping.

This happened at work

The migration weekend that stalled on Monday

An insurance company moved its claims database to RDS SQL Server over a weekend and joined it to Managed AD, with a trust to the on-premises domain. On Sunday the DBA tested from his laptop and everything worked.

Then on Monday morning 300 claims staff got “login is from an untrusted domain”. Someone had updated the application’s connection string with the endpoint copied from the RDS console, the rds.amazonaws.com name, while the DBA had tested with the domain name, which is why Kerberos had worked for him.

Once they found it, the fix took five minutes: point the connection string at the instance name plus domain, and add a CNAME in on-premises DNS so there’s an easy name pointing to it. The team also added a line to the cutover checklist: test as an ordinary user, from an ordinary desktop, with the exact connection string the app uses.

Common mistakes and troubleshooting

MistakeWhat happensWhat to do
Connecting with the rds.amazonaws.com nameLogin from an untrusted domainUse instance-name.domain-FQDN
Using the DNS label instead of the short nameMsg 15401 user or group not foundUse the NetBIOS short name (SAAT\…)
Logins for individual usersAccess reviews spread across many serversCreate logins for AD groups
Missing RDS directory roleThe domain join failsA role trusting rds.amazonaws.com with AmazonRDSDirectoryServiceAccess
Directory in subnets apps can’t reachJoins and logins time outPlace the DCs where clients and RDS can reach them, and check security groups
Deleting the directory before leaving the domainThe instance is left with a broken membershipDisable the domain on RDS first

Interview questions

Click a question to open it. Each one is worded the way an interviewer would ask it, and underneath you’ll find why they ask and one way you could answer in your own words.

Fresher level

1. Your company wants people to log in to RDS SQL Server with their Windows accounts. What do you need to set that up?

Why they ask this: Setups usually fail because one piece is missing, so they want to know you understand every part of Windows authentication on RDS.

How you might answer: I’d need AWS Managed Microsoft AD, which can also trust our on-premises AD if we have one. RDS needs an IAM role with AmazonRDSDirectoryServiceAccess, and the instance has to be joined to the directory.

After that I’d create Windows logins in SQL Server for the people or groups that need access.

2. The finance team needs read access to a reporting database. How would you create a login for their AD group?

Why they ask this: Once Windows authentication is in place this is an everyday task, so they’re checking you can write the basic T-SQL for Windows logins.

How you might answer: I’d run CREATE LOGIN [SHORTNAME\FinanceGroup] FROM WINDOWS to create a login for the group, then add a database user for it in the reporting database and give it only the read role it needs.

3. Why would you grant database access to AD groups instead of individual users?

Why they ask this: They want to see good habits around access, because granting it user by user turns into a mess as people join and leave.

How you might answer: That way access follows group membership, which lives in AD, so joiners and leavers are handled in one place and nobody has to touch SQL Server.

Access reviews get much easier too, since I’m reviewing a few groups and not hundreds of users.

2–5 years experience

4. Users get the error “login is from an untrusted domain” when connecting to RDS. What would you check?

Why they ask this: It’s one of the most common Windows authentication problems and the Kerberos side makes it confusing, so they want a clear troubleshooting order.

How you might answer: I’d start with the server name they’re using, because Kerberos only works with the domain FQDN endpoint. Then I’d check the client is domain-joined or in a trusted domain, and that DNS resolves to the instance.

I’d also look at time sync, and confirm the instance really shows as joined to the directory.

5. Staff in the office want to log in to RDS with the same accounts they use every day on-premises. How would you make that work?

Why they ask this: Most companies already run an on-premises AD they want to keep, so they’re checking you understand hybrid identity.

How you might answer: I’d set up a trust between AWS Managed Microsoft AD and the on-premises AD over VPN or Direct Connect, then create SQL Server logins for the on-premises groups so people can use the accounts they already have.

6. What is the Directory Service Data API, and why would an admin use it?

Why they ask this: It shows whether you keep up with changes in the services you run and know the newer tools that make daily work easier.

How you might answer: It’s an API, aws ds-data, for managing users and groups in Managed Microsoft AD without a domain-joined machine. You have to enable directory data access before you can use it.

I find it handy for scripting user and group changes from the CLI, so I don’t have to log in to a Windows server.

Senior level

7. You’re asked to design identity for 50 RDS SQL Server instances used by 2,000 employees. How would you set it up?

Why they ask this: They want identity architecture at scale, and they’re listening for how you handle sharing, trusts, emergency access and auditing.

How you might answer: I’d run Managed Microsoft AD in a shared services account and share it with the workload accounts, with a two-way or one-way trust to on-premises AD. I’d only create logins for AD groups, mapped to roles in each database.

For emergencies I’d keep break-glass SQL logins in Secrets Manager, and audit logins with SQL Server Audit.

8. Your apps use SQL logins today, and security wants them moved to Windows authentication. How would you do it without breaking anything?

Why they ask this: They’re looking for careful change management: moving step by step, with a way to roll back.

How you might answer: I’d begin by listing the SQL logins and which apps use each one. Then I’d create AD groups and gMSA or service accounts, and add Windows logins next to the existing SQL logins.

I’d move the connection strings over one app at a time, testing each with the domain FQDN, and only then disable the SQL logins and keep an eye out for failed logins.

Quick quiz

Q1. Which name must clients use for Kerberos with RDS?

  1. The rds.amazonaws.com endpoint
  2. instance-name.domain-FQDN
  3. The IP address
  4. localhost
Show answer

B: the domain endpoint is where the service is registered.

Q2. Why did CREATE LOGIN [CORP\…] fail?

  1. No permission
  2. CORP isn’t the NetBIOS short name
  3. The group was empty
  4. TLS was off
Show answer

B: the short name is SAAT.

Q3. What policy does the RDS directory role need?

  1. AmazonRDSFullAccess
  2. AmazonRDSDirectoryServiceAccess
  3. AdministratorAccess
  4. AmazonSSMManagedInstanceCore
Show answer

B: it lets RDS join the domain and manage the membership.

Q4. What should SQL logins be created for?

  1. Individual users
  2. AD groups
  3. Computers
  4. Nobody
Show answer

B: with groups, access stays managed in AD.

Q5. What must you do before deleting the directory?

  1. Nothing
  2. Remove RDS from the domain
  3. Delete the database
  4. Rotate passwords
Show answer

B: disable the domain on the instance first.

Quick recap

  • Managed Microsoft AD gives RDS a real domain, and RDS joins it through a role with AmazonRDSDirectoryServiceAccess.
  • Create Windows logins for AD groups using the NetBIOS short name.
  • For Kerberos, clients have to connect to instance-name.domain-FQDN.
  • You can manage users and groups from the CLI with the Directory Service Data API.
  • Always leave the domain before you delete the directory.

Next lesson

Lesson 46: Native backup and restore with S3 → Next you’ll back up a database from saat-sql to S3 with rds_backup_database and restore it as a new database.

Further reading: RDS SQL Server Windows authentication

Want to go deeper into RDS SQL Server Windows authentication? Read Working with AWS Managed Active Directory with RDS for SQL Server and AWS Managed Microsoft AD. You can also see the full plan for this course on the AWS Cloud Administration course page.

Scroll to Top

This website uses cookies

We use a few cookies to keep this site working. If you allow it, we also use Google Analytics to count visits so we can improve our lessons. You can accept all, deny the optional ones, or choose what to allow.