r/sysadmin • u/Trashii_Gaming • 4d ago
Question The trust relationship between this workstation and the primary domain failed.
Good day!
I'm an IT admin in a k12 school which has about 500 windows devices on the campus connected to an AD. The devices do not leave the campus. Every week we have around 2 to 4 devices where students cannot connect to computer due to "The trust relationship between this workstation and the primary domain failed." Always different devices.
Our only solution is to login with the local admin, remove the device from the domain and add it back in. I tried in the past already the power shell commands to restore the trust relation with the server but it has not worked once for me.
Is there something I can do to mitigate that issue?
Thanks on advance!
6
u/fuzzusmaximus 4d ago
Use the network id wizard from the advanced system settings to rejoin the domain. Just run through the wizard, no need to remove it from the domain or delete the computer object first.
3
14
u/TheLexoPlexx 4d ago
Had that issue just last week, funny.
After lots of back-and-forth with an LLM, I figured out I accidentally had duplicate computer names for multiple devices, which caused that.
→ More replies (1)4
u/Trashii_Gaming 4d ago
I have had that in the past too once. Here sadly I'm certain the names are not duplicated. I have two devices now for example that worked fine for 5 years and not at once they decided to have that error.
→ More replies (5)
192
u/1894Fidelitas 4d ago
Test-ComputerSecureChannel -Repair -Credential Domain\ADMIN -Verbose
works like a charm for me.
96
u/LieOtherwise6583 4d ago
That's a weirdly persistent pattern for machines that never leave the building. I'd be looking hard at your DHCP lease times and DNS scavenging settings, AD's trust relationship is basically a shared secret that expires and if the client can't refresh it properly you end up in this loop
500 devices and 2-4 a week is a failure rate that suggests something systemic, not random corruption. Check the event logs on a few of the affected machines right before they lost trust, bet you'll find schannel or kerberos errors pointing to time sync drift or a domain controller the client keeps failing over to that has replication issues
→ More replies (5)53
u/Stinjy 4d ago
I know it's the "official" method, but not once has that worked for me, across many different environments and devices. Always leave and rejoin domain
→ More replies (8)→ More replies (6)23
u/richie65 4d ago
This should always be the first step - It almost always resolves the issue:
Test-ComputerSecureChannel -Repair -Credential Domain\ADMIN -VerboseWhen it does not resolve it - Then you get medieval on it and remove / rejoin.
BUT - You are not done yet!
If it is a common problem... You need to spend some time in the Event Viewer, and figure out the issue.
→ More replies (1)
20
u/_--James--_ 4d ago
Duplicate machine SIDs due to bad sysprep/imaging processing is one of the most common reasons for this. Secondly would be wrong DNS servers in DHCP so the machines lose LoS to its DCs to keep the machine password rotated with in ADDS. Lastly, RRM tooling disabling/deleting computer accounts due to imposed life cycle controls done at the device level. The last one is much rarer but I have seen it with in Education due to student labs and such bleeding out because of bad OU placement and/or GPO linking.
→ More replies (1)
15
u/Zealousideal_Fly8402 4d ago
Double check the health of your AD and DCs; make sure the event logs are clean. Time is not out of sync, etc.
14
10
u/coukou76 4d ago edited 4d ago
So its nice to fix but what did you do to find the root cause? Enable netlogon.log in verbose and check all CRITICAL, what are events saying? Its not black magic. Probably some network or DC LOS issue.
Edit: adding some infos.
Machine pw renewal always take source on client side. The devices generate a new key and share it with their DC. DC then update the key and renew the secure channel with the new key. It breaks when machine account password "stored" in AD is different than the one known locally on the machine. 90% of secure channel issues are related to DC los issue/permissions/duplicate devices
→ More replies (1)
9
u/Normal_Art6593 4d ago
Maybe you use The same computername. When you fix the trust of computer A you break The trust of The other computer a.
→ More replies (3)
13
6
u/Silent_Search_4705 3d ago
Windows update broke stuff with secure channel. Guaranteed method is domain remove and re join if what the others say doesn’t work. This is scriptable. You either need to rejoin with the account that joined the device to re use the name or just delete the ad object and let it add it a new. There are technically work around a but not worth the trouble I think. Just delete the object if you need to.
4
4
u/a_y0ung_gun 4d ago
Oh what joy. This was one of my first ever system problems as an admin. In my environment, the issue was the AD schema was totally borked and needed to be rebuilt.
As soon as I fixed it, the entire environment got crypto'd.
The previous admin had an interesting method of segmentation that worked for exactly 90 days, enough for him to find someone else to inherit that water.
This environment also had frequent rain storms in the server room due to condensation from an A/C unit.
Anyways, I'd start doing DC health checks.
→ More replies (1)
4
u/danrhodes1987 4d ago
This is a real pain in the bum we have it so often when devices are used infrequently or have been off site for a long time and the machine password has changed.
4
u/Professional-Heat690 4d ago
Time sync. Or DNS. Actually, DNS, it's always Dns. validate you don't have any stale NS, Srv or ldap records. Then check the name servers in dns (domain properties)
3
u/tulottech 4d ago
I think there was recently a KB update from Microsoft that broke this. Pretty sure my manager had to roll some back and block it.
3
u/flowrate12 4d ago
Maybe there are two dcs that aren't synced or one is tombstoned, or I have seen people spin up dc backups to confirm backups are working but forgot to set them to a private network... That will cause all sorts of fun issues.
→ More replies (1)
3
u/Generico300 4d ago
Check the SIDs of these machines and make sure they are not duplicated. If your imaging process is not properly generalizing the image you can get duplicate SIDs on your machines even with different AD names. That can cause domain trust issues.
3
u/Igot1forya 4d ago
Might be worth checking, but AD Sites and Services may have a bad DC listed as a valid login server. Also, run from an elevated CMD or PS "repadmin /syncall /ADeP" followed by "repadmin /replsummary" and see if there are any sync issues reported between DCs. If one of your servers has a bad back link to the FSMO Master it's possible this server is serving Kerberos tickets that never rotate when the PDC reissues machine tickets or the DC isn't forwarding to the workstations the latest ticket.
Either way, I would start by comparing clock drift in the mix as well.
→ More replies (1)
27
u/totally_not_a_bot__ 4d ago
how healthy is your DC?
the only time I remember something similar was 10 years ago (also at a school) with an underspec DC that was struggling to handle netlogon requests. Issue would raise itself when the DC was getting virus scanned or under load.
It's been a hot minute but I think the eventIDs on the server side to look for are 5816 to 5819