Áramszünet és az ActiveDirectory

Július végén volt egy áramszünet ami két DC-t érintett (szünetmentes nem bírta szusszal). A “PDC”-nek szerencsére nem történt baja, no meg arról van mentés is persze, így elkezdtem kidebugolni a problémát amiből aztán kiesett 2 hiba is.

tl;dr a végén

AD replika hiba

Észlelés

Tünetek az alábbiak voltak:

  • Nem lehetett mindig bejelentkezni egy felhasználóval
  • Nem megbízható kapcsolatot írt a tartománnyal
  • Bejelentkezés még ment de policyket már nem kapta meg.
  • Új gépeket nem lehetett beléptetni (the target account name is incorrect)

Eközben a logokban arra panaszkodott, hogy nem sikerült frissíteni a DNS-ben a bejegyzéseket.

A DNS-rekord (‘455543f8-4b64-4128-9f12-61c1c3705652._msdcs.CONTOSO.local. 600 IN CNAME dc1.CONTOSO.local.’) dinamikus regisztrációja nem sikerült a következő DNS-kiszolgálón:

DNS-kiszolgáló IP-címe: 192.168.65.3
Visszaküldött válaszkód (RCODE): 5
Visszaküldött állapotkód: 9005

Ha a DNS kezelőt megpróbáltam megnynit a 192.168.65.3-on azt mondta, hogy nem létezik illetve ACCESS DENIED.

Ránéztem a replikára a DC1-ről, ott rendben volt, a probléma az EXCALIBUR DC-n volt (többek közt ilyen hibák voltak):

DC=DomainDnsZones,DC=CONTOSO,DC=local
Default-First-Site-Name\DC1 via RPC
DSA object GUID: 455543f8-4b64-4128-9f12-61c1c3705652
Last attempt @ 2020-08-28 17:15:38 failed, result 1908 (0x774):
Could not find the domain controller for this domain.
57 consecutive failure(s).
Last success @ 2020-07-22 18:52:45.

Source: Default-First-Site-Name\DC1
******* 466 CONSECUTIVE FAILURES since 2020-07-22 19:29:34
Last error: 1256 (0x4e8):
The remote system is not available. For information about network tr
oubleshooting, see Windows Help.

Illetve ilyen is (ez már csak az event viewerből van de a repadmin is írta):

Internal event: Active Directory Domain Services could not update the following object with changes received from the following source directory service. This is because an error occurred during the application of the changes to Active Directory Domain Services on the directory service.

Object:
DC=CONTOSO,DC=local
Object GUID:
0f1e7c61-6c89-4d3d-b3a1-1b8aa0dfe827
Source directory service:
455543f8-4b64-4128-9f12-61c1c3705652._msdcs.CONTOSO.local
Synchronization of the directory service with the source directory service is blocked until this update problem is corrected.
This operation will be tried again at the next scheduled replication.
User Action
Restart the local computer if this condition appears to be related to low system resources (for example, low physical or virtual memory).
Additional Data
Error value:
1127 While accessing the hard disk, a disk operation failed even after retries.

repadmin /syncall nem segített, ugyanaz a hiba, egy gyors reboot után mi a helyzet? Induláskor futott egy checkdisk:

Checking file system on C:
The type of the file system is NTFS.

One of your disks needs to be checked for consistency. You
may cancel the disk check, but it is strongly recommended
that you continue.
Windows will now check the disk.

CHKDSK is verifying files (stage 1 of 3)…
Cleaning up instance tags for file 0x175.
Cleaning up instance tags for file 0x7634.
Cleaning up instance tags for file 0x764b.
Cleaning up instance tags for file 0xf491.
Cleaning up instance tags for file 0xfe9d.
Cleaning up instance tags for file 0xfea3.
The attribute of type 0x80 and instance tag 0x0 in file 0x10f60
has allocated length of 0xb77650000 instead of 0xb77640000.
Deleted corrupt attribute list entry
with type code 128 in file 69472.
Unable to locate attribute with instance tag 0x0 and segment
reference 0x2ea7000000004253. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 16979.
Unable to locate attribute with instance tag 0x0 and segment
reference 0xaf1f00000000d9b6. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 55734.
Unable to locate attribute with instance tag 0x0 and segment
reference 0x24f1000000011c24. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 72740.
Unable to locate attribute with instance tag 0x0 and segment
reference 0x1c910000000123b3. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 74675.
Unable to locate attribute with instance tag 0x0 and segment
reference 0x6ed4000000012495. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 74901.
Unable to locate attribute with instance tag 0x0 and segment
reference 0x2271000000012ec1. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 77505.
Unable to locate attribute with instance tag 0x0 and segment
reference 0x1442000000025048. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 151624.
Unable to locate attribute with instance tag 0x0 and segment
reference 0xad900000002509f. The expected attribute type is 0x80.
Deleting corrupt attribute record (128, $J)
from file record segment 151711.
Cleaning up instance tags for file 0x16627.
288768 file records processed. File verification completed.
Deleting orphan file record segment 16979.
Deleting orphan file record segment 55734.
Deleting orphan file record segment 78543.
13117 large file records processed. 0 bad file records processed.
CHKDSK is verifying indexes (stage 2 of 3)…
375066 index entries processed. Index verification completed.
0 unindexed files scanned. 0 unindexed files recovered.
CHKDSK is verifying security descriptors (stage 3 of 3)…
Cleaning up 45 unused index entries from index $SII of file 0x9.
Cleaning up 45 unused index entries from index $SDH of file 0x9.
Cleaning up 45 unused security descriptors.
Security descriptor verification completed.
43150 data files processed. CHKDSK is verifying Usn Journal…
Creating Usn Journal $J data stream
Usn Journal verification completed.
CHKDSK discovered free space marked as allocated in the
master file table (MFT) bitmap.
CHKDSK discovered free space marked as allocated in the volume bitmap.

Windows has made corrections to the file system.
No further action is required.

523926527 KB total disk space.
146761988 KB in 150555 files.
116572 KB in 43151 indexes.
0 KB in bad sectors.
378207 KB in use by the system.
65536 KB occupied by the log file.
376669760 KB available on disk.

4096 bytes in each allocation unit.
130981631 total allocation units on disk.
94167440 allocation units available on disk.

Internal Info:
00 68 04 00 b4 f4 02 00 b7 83 05 00 00 00 00 00 .h…………..
54 02 00 00 de 00 00 00 00 00 00 00 00 00 00 00 T……………
20 03 00 14 e7 00 00 00 00 00 00 00 00 00 00 00 ……………

Windows has finished checking your disk.
Please wait while your computer restarts.

Tehát hibát talált, logban írta is, hogy sérült az AD DB fájl.

This event contains REPAIR PROCEDURES for the 1084 event which has previously been logged. This message indicates a specific issue with the consistency of the Active Directory Domain Services database on this replication destination. A database error occurred while applying replicated changes to the following object. The database had unexpected contents, preventing the change from being made.

Object:
DC=CONTOSO,DC=local
Object GUID:
0f1e7c61-6c89-4d3d-b3a1-1b8aa0dfe827
Source domain controller:
455543f8-4b64-4128-9f12-61c1c3705652._msdcs.CONTOSO.local

User Action

….javításról ír itt, de minket annyira ez nem izgat, van egy ép példányunk

Domain Services Databases.

If none of these actions succeed and the replication error continues, you should demote this domain controller and promote it again.

Additional Data
Primary Error value:
1127 While accessing the hard disk, a disk operation failed even after retries.
Secondary Error value:
-510 JET_errLogWriteFail, Failure writing to log file

Javítás

No de kit érdekel, van egy egészséges DC-nk, synceljük át onnan. Persze ez nyilván nem megy a szinkron “The target principal name is incorrect” hibával megáll. A probléma, hogy túl régen csúszott szét az egész (1 hónap) emiatt a kerberos ticketek is teljesen elmásztak. Kell egy force szinkron(1):

Ehhez először is állítsuk le a “Kerberos Key Distribution Center” szolgáltatást azon a szerveren ahova forceolni akarjuk a szinkront:

net stop kdc

Forceoljunk ki egy configuration szinkront

Replicate configuration from the selected DC

Indítsuk el a korábban leállított “Kerberos Key Distribution Center”-t:

net start kdc

Ezekután remélhetőleg már rendben lesz. Hagyjunk egy kis időt míg mindent rendben leszinkronizál. Közvetlenül utána:

C:\Windows\system32>repadmin /showrepl

Repadmin: running command /showrepl against full DC localhost
Default-First-Site-Name\EXCALIBUR
DSA Options: IS_GC
Site Options: (none)
DSA object GUID: 57e27dc2-70fd-49e2-8c71-702f9f125f22
DSA invocationID: ea8948bc-8291-40c2-b7b4-722497a869f5

==== INBOUND NEIGHBORS ======================================

DC=CONTOSO,DC=local
Default-First-Site-Name\DC1 via RPC
DSA object GUID: 455543f8-4b64-4128-9f12-61c1c3705652
Last attempt @ 2020-08-28 17:42:59 was successful.

CN=Configuration,DC=CONTOSO,DC=local
Default-First-Site-Name\DC1 via RPC
DSA object GUID: 455543f8-4b64-4128-9f12-61c1c3705652
Last attempt @ 2020-08-28 17:21:51 was successful.

CN=Schema,CN=Configuration,DC=CONTOSO,DC=local
Default-First-Site-Name\DC1 via RPC
DSA object GUID: 455543f8-4b64-4128-9f12-61c1c3705652
Last attempt @ 2020-08-28 17:14:37 failed, result 1908 (0x774):
Could not find the domain controller for this domain.
55 consecutive failure(s).
Last success @ 2020-07-22 18:52:45.

DC=DomainDnsZones,DC=CONTOSO,DC=local
Default-First-Site-Name\DC1 via RPC
DSA object GUID: 455543f8-4b64-4128-9f12-61c1c3705652
Last attempt @ 2020-08-28 17:15:38 failed, result 1908 (0x774):
Could not find the domain controller for this domain.
57 consecutive failure(s).
Last success @ 2020-07-22 18:52:45.

DC=ForestDnsZones,DC=CONTOSO,DC=local
Default-First-Site-Name\DC1 via RPC
DSA object GUID: 455543f8-4b64-4128-9f12-61c1c3705652
Last attempt @ 2020-08-28 17:34:45 was successful.

Source: Default-First-Site-Name\DC1
******* 57 CONSECUTIVE FAILURES since 2020-07-22 18:52:45
Last error: 1908 (0x774):
Could not find the domain controller for this domain.

Maximum fél óra után mindent szépen replikál.

DFSR hiba

Ezután szépen be lehetett jelentkezni mindenhova, majd ha nyomtam egy gpupdate-et akkor közölte, hogy sikertelen volt, nem találja a megadott policyt, szerveren event viewerben is látszódott a hiba:

– EventData

SupportInfo1 1
SupportInfo2 4875
ProcessingMode 0
ProcessingTimeInMilliseconds 610
ErrorCode 3
ErrorDescription The system cannot find the path specified.
DCName \\EXCALIBUR.CONTOSO.local
ExtensionName Group Policy Power Options
ExtensionId {E62688F0-25FD-4c90-BFF5-F508B9D2E31F}

Valóban beírva az intézőbe nem találtható a policy, míg a DC1 szerveren igen. Ezzel az a probléma, hogy nagyon régen állt le, amit nem talált policy az valamikor februárban született. Nem tudom, hogy nem derült ez ki korábban, mindenesetre event logban:

The DFS Replication service stopped replication on volume C:. This occurs when a DFSR JET database is not shut down cleanly and Auto Recovery is disabled. To resolve this issue, back up the files in the affected replicated folders, and then use the ResumeReplication WMI method to resume replication.

Additional Information:
Volume: C:
GUID: CA16872C-04BB-11E3-93E8-806E6F6E6963
Recovery Steps
1. Back up the files in all replicated folders on the volume. Failure to do so may result in data loss due to unexpected conflict resolution during the recovery of the replicated folders.
2. To resume the replication for this volume, use the WMI method ResumeReplication of the DfsrVolumeConfig class. For example, from an elevated command prompt, type the following command:
wmic /namespace:\\root\microsoftdfs path dfsrVolumeConfig where volumeGuid=”CA16872C-04BB-11E3-93E8-806E6F6E6963″ call ResumeReplication

For more information, see http://support.microsoft.com/kb/2663685.

Tehát ott is van mit kell csinálni, gyors backup mindkét DC-n (sima fájlmásolás) a c:\windows\SYSVOL\domain könyvtárról majd futtatni a

wmic /namespace:\\root\microsoftdfs path dfsrVolumeConfig where volumeGuid=”CA16872C-04BB-11E3-93E8-806E6F6E6963″ call ResumeReplication

Ha szerencsések vagyunk ennyi elég is, miután nekem nagyon régen szétcsúszott ezért az alábbi hibaüzenetet dobta:

The DFS Replication service stopped replication on the folder with the following local path: C:\Windows\SYSVOL\domain. This server has been disconnected from other partners for 267 days, which is longer than the time allowed by the MaxOfflineTimeInDays parameter (60). DFS Replication considers the data in this folder to be stale, and this server will not replicate the folder until this error is corrected.

To resume replication of this folder, use the DFS Management snap-in to remove this server from the replication group, and then add it back to the group. This causes the server to perform an initial synchronization task, which replaces the stale data with fresh data from other members of the replication group.

Additional Information:
Error: 9061 (The replicated folder has been offline for too long.)
Replicated Folder Name: SYSVOL Share
Replicated Folder ID: 6E031177-CEA1-49CC-97BD-7E20A2DEFA70
Replication Group Name: Domain System Volume
Replication Group ID: 2AB23F75-C70A-45F4-BE47-43BFCC8F2FDA
Member ID: A9B0D353-863C-4E4E-A325-06E072CA5F3F

267 nap. Az szép eset. Főleg, hogy fel sem tűnt. Annyi baj legyen kellene egy force szinkron.

Non-authoritive és authoritive szinkron

Két lehetőségünk van non-authoritive szinkront csinálni, ez ilyen kb. automata, kitalálja, hogy mi a jó nekünk, ezt akkor játszhatjuk meg ha több mint 2 DC-nk van és több mint a DC-k 50% rendben van(2). Az, hogy mi van rendben azt alábbival ellenőrízhetjük:

for /f %i IN (‘dsquery server -o rdn’) do @echo %i && @wmic /node:”%i” /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo WHERE replicatedfoldername=’SYSVOL share’ get replicationgroupname,replicatedfoldername,state

Egy ilyen például nem jó:

EXCALIBUR
No Instance(s) Available.
DC1
ReplicatedFolderName  ReplicationGroupName  State
SYSVOL Share          Domain System Volume  2

Nekem nincs meg legalább az 50+1 % így marad az authoritive szinkron, nagy eltérés nincs a kettő közt amúgy, egy attribútum érték. Mi a nagyjábóli menet?

Non authoritive esetében:

  1. Kivenni a rossz szervert a replikációból
  2. Frissíteni a DFS szinkronizálást AD-ból
  3. Visszarakni a rossz szervert a replikából
  4. Frissíteni a DFS szinkronizálást AD-ból

Authoritive esetében:

  1. Leállítani a DFS replikációkat
  2. Leállíteni mindenhol a replikációt és kinevezni egy “master”-t
  3. “master”-en elindulhat a DFS replikáció
  4. Visszarakni a “master”-t
  5. Frissíteni a DFS szinkronizálást AD-ból a masteren
  6. Mindenhol másutt elindítható a DFS replikáció
  7. Visszarakni a többi szervert is
  8. Frissíteni a DFS szinkronizálást AD-ból

Authoritive akkor, hogyan is néz ki pontosan:

Állítsuk le a DFS replikációt mindenhol

net stop dfsr

Nyissunk meg egy ADSI editort és módosítsuk az alábbit(egyszerűség kedvéért érdemes ezt a kiszemelt masteren csinálni):

CN=SYSVOL Subscription,CN=Domain System Volume,CN=DFSR-LocalSettings,CN=<amelyik a master lesz>,OU=Domain Controllers,DC=<domain>

Két attribútumot írjunk át:

msDFSR-Enabled=FALSE
msDFSR-options=1

Ezzel letiltottuk a szinkront és kineveztük masternek.ADSI editorban kb. így néz ki

Az összes többi szerveren a Domain Controllers alatt állítsuk át az

msDFSR-Enabled=FALSE

attribútumot.

Replikáljuk le a módosítást(én ezt a másik szerveren nyomtam, nem ahol az ADSI editor futott, de lényegtelen, úgyis ellenőrízzük ezután):

repadmin /syncall /AdP

A masteren elindulhat a DFSR replikációs szolgáltatás:

net start dfsr

Event viewer nyissuk meg a masteren és az “Applications és Services Logs” alatt a “DFS replication” alatt nézzük a 4114-es számú bejegyzést ahol jó esetben ilyet kell lássunk:

The replicated folder at local path C:\Windows\SYSVOL\domain has been disabled. The replicated folder will not participate in replication until it is enabled. All data in the replicated folder will be treated as pre-existing data when this replicated folder is enabled.

Engedjük vissza az ADSI-ban a masternek a replikálást:

msDFSR-Enabled=TRUE

Nyomjunk egy címtár replikát:

repadmin /syncall /AdP

A masteren pedig egy DFSR szinkront a címtárból:

dfsrdiag PollAD

Eventviewerben keressük az előző helyen a 4602-es bejegyzést, hogy sikeresen inicializálta a DFS-t  és, hogy ő a master (ez most csak magyarul van meg):

Az elosztott fájlrendszer replikációs szolgáltatása sikeresen inicializálta a(z) C:\Windows\SYSVOL\domain  helyi elérési úton található SYSVOL replikált mappát. Ez a tag a replikált mappa  kijelölt elsődleges tagja. Felhasználói művelet nem szükséges.  A SYSVOL megosztás meglétének ellenőrzéséhez nyisson egy parancssori ablakot,  és írja be a “net share” parancsot.

Ezekután az összes többi DC-n indítható a DFSR

net start dfsr

majd az ADSI editorban nyomhatjuk a

msDFSR-Enabled=TRUE

attribútumot utána pedig olvassuk ki a címtárból a konfigot:

dfsrdiag /pollad

Lessük az eventviewer a 4614-es bejegyzés után:

The DFS Replication service initialized SYSVOL at local path C:\Windows\SYSVOL\domain and is waiting to perform initial replication…..

Amit követni fog egy rakat 4414-es:

The DFS Replication service detected that a file was changed on multiple servers…..

Majd zárásképpen egy 4604-es

The DFS Replication service successfully initialized the SYSVOL replicated folder at local path C:\Windows\SYSVOL\domain. This member has completed initial synchronization of SYSVOL with partner dc1.CONTOSO.local.  To check for the presence of the SYSVOL share, open a command prompt window and then type “net share”.

Valóban, mostmár mindenhol minden policy megtalálható.

Már csak egy jó monitoringot kell erre a DFSR-re kitalálni.

tl;dr

Google huszároknak :p

Nem megy az AD replika a következő hibával: The target principal name is incorrect

Megoldás: net stop kdc, repadmin /syncall, net start kdc

Nem megy DFSR SYSVOL

Megoldás: non-authoritive vagy authoritive szinkron, ehhez fentebb a leírás

Megjegyzés – 2021.03.26

Újfent előjött a DFS szinkronizációs probléma, mindkét fél szinkronizációs állapota 2-es state kóddal volt (initial sync). Szemmel láthatóan bizonyos újabb GPO-k hiányoztak is az egyik oldalról. Szerencsére GPO módosítás csak az egyik DC-n történik, így nem kellett összefésülni őket. Egy sima non-authoritive szinkron után mindkét oldalon megvoltak az objectek de a master kivételéve az összes többi (1 db) replika maradt 2-es state-ben.

Ilyenkor segítséget adhat a Group Policy Management ->Domain -><domainünk neve>-re ha rákattintunk majd jobb alsó sarokban Detect Now:

SYSVOL DFS Status

SYSVOL DFS status

Ha van hibánk akkor ki fogja írni felülre. Ide írta nekem, hogy az egyik GPO ACL-je nem egyezik mindenhol. Megnézve senkinek nem volt hozzáférése a fájlhoz. Módosítottam mindenhol kézzel (vagy minden replikán letörölni, masteren korrigálni, majd mehet egy (non-)authoritive sync.

Ezután minden SYSVOL DFS Group stateje négyes kódot kapott (normal).

This entry was posted in ActiveDirectory, Szerver felgyelet, Uncategorized, Windows and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *