20 Ekim 2012 Cumartesi

Analysis "The trust relationship between this domain and the primary domain failed"

"The trust relationship between this domain and the primary domain failed"

"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.











1Import-Module ActiveDirectory
2Get-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 4769Etki 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.











1Import-Module ActiveDirectory
2Get-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.











1Import-Module ActiveDirectory
2Get-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.











1Import-Module activedirectory
2Get-ADComputer -Filter * -Properties Name, Description, badPwdCount, LastLogonDate, PasswordLastSet | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet



Script Code2 : DsQuery komutu ile.







1DsQuery * -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.











1Import-Module activedirectory
2Get-ADComputer -LDAPFilter "(badPwdCount>=1)" -Properties Name, Description, badPwdCount, LastLogonDate, PasswordLastSet | FT Name, Description, badPwdCount, LastLogonDate, PasswordLastSet



Script Code2 : DsQuery komutu ile.







1DsQuery -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/

20 yorum:

  1. Awesome blog! Do you have any recommendations for aspiring
    writers? 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!

    YanıtlaSil
  2. how to improve eyesight20 Mart 2013 05:51

    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.
    Can you suggest any other blogs/websites/forums that cover the
    same topics? Thank you so much!

    YanıtlaSil
  3. how to get back your ex24 Mart 2013 12:01

    If you are going for best contents like I do, only visit this website daily as it gives feature
    contents, thanks

    YanıtlaSil
  4. Tattoos Removed25 Mart 2013 07:07

    I do trust all the ideas you have offered to your post.
    They'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.

    YanıtlaSil
  5. lose fat in 2 weeks25 Mart 2013 18:33

    Every weekend i used to pay a quick visit this website, as i want enjoyment, for the reason that
    this this web page conations actually pleasant funny
    stuff too.

    YanıtlaSil
  6. world of tanks Hack26 Mart 2013 23:13

    Hello there, I discovered your website by way of Google at
    the 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!

    YanıtlaSil
  7. natural breast enlargement30 Mart 2013 14:51

    Hi there i am kavin, its my first occasion to commenting anywhere, when i read
    this post i thought i could also create comment due to this brilliant
    article.

    YanıtlaSil
  8. coconut oil for hair31 Mart 2013 12:57

    Hi there, after reading this amazing piece of
    writing i am also cheerful to share my knowledge here with friends.

    YanıtlaSil
  9. My brother recommended I might like this web site. He was
    entirely right. This post actually made my day. You cann't imagine just how much time I had spent for this information! Thanks!

    YanıtlaSil
  10. Very nice blog post. I certainly love this website.
    Keep it up!

    YanıtlaSil
  11. 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.
    Can you suggest any other blogs/websites/forums that go over the same subjects?

    Thank you!

    YanıtlaSil
  12. Nice post. I was checking constantly this blog and I am impressed!

    Extremely 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.

    YanıtlaSil
  13. Women designer clothing25 Nisan 2013 04:04

    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.
    I 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!

    YanıtlaSil
  14. download 7zip1 Mayıs 2013 18:29

    I am in fact pleased to glance at this webpage posts which includes
    tons of useful data, thanks for providing such information.

    YanıtlaSil
  15. microsoftpointss1 Mayıs 2013 20:07

    Way cool! Some very valid points! I appreciate you
    writing this article plus the rest of the website is also really good.

    YanıtlaSil
  16. Wedding Dress accessories2 Mayıs 2013 03:18

    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
    and 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.

    YanıtlaSil
  17. Bestcoconutoilforhair4 Mayıs 2013 06:24

    Simply wish to say your article is as astonishing.
    The 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.

    YanıtlaSil
  18. Ӏ got this wеb site from mу buddy who tοld me cοncеrning this websіtе anԁ noω thіs time
    I am visiting thіs web site and reаding very informаtіνe articlеs or rеviews аt this tіmе.

    YanıtlaSil
  19. diaperrashhomeremedies4 Mayıs 2013 19:22

    Hi there, this weekend is fastidious in favor of me, as this time i am reading this fantastic informative article here
    at my house.

    YanıtlaSil
  20. Pretty! This was an extremely wonderful post. Thanks for providing this info.

    YanıtlaSil