"Bu iş istasyonu ile birinci etki alanı arasındaki güven ilişkisi başarısız"

Bu problemle ilgili 3 adet yazımız bulunmaktadır.
1- Problemin kaynağı ve çözüm yöntemleri: http://siberblog.org/index.php/the-trust-relationship-between-this-domain-and-the-primary-domain-failed/ yazımızı inceleyin.
2- DC üzerinde problemli makinelerin tespiti: (Bu yazı)
3- Computer Accountlar için Password değişim politikasının iptali için: http://siberblog.org/index.php/active-directory-machine-account-password-changes-policy/ yazımızı inceleyin.
[adsenseyu2]
Active Directory'de aşağıdaki 2 satırlık powershell scriptini çalıştırarak tüm problemli makineleri tespit edebilirsiniz.
1 | Import-Module ActiveDirectory |
2 | Get-ADComputer -LDAPFilter "(badPasswordTime>=1)" -Properties * | Where {$_.LastBadPasswordAttempt -gt ($_.PasswordLastSet)+300000000} | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet, LastBadPasswordAttempt |

TrustcheckUp2.ps1 scriptini buradan indirebilirsiniz. Burada yapılan işlemin ayrıntısını görmek için Metodoloji1 başlığını inceleyebilirsiniz.
ANALİZ İŞLEMLERİ:
DC üzerinde problemli makinelerin tespiti:
Problemin temel kaynağı olan (computer account password) makine hesabı şifresi ile problemli makinede kayıtlı şifrenin eşleşmemesidir. Aktif dizin ortamında "The trust relationship between this domain and the primary domain failed" hatası ile karşı karşıya olan muhtemel problemli makinelerin tespiti için farklı metodolojiler geliştirilebilir.
Aktif dizin’de makine hesabı (computer account) şifresi varsayılan olarak 30 günde bir değiştirilir. Aynı kullanıcı hesaplarında olduğu logon esnasında hesabın bu 30 gün süreyi doldurup doldurmadığı kontrol edilir. Kullanıcılar için şifre değiştirme ekranı gelirken makine hesapları şifresi netlogon servisi tarafından otomatik olarak güncellenir. 30 gün süresi dolan ve aktif olamayan hesaplar, aktif olduğunda güncellenir. Bu süre için bir sınır yoktur.(Etki alanı sunucusunun ve test makinesinin saatlerini el ile 3 yıl ileri alıp kontrol ettim ve herhangi bir sorun ile karşılaşmadım.)

NOT : Best Practies olarak sanal sistemler arasında makine hesap şifre değiştirme işlemi devre dışı bırakılmalıdır. Makine hesabı şifre değiştirme iptali için http://siberblog.org/index.php/active-directory-machine-account-password-changes-policy/ burayı inceleyin.
Herhangi bir problem sonucu ekti alanında veya makinede snapshot, image vb. geri dönme işlemi yapılmış ise buraya dikkat etmek gerekir. (DC'nin snapshottan dönülmesi büyük problemler oluşturabilir.) Etki alanında makine hesabının son şifre değişim zamanını (pwdLastSet) kontrol edelim. Bu tarih yedek alma tarihinden daha eski ise şifreler eşleşmeyecektir.

NOT : Makine hesaplarının şifre değişimlerini eventlog'dan görmek için aktif dizinde Event Viewer üzerinden Event ID 4742 olay kaydını inceleyebilirsiniz. (Audit ayarlarında Account Management altında Computer Account Management etkin ise). Örnek 4742 olay kaydı;

EventLog kayıtları:
Bu probleme içim DC'ye 4771 olay kaydı ve problemli makineye de 4625 olay kaydı düşmektedir. Ayrı ayrı ele alalım:
1- DC Eventlog Kaydı: Bu hata durumunda aktif dizin eventlog'a Event ID 4771 olay kaydı düşmektedir (Audit ayarlarında Account Logon Kerberos Authentication Service etkin ise).
Event ID 4771: Etki alanı üyesi makineler belirli aralıklarla Kerberos servisi tarafından DC'ye (gpupdate) bağlanıp politika güncellemesi yaparlar. Authentication hatasında Event ID 4771 olay kaydı düşer. Hata ayrıntısında belirtilen Failure Code: 0x18 hata kodu Usually means bad password hatalı şifreyi belirtmektedir.

NOT: Event ID 4769: Etki alanı üyesi problemli makineye herhangi bir etki alanı üyesi bağlanmak istediğinde Event ID 4769 olay kaydı düşer. Bu olay kaydında sisyon kullanıcısı CLIENT_01 makinesi üzerinden başarılı olarak Failure Code:0x0 kerberos ticket TGT aldığı yalnız logon olmak istediği makine TGT'yi alamadığı için logon işlemi iptal edilir.

Aktif dizinde Event Viewer kullanarak hatalı olay kayıtlarını filtreleyerek listeleyelim.
- Event Viewer başlatın.
- Windows Log altından Security'e sağ tıklayın ve Filter Current Log... seçin.

- XML sekmesine geçin
- Edit query manually kutucuğunu işaretleyin.

- XML query'i isteğimize göre düzenleyeceğiz. Bize lazım olan olay kaydı 4771'dir. Aynı zamanda 4771 olay kayıtları içinde hatalı şifre 0x18 durumundaki kayıtlar gerekmektedir. Hatalı şifre denildiğinde kullanıcı hesaplarının da hatalı şifreleri geleceği için Servis adını da ekleyelim.
XML sorgumuz aşağıdaki gibidir. Değiştirmeniz gereken yer SIBERBLOG.ORG alanıdır. Yani sorguyu çalıştıracağınız domainin adını girmelisiniz.
XML Source Code1:
EventData[Data[@Name='Status'] and (Data='0x18')] and |
EventData[Data[@Name='ServiceName']='krbtgt/SIBERBLOG.ORG'] |
] |
- Sorguyu yazıp OK butonuna tıkladığınız zaman aşağıdaki gibi bir ekranla karşılaşacaksınız. 1.036.576 adet olay kaydından filtremize uygun 18 adet olay kaydı bulunmuş.
NOT : Kullanıcı hesaplarına ait hatalı şifre giriş olay kayıtları da filtrelenebilmektedir.

Ayrıca belirli bir veya daha fazla makine adı girerek sorgulamak isterseniz:
Sorgulayacağınız makine adlarını kırmızı olarak belirtilen PC01 yerlere yazabilirsiniz. İsteğinize göre makine sayısını artırabilir veya azaltabilirsiniz.
XML Source Code2:
EventData[Data[@Name='Status'] and (Data='0x18')] and |
EventData[Data[@Name='TargetUserName'] and ( |
Data='PC01$' or |
Data='PC02$' or |
Data='PC03$' |
)]] |
Xml query yazmak için link:
http://en.wikipedia.org/wiki/Event_Viewer
http://blogs.technet.com/b/askds/archive/2011/09/26/advanced-xml-filtering-in-the-windows-event-viewer.aspx
http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/bd136cf0-fb9e-48a1-ae2f-3cd4290ab973
2- Problemli makineye ait yerel EventLog kaydı:
Problemli makinenin eventlog kayıtlarına Event ID 4625 olay kaydı düşmektedir. Bu olay kaydı kullanıcının logon olamaması değil makinenin logon olamama kaydıdır. 4625 olay kaydı incelendiğinde Failure Information: altında Status: 0xc000018d görülmektedir. Bu 0xc000018d hata durumu kesin olarak problemimize işaret etmektedir. Bu çözüm SIEM (Security Information and Event Management) ürünleri ile veya merkezi log alma yazılımları ile kullanılabilir.

Aktif Dizin'de problemli makinelerin bulmak için diğer metodolojilerimiz:
Aktif dizin'de ilgili eventlog kayıtları aktif olamayabilir. Veya kayıtların aktarıldığı Syslog'dan eventlog verilerinin çekilip analiz edilmesi mümkün olmayabilir. Bu gibi durumlar için:
Metodoloji1 :
Bir makine hesabında badPasswordTime alanı normal şartlar altında (never) olmalıdır. Bu alan (never) değil ise ve son şifre değişim zamanından pwdLastSet büyük ise problemli demektir.

Powershell script ile etki alanı makine hesaplarında son yanlış şifre badPasswordTime alanı ve son şifre değiştirme zamanı pwdLastSet 'i karşılaştıralım.
Script Code1 : "activedirectory" modülü yüklenerek Get-ADComputer komutu ile.
1 | Import-Module ActiveDirectory |
2 | Get-ADComputer -LDAPFilter "(badPasswordTime>=1)" -Properties * | Where {$_.LastBadPasswordAttempt -gt $_.PasswordLastSet} | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet, LastBadPasswordAttempt |

TrustCheckUp1.ps1 scriptini buradan indirebilirsiniz.
NOT :
Script Code2 : Bazı durumlarda şifre değişim zamanının güncellenmesi işlemi, sunucunun iş yüküne göre 30 saniye kadar gecikme gösterebilmektedir. Bu durumda son şifre değişim zamanı 30 saniye kadar ileri kayabilmektedir. Bu durumu çözmek için son şifre değişim zamanına 30 saniye eklemek gerekebilir. "($_.PasswordLastSet)+300000000"
"activedirectory" modülü yüklenerek Get-ADComputer komutu ile.
1 | Import-Module ActiveDirectory |
2 | Get-ADComputer -LDAPFilter "(badPasswordTime>=1)" -Properties * | Where {$_.LastBadPasswordAttempt -gt ($_.PasswordLastSet)+300000000} | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet, LastBadPasswordAttempt |
TrustcheckUp2.ps1 scriptini buradan indirebilirsiniz.
Metodoloji2 :
Aktif dizin'de kullanıcı hesabı (user account) ile makine hesabını (computer account) karşılaştıralım ve yorumlayalım. Bir kullanıcının şifresini yanlış girmesi doğal bir olaydır çünkü insan faktörü vardır. Fakat makinenin şifresinin yanlış girilmesi olağan dışı bir olaydır. Normal şartlar altında makine hesabının badPasswordTime (en son yanlış girilmiş şifre zamanı) alanının (never) ve badPwdCount (en son doğru şifre girilmesinden bu yana girilen yanlış şifre sayısı) alanının da "0" olması beklenir. (Yalnız problem olsa da bu değer bazen "0" olmayabiliyor.)

NOT : "Attribute Editor" sekmesinin görülebilmesi için "Active Directory Users and Computers" 'da "View" menüsünden "Advanced Features" seçeneğinin işaretli olması gerekmektedir.
Makine hesabının "badPasswordTime" (en son yanlış girilmiş şifre zamanı) alanının ve "badPwdCount" (en son doğru şifre girilmesinden bu yana girilen yanlış şifre sayısı) alanının "0" 'dan farklı olması problemin varlığına işarettir.

Çözüm1 :
a) Problemsiz bir etki alanı kayıtlarına Powershell script ile bakalım. "badPwdCount" alanı "0" sıfır olması sistemde bir anormallik olmadığının göstergesidir.
Script Code1 : "activedirectory" modülü yüklenerek Get-ADComputer komutu ile.
1 | Import-Module activedirectory |
2 | Get-ADComputer -Filter * -Properties Name, Description, badPwdCount, LastLogonDate, PasswordLastSet | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet |

Script Code2 : DsQuery komutu ile.
1 | DsQuery * -filter "(&(objectCategory=Computer)(objectClass=Person)(sAMAccountName=*))" -attr Name dNSHostName Description badPwdCount |

b) Problemli bir etki alanı kayıtlarına Powershell script ile bakalım. Scriptimizde "badPwdCount" alanı "1" ve daha büyük olanları filtreleyerek isteğimiz sonuca ulaşabiliriz.
Script Code1 : "activedirectory" modülü yüklenerek Get-ADComputer komutu ile.
1 | Import-Module activedirectory |
2 | Get-ADComputer -LDAPFilter "(badPwdCount>=1)" -Properties Name, Description, badPwdCount, LastLogonDate, PasswordLastSet | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet |

Script Code2 : DsQuery komutu ile.
1 | DsQuery * -filter "(&(objectCategory=Computer)(objectClass=Person)(sAMAccountName=*)(badPwdCount>=1))" -attr Name dNSHostName Description badPwdCount |

Download Script1: TrustCheckUp1.ps1 scriptini buradan indirebilirsiniz.
Download Script2: TrustcheckUp2.ps1 scriptini buradan indirebilirsiniz.
Referans:
http://siberblog.org/index.php/the-trust-relationship-between-this-domain-and-the-primary-domain-failed/
Awesome blog! Do you have any recommendations for aspiring
YanıtlaSilwriters? I'm planning to start my own blog soon but I'm a little lost on everything.
Would you propose starting with a free platform like Wordpress or go for a paid option?
There are so many options out there that I'm completely confused .. Any suggestions? Thank you!
Good day! This is my 1st comment here so I just wanted to give a quick shout out and tell you I truly enjoy reading through your blog posts.
YanıtlaSilCan you suggest any other blogs/websites/forums that cover the
same topics? Thank you so much!
If you are going for best contents like I do, only visit this website daily as it gives feature
YanıtlaSilcontents, thanks
I do trust all the ideas you have offered to your post.
YanıtlaSilThey're very convincing and can definitely work. Nonetheless, the posts are too short for novices. May you please lengthen them a bit from subsequent time? Thanks for the post.
Every weekend i used to pay a quick visit this website, as i want enjoyment, for the reason that
YanıtlaSilthis this web page conations actually pleasant funny
stuff too.
Hello there, I discovered your website by way of Google at
YanıtlaSilthe same time as searching for a related subject, your site got here
up, it appears to be like great. I have bookmarked it in my google bookmarks.
Hi there, simply turned into alert to your weblog through Google, and located that it
is really informative. I'm gonna watch out for brussels. I will be grateful should you proceed this in future. Many other folks will likely be benefited from your writing. Cheers!
Hi there i am kavin, its my first occasion to commenting anywhere, when i read
YanıtlaSilthis post i thought i could also create comment due to this brilliant
article.
Hi there, after reading this amazing piece of
YanıtlaSilwriting i am also cheerful to share my knowledge here with friends.
My brother recommended I might like this web site. He was
YanıtlaSilentirely right. This post actually made my day. You cann't imagine just how much time I had spent for this information! Thanks!
Very nice blog post. I certainly love this website.
YanıtlaSilKeep it up!
Hello there! This is my first comment here so I just wanted to give a quick shout out and tell you I genuinely enjoy reading through your articles.
YanıtlaSilCan you suggest any other blogs/websites/forums that go over the same subjects?
Thank you!
Nice post. I was checking constantly this blog and I am impressed!
YanıtlaSilExtremely useful info specially the last part :) I care for such information a lot.
I was seeking this particular info for a
very long time. Thank you and good luck.
First off I would like to say superb blog! I had a quick question in which I'd like to ask if you don't mind.
YanıtlaSilI was interested to know how you center yourself and clear your head before writing.
I have had a hard time clearing my mind in getting my ideas out there.
I do enjoy writing however it just seems like the first 10 to 15 minutes are wasted just trying to figure out how
to begin. Any suggestions or tips? Thanks!
I am in fact pleased to glance at this webpage posts which includes
YanıtlaSiltons of useful data, thanks for providing such information.
Way cool! Some very valid points! I appreciate you
YanıtlaSilwriting this article plus the rest of the website is also really good.
Hello there I am so thrilled I found your blog page, I really found you by error, while I was searching on Askjeeve for something else, Nonetheless I am here now and would just like to say kudos for a tremendous post
YanıtlaSiland a all round enjoyable blog (I also love the theme/design), I
don't have time to look over it all at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the excellent job.
Simply wish to say your article is as astonishing.
YanıtlaSilThe clearness on your put up is simply nice and that
i could suppose you are knowledgeable on this subject.
Fine with your permission let me to clutch your RSS feed to keep up
to date with coming near near post. Thanks a million and
please carry on the gratifying work.
Ӏ got this wеb site from mу buddy who tοld me cοncеrning this websіtе anԁ noω thіs time
YanıtlaSilI am visiting thіs web site and reаding very informаtіνe articlеs or rеviews аt this tіmе.
Hi there, this weekend is fastidious in favor of me, as this time i am reading this fantastic informative article here
YanıtlaSilat my house.
Pretty! This was an extremely wonderful post. Thanks for providing this info.
YanıtlaSil