+
    4SsiJ                       ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RIH
t
 ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHtHt ^ RIHtHt ^ RIHt ^ RIHt ^ RIHtHtH t H!t! R t" ! R R]#4      t$R# )    N)	b64decode	b64encode)dsdb)common)misc)drsuapi)
ndr_unpackndr_pack)drsblobs)dsdb_Dn)security)get_wellknown_sdsget_deletedobjects_descriptorget_diff_sds)system_sessionadmin_session)CommandError)get_fsmo_roleowner)c_REDc_DARK_YELLOWc_DARK_CYANc_DARK_GREENc                    . pV  F$  p VP                  VP                  R4      4       K&  	  RP	                  V4      #   \         d    TP                  \        T4      4        Ka  i ; i)zStringify a value list, using utf-8 if possible (which some tests
want), or the python bytes representation otherwise (with leading
'b' and escapes like b' ').
zutf-8,)appenddecodeUnicodeDecodeErrorreprjoin)valsresultvalues   &  1/usr/lib/python3/dist-packages/samba/dbchecker.pydump_attr_valuesr$   *   s_    
 F	'MM%,,w/0 
 88F " 	'MM$u+&	's    >%A'&A'c                     a  ] tR t^8t o Rt/ tRMR ltR tR]P                  RR3R lt
R tR tRNR ltR	 tR
 tROR ltR tR tR tR tR tR tR tR tRPR ltR tR tR tR tR tR tR t R t!R t"R t#ROR lt$R  t%R! t&R" t'R# t(R$ t)R% t*R& t+R' t,R( t-R) t.R* t/R+ t0R, t1R- t2R. t3R/ t4R0 t5R1 t6R2 t7R3 t8R4 t9R5 t:R6 t;R7 t<R8 t=R9 t>R: t?R; t@R< tAR= tBR> tCR? tDR@ tERA tFRB tGRC tHRD tIRE tJRF tKRG tLRQRH ltMRI tNRJ tORK tPRLtQV tRR# )Rdbcheckzcheck a SAM database for errorsNc           
        Wn         R V n        T;'       g    TV n        W0n        W@n        WPn        W`n        Wn        RV n        RV n	        RV n
        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        RV n        \7        4       V n        RV n        RV n        RV n        RV n         RV n!        RV n"        RV n#        RV n$        RV n%        RV n&        RV n'        RV n(        RV n)        RV n*        RV n+        RV n,        RV n-        Wn.        Wn/        Wn0        ^ V n1        RV n2        Wpn3        \h        Pj                  ! VRVPm                  4       ,           4      V n7        \h        Pj                  ! VRVPq                  4       ,          4      V n9        VPu                  4       V n;        \h        Pj                  ! VRVPm                  4       ,           4      V n<        \h        Pj                  ! WP{                  4       4      V n>        / V n?        \        V P                   4      V nA        RV nB        RV nC        RV nD        RV nE        RV nF        \        4       V nH        / V nI        / V nJ         RV P                  VP                  4       \        P                  4      ,          pVP                  V\h        P                  R.R7      p\        \        P                  V^ ,          R,          ^ ,          4      p\        V4      V P                  R&   \        4       V nY        \        R VP                  4       4      V n\        V P                   P                  V P|                  \h        P                  R	R
.R7      pR	V^ ,          9   d   V^ ,          R	,          V n]        M+R
V^ ,          9   d   V^ ,          R
,          V n]        MR V n]        V P                   P                  R\h        P                  R.R7      p. V n^        . V n_        . V n`         V^ ,          R,          V na        V P                   Fm  p V P                  \h        Pj                  ! V P                   VP                  R4      4      \        P                  4      pV P                  P                  V4       Ko  	  RV P                   P                  4       ,          pRV P                   P                  4       ,          pV P                   P                  \h        P                  RR.V P                   P                  4       RV,          R7      p\        V4      ^8X  dD   V P                  P                  \h        Pj                  ! V P                   V4      V^ ,          34       V P                   P                  \h        P                  RR.V P                   P                  4       RV,          R7      p\        V4      ^8X  dD   V P                  P                  \h        Pj                  ! V P                   V4      V^ ,          34       \h        Pj                  ! V P                   RV P                   Pm                  4       ,           4      p\        V P                   VR4      p\h        Pj                  ! V P                   V P                   P{                  4       4      V8X  d	   RV nl        MRV nl        V P                   P                  \h        Pj                  ! V P                   V P                   P                  4       4      \h        P                  R.R7      p\h        Pj                  ! V P                   V^ ,          R,          ^ ,          P                  R4      4      V nn        V P                   P                  V P                  \h        P                  R.R7      pRV^ ,          9   dL   \h        Pj                  ! V P                   V^ ,          R,          ^ ,          P                  R4      4      V no        MR V no        RV P                   Pq                  4       P                  4       ,          pVP                  V\h        P                  RR.R7      pRV^ ,          9   d'   \        V^ ,          R,          ^ ,          4      V nr        M^V nr        . V ns        . V nt         V P                   P                  \h        P                  RRR.R7      pRV^ ,          9   d   V^ ,          R,          V ns        RV^ ,          9   d   V^ ,          R,          V nt        R # R #   \h        P                   d1   pTP                  w  ppT\h        P                  8w  d   h  R p?ELLR p?ii ; i  \         d     ELU\         d     ELbi ; i  \         dO    T P                  P                  \h        Pj                  ! T P                   TP                  R4      4      4        EK  i ; i  \h        P                   d1   pTP                  w  ppT\h        P                  8w  d   h  R p?R # R p?ii ; i) NFzCN=Infrastructure,zCN=Partitions,%szCN=RID Manager$,CN=System,zCN=DnsAdmins,%s	objectSidbasescopeattrs	DnsAdminszmsDS-hasMasterNCshasMasterNCs namingContextsutf8zDC=DomainDnsZones,%szDC=ForestDnsZones,%smsDS-NC-Replica-LocationsmsDS-NC-RO-Replica-Locationsz$(&(objectClass=crossRef)(ncName=%s)))r+   r,   r*   
expressionridTserverReferencerIDSetReferencesz1CN=Directory Service,CN=Windows NT,CN=Services,%sz(objectClass=nTDSService)tombstoneLifetime)r*   r+   r4   r,   z@SAMBA_DSDBcompatibleFeaturesrequiredFeatures)r+   r*   r,   )usamdbdict_oid_namesamdb_schemaverbosefixyesquietcolourremove_all_unknown_attributesremove_all_empty_attributesfix_all_normalisationfix_all_duplicatesfix_all_DN_GUIDsfix_all_binary_dn#remove_implausible_deleted_DN_links!remove_plausible_deleted_DN_links$fix_all_string_dn_component_mismatch"fix_all_GUID_dn_component_mismatch!fix_all_SID_dn_component_mismatch fix_all_SID_dn_component_missing(fix_all_old_dn_string_component_mismatchfix_all_metadatafix_time_metadatafix_undead_linked_attributesfix_all_missing_backlinksfix_all_orphaned_backlinksfix_all_missing_forward_linksdictduplicate_link_cacherecover_all_forward_linksfix_rmd_flagsfix_ntsecuritydescriptor$fix_ntsecuritydescriptor_owner_groupseize_fsmo_rolemove_to_lost_and_foundfix_instancetype"fix_replmetadata_zero_invocationid fix_replmetadata_duplicate_attidfix_replmetadata_wrong_attidfix_replmetadata_unsorted_attidfix_deleted_deleted_objectsfix_dnfix_base64_userparametersfix_utf8_userparametersfix_doubled_userparametersfix_sid_rid_set_conflictquick_membership_checksreset_well_known_aclscheck_expired_tombstonesexpired_tombstonesreset_all_well_known_aclsin_transactionldbDn	domain_dninfrastructure_dnget_config_basedn	naming_dnget_schema_basedn	schema_dnrid_dnget_dsServiceNamentds_dsaclass_schemaIDGUIDr   wellknown_sdsfix_all_missing_objectclassfix_missing_deleted_objectsfix_replica_locationsfix_missing_rid_set_masterfix_changes_after_deletion_bugsetdn_setlink_id_cachename_mapget_wellknown_dn_cachedget_default_basednr   DS_GUID_USERS_CONTAINERsearch
SCOPE_BASEr	   r   dom_sidstrLdbErrorargsERR_NO_SUCH_OBJECTr   system_session_infor   get_domain_sidadmin_session_info	write_ncsdeleted_objects_containersncs_lacking_deleted_containersdns_partitionsncsKeyError
IndexErrorr   !DS_GUID_DELETED_OBJECTS_CONTAINERr   get_root_basednSCOPE_ONELEVELget_partitions_dnlenr   is_rid_masterget_serverNameserver_ref_dn
rid_set_dnget_linearizedintr8   r9   r:   )selfr;   r=   r>   r?   r@   rA   rn   ri   rj   rk   rB   base_dnresdnsadmins_side5enumestrncdndomaindns_zoneforestdns_zonedomainforestfsmo_dn
rid_masterntds_service_dne6s   &&&&&&&&&&&&                r#   __init__dbcheck.__init__=   s    
!)22U
-2*+0(%*""' %!&38016.49127/16.05-8=5 %!&,1)).&*/'-2*$(F!).&"(-%491$&+# %27/05-,1)/4,+0().&',$*/'(-%'>$%:"(@%"#).&,!$/CeooFW/W!X'9E<S<S<U'UV002ffU$@5??CT$TUu&=&=&?@"$.tzz:+0(+0(%*"*/'.3+e	'$*F*F((*,,+. .G ,,G3>>&1]  4C&x'7'7Q9LQ9OPM),]);DMM+& $2#3 "/e6J6J6L"MjjT]]#..QdftPuv#a&( V$78DN Q'!$Q!7!%jjRs~~FVEWX*,'.0+ 	1v./DH ((Bb11#&&RYYvEV2W262X2XZ//66r:	  0$**2O2O2QQ/$**2L2L2NN""););*EGe)f(,

(D(D(F.TWe.e # g v;!&&tzz>(JFSTI'VW""););*EGe)f(,

(D(D(F.TWe.e # g v;!&&tzz>(JFSTI'VW&&%ADJJDXDXDZ%Z['

GUC
66$**djj::<=K!%D!&D jjSVVDJJ

8Q8Q8S%T&)nn=N<O   Q !VVDJJA7H0I!0L0S0STZ0[\ jjT%7%7&)nn=O<P   RQ'!ffTZZQ8J1KA1N1U1UV\1]^DO"DOM**668GGIJll!$&A"5!6  8 #a&(%(Q0C)DQ)G%HD"%(D""$ "	**###..)6+?+=+? $ @C $s1v-*-a&1E*F'!SV+(+A/A(B% ,G || 	77LT4s--- .	6  	 		  b33::366$**biiX^N_;`aab@ || 	77LT4s--- .	sd   !Be 8f A)f3A4h f!%fff0"f0+f0/f03Ahhi$%iic                >   V P                   P                  \        V4      4      pR pVe   VP                  V4      pVf^   V P                  P	                  W4      pVf   V# Vf5   / V P                   \        V4      &   V P                   \        V4      ,          pWCV&   V# N)hash_well_knowngetr   r;   get_wellknown_dn)r   nc_rootwkguidh_ncr   s   &&&  r#   r   dbcheck.get_wellknown_dn_cached   s    ##''G5&!B:,,W=Bz	|57$$S\2++CL9L	    c                R   V P                   P                  WR.VR7      pV P                  R\        V4      ,          4       ^ p^ V n        W`P                  4       ,          p\        4       V n        V FT  pV P                  P                  \        VP                  4      4       W`P                  VP                  VR7      ,          pKV  	  Vf   W`P                  4       ,          pV P                  ^ 8  d#   V P                  RV P                  ,          4       V P                  R\        V4      W`P                  ,           3,          4       V P                  ^ 8w  d    V P                  RV P                   R24       V^ 8w  d(   V P                  '       g   V P                  R	V R
24       V# )z>perform a database check, returning the number of errors foundr   r*   r+   r,   controlszChecking %u objects)requested_attrszNOTICE: found %d expired tombstones, 'samba' will remove them daily, 'samba-tool domain tombstones expunge' would do that immediately.zChecked %u objects (%u errors)z	WARNING: z/ of these errors cannot be automatically fixed.z-Please use 'samba-tool dbcheck --fix' to fix z errors)r;   r   reportr   unfixable_errors check_deleted_objects_containersr   attribute_or_class_idsr   addr   r   check_objectcheck_rootdserl   r?   )r   DNr+   r   r,   r   error_countobjects   &&&&&   r#   check_databasedbcheck.check_database  s|    jjRTFXV)CH45 !<<>>&)e#FKKOOC		N+,,VYY,NNK  :--//K""Q&KK 5 //	1 2 	4X{-B-BBCD 	E   A%KK)D$9$9#: ;I I J !DHHHKKG&-w0 1 r   c           
     	   ^ pV P                    EF.  pW P                  8X  d   K  V^,          pV P                  RV,          4       V P                  RV,          R4      '       g   KX  \        P
                  ! V P                  R4      pVP                  V4       Rp V P                  P                  V\        P                  . . R!OR7      p\        V4      ^ 8w  dy   V^ ,          P                  P                  R4      p\        P
                  ! V P                  R\        \        P                  ! V4      4      ,          4      pVP                  V4       Te     T P                  P'                  Y4. R"O4       T P                  P                  T\        P                  R.. R#OR7      p\        T4      ^8w  d   T P                  RT,          4        ^# T^ ,          R,          p. pRpT F  p\)        T P                  TP+                  R4      \,        P.                  4      pT P1                  T4      '       d4   T P                  RT,          4       TP                  P                  R4      pTP3                  \        T4      4       K  	  Te(   R\        \        P                  ! T4      4      ,          pM1R\,        P4                  ,          pTP3                  T: RT: 24       Rp\6        P8                  ! T P                  P;                  4       4      p\=        TT P>                  R7      p\A        T4      P+                  R4      pT P                  PC                  RT: RT: RT: 2R
R.R7       \        PD                  ! 4       p\        P
                  ! T P                  \        T^ ,          R,          4      4      Tn        \        PF                  ! T\        PH                  R4      TR&   T PK                  TR
.RT,          RR7      '       d   T P                  R T,          4       T PL                  P3                  T4       EK1  	  V#   \        P                    dN   pTP"                  w  rT\        P$                  8X  d    Rp?EL/T P                  R	T	,          4        Rp? ^# Rp?ii ; i  \        P                    d8   p
T
P"                  w  rT P                  RT: RT: RT	: 24        Rp
?
 ^# Rp
?
ii ; i)$zXThis function only fixes conflicts on the Deleted Objects
containers, not the attributesz=ERROR: NC %s lacks a reference to a Deleted Objects containerz-Fix missing Deleted Objects container for %s?r}   zCN=Deleted ObjectsNr   GUIDzCN=Deleted Objects\0ACNF:%sz<Couldn't check for conflicting Deleted Objects container: %srelax:0z/Couldn't move old Deleted Objects placeholder:  to z: wellKnownObjectsz(wellKnownObjects was not found for NC %sr1   z7wellKnownObjects had duplicate Deleted Objects value %sz
objectGUID: %szB:32:%s:r/   r   dn: z
objectClass: top
objectClass: container
description: Container for deleted objects
isDeleted: TRUE
isCriticalSystemObject: TRUE
showInAdvancedViewOnly: TRUE
nTSecurityDescriptor:: z
systemFlags: -1946157056provision:0r   r   z"NC %s lacks Deleted Objects WKGUIDFvalidatezAdded %s well known guid link)show_deleted:1extended_dn:1:1show_recycled:1reveal_internals:0)r   r   r   )r   extended_dn:0r   r   )'r   rv   r   confirm_allro   rp   r;   add_baser   r   r   r   get_extended_componentr   r   r   r   r   r   renamer   r   r   DSDB_SYNTAX_BINARY_DNis_deleted_objects_dnr   r   r   r   r   r   r   r   add_ldifMessageMessageElementFLAG_MOD_REPLACE	do_modifyr   )r   r   r   r   conflict_dnr   guide2r   r   e1wkolistwkoproposed_objectguidodsdb_dnguid_suffix
wko_prefix
domain_sidsec_descsec_desc_b64deltas   &                     r#   r   (dbcheck.check_deleted_objects_containers.  s    55B^^#1KKKWZ\\]##$SWY$Z\yzz

$89BKKOKjj''Rs~~R2[ ( \ s8q=q699;;FCD"%&&)G#diiX\oJ^)^#`K((, &JJ%%b7gh **##3>>+=*>.W $ XC 3x1}FKL a&+,CG"&!$**ahhv.>@Z@Z[--g66KK Y\] ]^ +2***K*KF*S's1v&  #.03tyyAT7U3VV&)O)OO
*b9:  "))$***C*C*EFJ4Z>BmmMH$X.55f=L JJ "$\;!@ +4])C   	E KKMEvvdjj#c!fTl*;<EH(+(:(:7;>;O;O;M)OE$%
 ~~ei[BRG',  . . ;b@A++2226G 6J ] << !ww3111KK ^ae ef || #%77LTKKaceprv wxs7   B7QR)R&#R!R!!R&)S5>+S00S5c                   V P                   '       d   R# V P                  '       Ed&   VP                  R4      '       d   \        R4      VR,          ,           pMVP                  R4      '       d   \	        R4      VR,          ,           pMVP                  R4      '       d   \        R4      VR,          ,           pMVP                  R4      '       d   \        R4      VR	,          ,           pMaVP                  R
4      '       d   \        R
4      VR,          ,           pM0VP                  R4      '       d   \        R4      VR,          ,           p\        V4       R# )z#print a message unless quiet is setNERROR:   NNWARNING:   NNINFO:   NNNOTICE:   NNNOTESKIPPING:   NN)rA   rB   
startswithr   r   r   r   print)r   msgs   &&r#   r   dbcheck.report  s    :::;;;~~g&&Gns2w.	**#I.R8''!&)CG3))!(+c"g5''!&)CG3
++":.R8c
r   c                    V P                   '       g   R# V P                  '       d   V P                  # V P                  '       d   Rp\        P                  ! WVR7      # )zconfirm a changeFTforced	allow_all)r?   rA   r@   r   confirm)r   r  r  r  s   &&&&r#   r  dbcheck.confirm  s?    xxx:::88O888F~~cIFFr   c                <   V P                   '       g   R# \        W4      R8X  d   R# \        W4      R8X  d   RpMV P                  pV P                  '       d   V# \        P
                  ! WRR7      pVR8X  d   \        WR4       R# VR8X  d   \        WR4       R# V# )z(confirm a change with support for "all" FNONEALLTr  )r?   getattrr@   rA   r   r  setattr)r   r  all_attrr  cs   &&&  r#   r   dbcheck.confirm_all  s    xxx4"f,4"e+FXXF:::MNN3>:DE*;DF+r   c                |   V P                   '       d   V P                  RV,          4        VR\        P                  ,          .,           pV P                  P                  WR7       R#   \         dH   pT P                  '       d   \        T: RT: 24      hT P                  T: RT: 24        Rp?R# Rp?ii ; i)z&delete dn with optional verbose outputzdelete DN %slocal_oid:%s:0r    : NFT)	r>   r   r   DSDB_CONTROL_DBCHECKr;   delete	Exceptionrn   r   )r   r   r   r  errs   &&&& r#   	do_deletedbcheck.do_delete  s    <<<KK+,	#3d6O6O#O"PPHJJb4   	""""S#9::KKS#./		s   ;A) )B;4<B66B;c                   VR\         P                  ,          .,           pV P                  '       dR   V P                  V P                  P                  V\        P                  4      4       V P                  RV,          4        V P                  P                  WVR7       R#   \         dH   pT P                  '       d   \        T: RT: 24      hT P                  T: RT: 24        Rp?R# Rp?ii ; i)z-perform a modify with optional verbose outputr  zcontrols: %r)r   r   r  NFT)r   r  r>   r   r;   
write_ldifro   CHANGETYPE_MODIFYmodifyr   rn   r   )r   mr   r  r   r!  s   &&&&& r#   r   dbcheck.do_modify  s    /$2K2KKLL<<<KK

--a1F1FGHKK12	JJaXF   	""""S#9::KKS#./		s   B# #C5.<C00C5c           
        V P                   '       d9   V P                  R\        V4      : R\        V4      : R\        V4      : 24        W#,           pVR\        P                  ,          .,           pV P
                  P                  WVR7       R	#   \         dH   pT P                  '       d   \        T: RT: 24      hT P                  T: RT: 24        Rp?R# Rp?ii ; i)
z-perform a rename with optional verbose outputr   z
changeType: modrdn
newrdn: z
deleteOldRdn: 1
newSuperior: r  r   r  NFT)
r>   r   r   r   r  r;   r   r   rn   r   )r   from_dnto_rdnto_baser   r  to_dnr!  s   &&&&&&  r#   	do_renamedbcheck.do_rename  s    <<<KK 'lCKW	? @
	$E#3d6O6O#O"PPHJJgx@   	""""S#9::KKS#./		s   AB C$<CC$c                    WP                   9   d   V P                   V,          # V P                  P                  V4      pV'       d   V P                  P                  V4      pMR pW#3V P                   V&   W#3# r   )r   r=   get_linkId_from_lDAPDisplayName!get_backlink_from_lDAPDisplayName)r   attrnamelinkIDrevnames   &&  r#    get_attr_linkID_and_reverse_name(dbcheck.get_attr_linkID_and_reverse_name  sn    )))%%h//""BB8L''II(SGG(.'88$r   c                   V P                  RV: RV: 24       V P                  RV: RV: R2R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pWn        \        P
                  ! R	\        P                  V4      W2&   V P                  VR
R.RV,          RR7      '       d   V P                  RV,          4       R# R# )zfix empty attributeszERROR: Empty attribute  in zRemove empty attribute  from ?rD   zNot fixing empty attribute %sNr/   r   r   z#Failed to remove empty attribute %sFr   zRemoved empty attribute %s)r   r   ro   r   r   r   FLAG_MOD_DELETEr   )r   r   r4  r(  s   &&& r#   err_empty_attributedbcheck.err_empty_attribute	  s    2FGRT UWtuuKK7(BCKKM((S-@-@(K>>!i):;?(JUZ  \ \KK4x?@\r   c                   V P                  RV: RV: 24       . pV F  pV P                  P                  V P                  W%.4      p\	        V4      ^8w  d.   V P                  RV,          4       VP                  VR34       Kg  V^ ,          V8w  g   Kw  V P                  RV: RV^ ,          : R24       VP                  WV^ ,          34       K  	  V P                  RV: R	V: R
2R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pWn	        \        ^ \	        V4      4       Fv  pWH,          w  rY\        P                  ! V\        P                  V4      VRV,          &   V	R8w  g   KF  \        P                  ! V	\        P                  V4      VRV,          &   Kx  	  V P                  VRR.RV,          RR7      '       d   V P                  RV,          4       R# R# )z?fix attribute normalisation errors, without altering sort orderz)ERROR: Normalisation error for attribute r:  zUnable to normalise value '%s'r/   zvalue 'z' should be ''zFix normalisation for r;  r<  rE   zNot fixing attribute %sNzvalue_%uznormv_%ur   r    Failed to normalise attribute %sFr   Normalised attribute %s)r   r;   dsdb_normalise_attributesr=   r   r   r   ro   r   r   ranger   r=  FLAG_MOD_ADDr   )
r   r   r4  valuesmod_listval
normalisedr(  invals
   &&&&      r#   err_normalise_mismatchdbcheck.err_normalise_mismatch  s   8UWXYC==!!8U4J:!#<sBCb	*Q-3&3
1NOm 45  xQS TVmnnKK1H<=KKMq#h-(A"+KS # 2 238K8KX VAj1nrz$'$6$6tS=M=M7?%A*q.!	 ) >>!i):;<xG#(  * * KK1H<=*r   c                h   V P                   P                  V P                  W#4      p\        V4      V8X  d   R# V P	                  RV: RV: R24       V P	                  RV: R\        V4      : R24       V P                  RV: R	V: R
2R4      '       g   V P	                  RV,          4       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      WR&   V P                  VRR.RV,          RR7      '       d   V P	                  RV,          4       R# R# )z.fix attribute normalisation and/or sort errorsNz*ERROR: Normalisation error for attribute '' in 'rA  z*Values/Order of values do/does not match: /!zFix normalisation for '' from ''?rE   Not fixing attribute '%s'r   r   rB  Fr   rC  )r;   rD  r=   listr   r   ro   r   r   r   r   r   )r   r   r4  rG  rJ  r(  s   &&&&  r#   err_normalise_mismatch_replace&dbcheck.err_normalise_mismatch_replace6  s    ZZ99$:K:KX^

v%xY[\]&RVWaRbcd8UW XZqrrKK3h>?KKM((S5I5I8T>>!i):;<xG#(  * * KK1H<=*r   c                
   V P                  RV: RV: R24       V P                  R\        V4      : R\        V4      : R24       V P                  RV: RV: R	2R
4      '       g   V P                  RV,          4       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      WR&   V P                  VRR.RV,          RR7      '       d   V P                  RV,          4       R# R# )zfix duplicate attribute valuesz'ERROR: Duplicate values for attribute 'rP  rA  zValues contain a duplicate: [z]/[z]!zFix duplicates for 'rS  rT  rF   rU  Nr   r   z0Failed to remove duplicate value on attribute %sFr   z'Removed duplicate value on attribute %s)	r   r$   r   ro   r   r   r   r   r   )r   r   r4  
dup_valuesrG  r(  s   &&&&& r#   err_duplicate_valuesdbcheck.err_duplicate_valuesK  s    HVXYZ%j13CF3KM 	NRT UWkllKK3h>?KKM((1E1ExP>>!i):;LxW#(  * * KKAHLM*r   c                J    VP                   R\        P                  ,          8H  # )z2see if a dsdb_Dn is the special Deleted Objects DNzB:32:%s:)prefixr   r   )r   r   s   &&r#   r   dbcheck.is_deleted_objects_dn]  s    ~~d.T.T!TTTr   c                T   V P                  RV: RV P                  P                  V4      : R24       V P                  RV,          R4      '       g   V P                  RV,          4       R# V P	                  VR.R	V,          4      '       d   V P                  R
V,          4       R# R# )z!handle object without objectclassz%ERROR: missing objectclass in object zw.  If you have another working DC, please run 'samba-tool drs replicate --full-sync --local <destinationDC> <sourceDC> rA  zIIf you cannot re-sync from another DC, do you wish to delete object '%s'?r|   z1Not deleting object with missing objectclass '%s'Nr   Failed to remove DN %sRemoved DN %s)r   r;   get_nc_rootr   r"  r   r   s   &&r#   err_missing_objectclassdbcheck.err_missing_objectclassa  s      |~  @D  @J  @J  @V  @V  WY  @Z  [  	\ knp p  sP  Q  QKKKbPQ>>"yk2R79 9KK",-9r   c                   V'       gk   V P                  RV: RV: RV: 24       V P                  R\        V4      ,          4       V P                  RR4      '       g   V P                  R4       R# MiV P                  R	V: RV: RV: 24       V P                  R\        V4      ,          4       V P                  R
R4      '       g   V P                  R4       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      VR&   V P                  VRR\        P                  ,          .RV,          4      '       d   V P                  RV,          4       R# R# )z(handle a DN pointing to a deleted objectz ERROR: target DN is deleted for  in object  - z#Target GUID points at deleted DN %rzRemove DN link?rI   zNot removingNz"WARNING: target DN is deleted for zRemove stale DN link?rJ   	old_valuer   r  z(Failed to remove deleted DN attribute %sz"Removed deleted DN on attribute %s)r   r   r   ro   r   r   r   r=  r   r    DSDB_CONTROL_REPLMD_VANISH_LINKS)r   r   r4  rI  r   
correct_dnremove_plausibler(  s   &&&&&&& r#   err_deleted_dndbcheck.err_deleted_dnk  s)   KKRZ\^`cdeKK=JOP##$57\]]N+ ^ KKT\^`befgKK=JOP##$;=`aaN+KKM++C1D1DhO+>>!/.1V1VVXDxOQ Q KK<xGHQr   c           
        \        V4      P                  R4      R8w  d1   V P                  RV: RV: RV: 24       V P                  R4       ^ # V P                  V4      w  rVV^,          ^ 8X  EdT   \        V4      P                  R4      R8X  Ed4   V P                  V4      w  rWVe1   V P                  RV: RV: RV: 24       V P                  R	4       ^ # V P                  P                  V4      p V P                  P                  VP                  4      p	V	f?   V P                  R
V: RVP                  : RV: RV: 24       V P                  R4       ^ # W8w  d1   V P                  RV: RV: RV: 24       V P                  R4       ^ # V P                  RV: RV: RV: 24       V P                  WVWDR4       ^ # V P                  RV: RV: RV: 24       V P                  WW4VR4       ^#   \        P                   d2   p
T
P                  w  rT\        P                  8w  d   h Rp	 Rp
?
ELRp
?
ii ; i)zphandle a missing target DN (if specified, GUID form can't be found,
and otherwise DN string form can't be found)z\0ADELz8WARNING: no target object found for GUID component link z in deleted object ri  z`Not removing dangling one-way link on deleted object (tombstone garbage collection in progress?)NzLWARNING: no target object found for GUID component for one-way forward link rh  z"Not removing dangling forward linkz<WARNING: no target object found for GUID component for link z in object to z outside our NCszhNot removing dangling one-way left-over link outside our NCs (we might be building a renamed/lab domain)zLWARNING: no target object found for GUID component for cross-partition link zPNot removing dangling one-way cross-partition link (we might be mid-replication)z@WARNING: no target object found for GUID component for DN value Tz:ERROR: no target object found for GUID component for link F)r   findr   r7  r;   rc  r   ro   r   r   r   rn  )r   r   r4  rI  r   r5  _reverse_link_namer   target_nc_rooter   r   s   &&&&&        r#   err_missing_target_dn_or_GUID%dbcheck.err_missing_target_dn_or_GUID  s   
 r7<<	"b( KK%-r38 9 KK F G  99(C	QJ!OW!2!29!=!C 77A &F , *22s< = @Ajj,,R0G&!%!7!7

!C %  *27::r3H I  J K (  *22s< =  < =  KK%-r38 9 c '$8 	!)2s4 	5 	B#Ge << & vv3111!%	&s   5%G8 8H>&H99H>c           
     r   V P                  RV: RV: RV: RV: 24       RR.p V P                  P                  \        VP                  4      \
        P                  . VR7      p\        T4      ^ 8X  d7   T P                  RTP                  ,          4       T P                  YY44       R# T^ ,          P                  Tn        T P                  R\        T4      ,          R4      '       g   T P                  RT,          4       R# \
        P                  ! 4       pYn        \
        P                  ! T\
        P                  T4      TR&   \
        P                  ! \        T4      \
        P                   T4      TR&   T P#                  TR.RT: RT: 24      '       d   T P                  RT: RT: 24       R# R#   \
        P                   df   pTP                  w  rT P                  RTP                  : R	T
: R
24       T	\
        P                  8w  d   h T P                  YY44        Rp?R# Rp?ii ; i)z+handle a missing GUID extended DN componentERROR:  component for rh  ri  r   r   r   zunable to find object for DN z - ()Nzunable to find object for DN %sChange DN to %s?rG   Not fixing %srj  	new_valueFailed to fix  on attribute Fixed )r   r;   r   r   r   ro   r   r   r   r   rw  r   r   r   r   r=  rF  r   )r   r   r4  rI  r   errstrr   r   e7r   r   r(  s   &&&&&&      r#   err_missing_dn_GUID_component%dbcheck.err_missing_dn_GUID_component  s   fhXZ\_`a%'89		**##WZZ*,x $ AC s8q=KK9GJJFG..rSJVYY
 2S\ ACUVVKK&01KKM++C1D1DhO+++CL#:J:JHU+>>!/0@FQS SKKfhGHS+ || 	77LTKKGJJPTUVs---..rSJ	s   A F< <H6AH11H6c           
     2   V P                  RV: RV: RV: RV: 24       V P                  R\        V4      ,          R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      VR	&   \        P                  ! \        V4      \        P                  V4      VR
&   V P                  VR.RV: RV: 24      '       d   V P                  RV: RV: 24       R# R# )z'handle an incorrect binary DN componentrz  z binary component for rh  ri  r}  rH   r~  Nrj  r  r   r  r  r  )
r   r   r   ro   r   r   r   r=  rF  r   )r   r   r4  rI  r   r  r(  s   &&&&&& r#   err_incorrect_binary_dndbcheck.err_incorrect_binary_dn  s    VU]_acfgh 2S\ ACVWWKK&01KKM++C1D1DhO+++CL#:J:JHU+>>!/0@FQS SKKfhGHSr   c                P   V P                  RV: RV: RV: 24       WTn        V P                  R\        V4      ,          R4      '       g   V P                  R4       R# \        P
                  ! 4       pWn        \        P                  ! V\        P                  V4      VR&   \        P                  ! \        V4      \        P                  V4      VR	&   V P                  VR
R\        P                  ,          .RV,          4      '       d   V P                  RV,          4       R# R# )z<handle a DN string being incorrect due to a rename or deletez<NOTE: old (due to rename or delete) DN string component for rh  ri  r}  rO   zNot fixing old string componentNrj  r  r   local_oid:%s:1z+Failed to fix old DN string on attribute %sz#Fixed old DN string on attribute %s)r   r   r   r   ro   r   r   r=  rF  r   r   %DSDB_CONTROL_DBCHECK_FIX_LINK_DN_NAME)r   r   r4  rI  r   rl  r(  s   &&&&&& r#   err_dn_string_component_old#dbcheck.err_dn_string_component_old  s    jrtvx{|}
 2S\ A JL LKK9:KKM++C1D1DhO+++CL#:J:JHU+>>!/.1[1[[]G8TV V KK=JKVr   c           
     L   V P                  RV: RV: RV: RV: 24       WTn        V P                  R\        V4      ,          RV,          4      '       g   V P                  RV,          4       R# \        P
                  ! 4       pWn        \        P                  ! V\        P                  V4      VR	&   \        P                  ! \        V4      \        P                  V4      VR
&   V P                  VR.RV: RV: 24      '       d   V P                  RV: RV: 24       R# R# )z"handle a DN string being incorrectzERROR: incorrect DN r{  rh  ri  r}  z fix_all_%s_dn_component_mismatchz Not fixing %s component mismatchNrj  r  r   zFailed to fix incorrect DN r  zFixed incorrect DN )
r   r   r   r   ro   r   r   r=  rF  r   )r   r   r4  rI  r   rl  mismatch_typer(  s   &&&&&&& r#    err_dn_component_target_mismatch(dbcheck.err_dn_component_target_mismatch  s    S`bjlnpstu
 2S\ A B] RT TKK:]JKKKM++C1D1DhO+++CL#:J:JHU+>>!/0MZ\deg gKK=RZ[\gr   c                   V P                  RV: RV: RV: 24       \        VP                  4      ^ 8w  d   V P                  R4       R# \        P                  ! V P
                  VP                  P                  4       4      pVP                  RV4       V P                  RVP                  4       ,          R4      '       g   V P                  R	4       R# VP                  R
4      p\        P                  ! V P
                  R4      pVP                  R
V4       VP                  RV4       \        P                  ! 4       p	Wn        \        P                  ! VP                  4       \        P                  V4      V	R&   RR\        P                  ,          .p
V P!                  WRV,          4      '       d   V P                  RV,          4       R# R# )z*fix missing <SID=...> on linked attributesz$ERROR: missing DN SID component for rh  ri  z3Not fixing missing DN SID on DN+BINARY or DN+STRINGNSIDr}  rN   z#Not fixing missing DN SID componentr   r/   r  r   r  z,Failed to ADD missing DN SID on attribute %sz$Fixed missing DN SID on attribute %s)r   r   r^  ro   rp   r;   r   extended_strset_extended_componentr   r   r   r   rF  r   $DSDB_CONTROL_DBCHECK_FIX_LINK_DN_SIDr   )r   r   r4  rI  r   target_sid_blobrl  target_guid_blobguid_sid_dnr(  r   s   &&&&&&     r#   #err_dn_component_missing_target_sid+dbcheck.err_dn_component_missing_target_sid*  sp   RZ\^`cdew~~!#KKMNVVDJJ

(?(?(AB
))%A 2Z5L5L5N N BD DKK=>%<<VDffTZZ,**63CD**5/BKKM++K,D,D,FHXHXZbc+tHHH
 >>!HHUW WKK>(KLWr   c                   V P                  RV: RVP                  : 24       V P                  RV,          R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! . \        P                  V4      VR&   V P                  VRR	.R
V,          4      '       d   V P                  RV,          4       R# R# )z!handle an unknown attribute errorzERROR: unknown attribute '' in zRemove unknown attribute %srC   zNot removing %sNrj  r   r   z%Failed to remove unknown attribute %szRemoved unknown attribute %s)r   r   r   ro   r   r   r=  r   )r   objr4  r(  s   &&& r#   err_unknown_attributedbcheck.err_unknown_attributeJ  s    XsvvNO = HJijjKK)H45KKMvv++B0C0CXN+>>!i):;AHLN NKK6(CDNr   c                
   V P                  RV: RV: RVP                  : 24       V P                  RV,          R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! V\        P                  V4      VR&   V P                  VR	R
RR\        P                  ,          .RV,          4      '       d   V P                  RV,          4       R# R# )z:handle a link that should not be there on a deleted objectzERROR: linked attribute 'z' to 'z' is present on deleted object zRemove linked attribute %srR   z Not removing linked attribute %sNrj  r   r   r   r  z Failed to delete forward link %szFixed undead forward link %s)
r   r   r   ro   r   r   r=  r   r   rk  )r   r  r4  rI  r(  s   &&&& r#   err_undead_linked_attribute#dbcheck.err_undead_linked_attributeW  s    +3S#&&B 	C <x GIghhKK:XEFKKMvv++C1D1DhO+>>!/1ACW.1V1VVX<xGI I KK6(CDIr   c           
        V P                  RV: RV: RV: RVP                  : 24       V P                  RV,          R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pWVn        \        P
                  ! V\        P                  V4      VR	&   V P                  VR
R.RV,          4      '       d   V P                  RV,          4       R# R# )zhandle a missing backlink valuez#ERROR: missing backlink attribute 'r  
 for link r:  zFix missing backlink %srS   zNot fixing missing backlink %sNr  r   r   z!Failed to fix missing backlink %szFixed missing backlink %s)r   r   r   ro   r   r   rF  r   )r   r  r4  rI  backlink_name	target_dnr(  s   &&&&&& r#   err_missing_backlinkdbcheck.err_missing_backlinkg  s    Xegprz|  }C  }C  D  	E 9M IKfggKK8=HIKKM++C1A1A=Q+>>!/;=MO OKK3}EFOr   c                b   \        VP                  P                  R4      4      pV P                  RWBVP                  VP                  P	                  4       3,          4       V P                  RV,          R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pVP                  Vn        \        P                  ! \        V4      \        P                  V4      VR&   V P                  V. R
ORV,          4      '       d   V P                  R	V,          4       R# R# )z"handle a incorrect RMD_FLAGS value	RMD_FLAGSzHERROR: incorrect RMD_FLAGS value %u for attribute '%s' in %s for link %szFix incorrect RMD_FLAGS %urY   z!Not fixing incorrect RMD_FLAGS %uNrj  z$Failed to fix incorrect RMD_FLAGS %uzFixed incorrect RMD_FLAGS %u)r   r   show_deleted:0)r   r   r   r   r  r   ro   r   r   r   r=  r   )r   r  r4  revealed_dn	rmd_flagsr(  s   &&&&  r#   err_incorrect_rmd_flagsdbcheck.err_incorrect_rmd_flagst  s   ==kJK	^bkwzw}w}  @K  @N  @N  @[  @[  @]  b^  ^  	_ <y H/ZZKK;iGHKKMvv++C,<c>Q>QS[\+>>!X@9LN NKK6)DENr   c                L   VRJ dD   V P                  WEV4      '       d,   V P                  RRV: RV: RV: RV: R2	,           4       R# V P                  RV: RV: R	V: R
V: 24       V P                  RV,          R4      '       g   V P                  RV,          4       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      VR&   V P                  VRR.RV,          4      '       d   V P                  RV,          4       R# R# )z handle a orphaned backlink valueTz*WARNING: Keep orphaned backlink attribute rA  rP  z' for link 'Nz$ERROR: orphaned backlink attribute 'r  r  r:  zRemove orphaned backlink %srT   z!Not removing orphaned backlink %sr"   r   r   z"Failed to fix orphaned backlink %szFixed orphaned backlink %s)	has_duplicate_linksr   r   ro   r   r   r   r=  r   )	r   obj_dnbacklink_attrbacklink_valr  forward_attrforward_syntaxcheck_duplicatesr(  s	   &&&&&&&& r#   err_orphaned_backlinkdbcheck.err_orphaned_backlink  s    t#(@(@Zh(i(iKKD)6<LL M Yfhnp|  H  I  	J = MOkllKK;mKLKKM''c6I6I=Y'
>>!/;>NP PKK4FGPr   c                   V P                  RV: RVP                  : R24       V P                  RV,          R4      '       g'   V P                  RV: RVP                  : R24       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! V\        P                  V4      VR	&   V P                  VR
\        P                  ,          .RV,          4      '       dX   V P                  RV,          4       \        VP                  4      : RV: 2pWPP                  9   g   Q hRV P                  V&   R# R# )zhandle a duplicate links valuezERECHECK: 'Missing/Duplicate/Correct link' lines above for attribute 'rP  rA  zDCommit fixes for (missing/duplicate) forward links in attribute '%s'rX   zENot fixing corrupted (missing/duplicate) forward links in attribute '' of 'Nr"   r  z/Failed to fix duplicate links in attribute '%s'z'Fixed duplicate links in attribute '%s'r   F)r   r   r   ro   r   r   r   r   r   (DSDB_CONTROL_DBCHECK_FIX_DUPLICATE_LINKSr   rW   )r   r  r  forward_valsr(  duplicate_cache_keys   &&&&  r#   err_recover_forward_links!dbcheck.err_recover_forward_links  s    	jvx{x~x~  	A fiu u  xS  T  TKK$cff. /KKMvv''c6J6JLY'
>>!.1^1^^_KlZ\ \KKA\RS-0[,"G&*C*CCCC=BD%%&9:\r   c                   V P                  RVP                  ,          4       V P                  P                  R\        P
                  R.R7      p\        V4      ^8X  g   Q h\        V^ ,          R,          ^ ,          4      pV P                  RVP                  : RV: 2R4      '       g&   V P                  RVP                  : RV: 24       R	# \        P                  ! 4       pVP                  Vn        \        P                  ! V\        P                  R
4      VR&   V P                  V. RVP                  : RV: 24      '       d&   V P                  RVP                  : RV: 24       R	# R	# )zhandle a missing fSMORoleOwnerz*ERROR: fSMORoleOwner not found for role %sr/   dsServiceName)r+   r,   zSeize role z) onto current DC by adding fSMORoleOwner=r\   zNot Seizing role NfSMORoleOwnerr"   zFailed to seize role zSeized role )r   r   r;   r   ro   r   r   r   r   r   r   rF  r   )r   r  r   serviceNamer(  s   &&   r#   err_no_fsmoRoleOwnerdbcheck.err_no_fsmoRoleOwner  s(   @CFFKLjj&)nn_<M   O3x1}}#a&1!45^a^d^dfq r  uF  G  GKK\_\b\bdopqKKMvv''S5E5EW'
>>!Rbebhbhjuvx xKKWZW]W]_jklxr   c                H   V P                  RVP                  ,          4       V P                  RVP                  ,          R4      '       g%   V P                  RVP                  ,          4       R# RpV P                  P	                  4         V P                  P                  VP                  4      pV P                  V\        P                  4      p\        P                  ! V P                  \        VP                  4      4      pVP                  \        V4      ^,
          4       V P                  VP                  WTRR.R	VP                  : R
WT,           : 24      '       d   V P                  RVP                  : R
WT,           : 24       \        P                  ! 4       pVP                  Vn        \        P                   ! \        VP                  P#                  4       4      \        P$                  R4      VR&   V P'                  V. RWT,           ,          4      '       d!   V P                  RWT,           ,          4       RpT'       d   T P                  P+                  4        R# T P                  P)                  4        R#    T P                  P)                  4        h ; i)zhandle a missing parentz%ERROR: parent object not found for %sz!Move object %s into LostAndFound?r]   z&Not moving object %s into LostAndFoundNFr  r   Failed to rename object z into lostAndFound at zRenamed object lastKnownParentz:Failed to set lastKnownParent on lostAndFound object at %sz0Set lastKnownParent on lostAndFound object at %sT)r   r   r   r;   transaction_startrc  r   r   DS_GUID_LOSTANDFOUND_CONTAINERro   rp   r   remove_base_componentsr   r/  r   r   parentr   r   transaction_canceltransaction_commit)r   r  keep_transactionr   lost_and_foundnew_dnr(  s   &&     r#   err_missing_parentdbcheck.err_missing_parent  s   ;svvFG Csvv NPhiiKK@CFFKL 

$$&	jj,,SVV4G!99'4CfCfgNVVDJJCFF4F))#f+/:~~cfff?OQZ>[VYV\V\^d^uvx x366SYSjklKKMvv'*'9'9#cffmmo:NPSPdPdfw'x#$>>!R"^bhby"z| |KK RV\Vm no'+$
 JJ))+JJ))+	JJ))+s   F7J J!c           
        \         P                  ! V P                  \        V4      4      pVP	                  \        V4      ^,
          4       VP                  4       pRp	WE8w  d   W: RV: R2,          p	V	RV,          ,          p	V P                  RVP                  : RV	: RV: R24       V P                  R	VP                  : R
V: R2R4      '       g&   V P                  RVP                  : R
V: 24       R# V P                  VP                  WxVRVP                  : RV: 24      '       d&   V P                  RVP                  : RV: 24       R# R# )zhandle a wrong dnr/   = zname=%rzERROR: wrong dn[z] z new_dn[]zRename r   r<  rd   zNot renaming Nr  z into zRenamed )ro   rp   r;   r   r  r   r  r   r   r   r/  )
r   r  r  rdn_attrrdn_valname_valr   new_rdn
new_parent
attributess
   &&&&&&&   r#   err_wrong_dndbcheck.err_wrong_dn  s     &&S[1&&s7|a'78]]_

h88Ji8,,
366:vVWcfff ExPPKK3666BC>>#&&'xBE&&&QS SKK?@Sr   c                   V P                  RVR,          VP                  V3,          4       V P                  RVR,          W!P                  3,          R4      '       g.   V P                  RVR,          W!P                  3,          4       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! \        V4      \        P                  R4      VR&   V P                  VR\        P                  ,          .R	VP                  V3,          4      '       d'   V P                  R
VP                  V3,          4       R# R# )zhandle a wrong instanceTypez0ERROR: wrong instanceType %s on %s, should be %dinstanceTypez(Change instanceType from %s to %d on %s?r^   z-Not changing instanceType from %s to %d on %sNr"   r  zGFailed to correct missing instanceType on %s by setting instanceType=%dz7Corrected instancetype on %s by setting instanceType=%d)r   r   r   ro   r   r   r   r   r   r   &DSDB_CONTROL_DBCHECK_MODIFY_RO_REPLICA)r   r  calculated_instancetyper(  s   &&& r#   err_wrong_instancetypedbcheck.err_wrong_instancetype  sF   F#nJ]_b_e_eg~I  	A JcR`Nacz  }C  }C  ND  !D  FX  Y  YKKG3~K^`wyy  KA  A  BKKMvv'',C(DcFZFZ\jk'
>>!.1\1\\]cgjgmgm  pG  gH  HI IKKQUXU[U[]tTuuvIr   c                    V P                  R VP                  : RV P                  P                  VP                  4      : R24       R# )0ERROR: incorrect userParameters value on object z.  If you have another working DC that does not give this warning, please run 'samba-tool drs replicate --full-sync --local <destinationDC> <sourceDC> rA  Nr   r   r;   rc  )r   r  r4  r"   s   &&&&r#   err_short_userParameters dbcheck.err_short_userParameters   si      gj  gm  gm  os  oy  oy  oE  oE  FI  FL  FL  oM  N  	Or   c                N   V P                  RV: RVP                  : R24       V P                  RVP                  ,          R4      '       g%   V P                  RVP                  ,          4       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! \        W,          ^ ,          4      \        P                  R4      VR	&   V P                  V. R
VP                  ,          4      '       d%   V P                  RVP                  ,          4       R# R# )z6handle a userParameters that is wrongly base64 encodedz(ERROR: wrongly formatted userParameters  on z, should not be base64-encodedz2Convert userParameters from base64 encoding on %s?re   z6Not changing userParameters from base64 encoding on %sNuserParametersr"   zOFailed to correct base64-encoded userParameters on %s by converting from base64zGCorrected base64-encoded userParameters on %s by converting from base64)	r   r   r   ro   r   r   r   r   r   r   r  r4  r"   r(  s   &&&& r#   err_base64_userParameters!dbcheck.err_base64_userParameters  s    hmorououvw TX[X^X^ _a|}}KKPTWTZTZ[\KKMvv''	#-2B(CSEYEY[kl'
>>!Rkorououvx xKKaehekeklmxr   c                t   V P                  RVP                  ,          4       V P                  RVP                  ,          R4      '       g%   V P                  RVP                  ,          4       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! W,          ^ ,          P                  R4      P                  R4      \        P                  R4      VR	&   V P                  V. R
VP                  ,          4      '       d%   V P                  RVP                  ,          4       R# R# )z5handle a userParameters that is wrongly utf-8 encodedzPERROR: wrongly formatted userParameters on %s, should not be pseudo-UTF8 encodedz0Convert userParameters from UTF8 encoding on %s?rf   z4Not changing userParameters from UTF8 encoding on %sNr1   	utf-16-ler  r"   zQFailed to correct psudo-UTF8 encoded userParameters on %s by converting from UTF8zICorrected psudo-UTF8 encoded userParameters on %s by converting from UTF8
r   r   r   ro   r   r   r   encoder   r   r  s   &&&& r#   err_utf8_userParametersdbcheck.err_utf8_userParameters  s     8;>66C 	D RVYV\V\ ]_xyyKKNRURXRXYZKKMvv''a(8(?(?(G(N(N{([(+(<(<>NP'
>>!Rmqtqwqwxz zKKcgjgmgmnozr   c                t   V P                  RVP                  ,          4       V P                  RVP                  ,          R4      '       g%   V P                  RVP                  ,          4       R# \        P                  ! 4       pVP                  Vn        \        P
                  ! W,          ^ ,          P                  R4      P                  R4      \        P                  R4      VR	&   V P                  V. R
VP                  ,          4      '       d%   V P                  RVP                  ,          4       R# R# )z:handle a userParameters that has been utf-16 encoded twicezQERROR: wrongly formatted userParameters on %s, should not be double UTF16 encodedz:Convert userParameters from doubled UTF-16 encoding on %s?rg   z>Not changing userParameters from doubled UTF-16 encoding on %sNr  r1   r  r"   zJFailed to correct doubled-UTF16 encoded userParameters on %s by convertingzBCorrected doubled-UTF16 encoded userParameters on %s by convertingr  r  s   &&&& r#   err_doubled_userParameters"dbcheck.err_doubled_userParameters"  s   gknkqkqrs \`c`f`f g  jF  G  GKKX\_\b\bcdKKMvv ''a(8(?(?(L(S(STZ([(+(<(<>NP'
 >>!Rfjmjpjpqs sKK\`c`f`fghsr   c                    V P                  RVP                  : RV P                  P                  VP                  4      : R24       R# )z?Fix a truncated userParameters due to a pre 4.1 replication bugr  z (odd length).  If you have another working DC that does not give this warning, please run 'samba-tool drs replicate --full-sync --local <destinationDC> <sourceDC> rA  Nr  )r   r  r4  s   &&&r#   err_odd_userParametersdbcheck.err_odd_userParameters<  si      tw  tz  tz  |@  |F  |F  |R  |R  SV  SY  SY  |Z  [  	\r   c                `   V P                   P                  V\        P                  V.. ROR7      pV P                  P                  V4      pV^ ,          V,           FN  p\        V P                   VP                  R4      V4      pVP                  P                  R4      pW88X  g   KL  Vu # 	  R# )z#return a revealed link in an objectr   r1   r   N)r  r   r   )
r;   r   ro   r   r=   #get_syntax_oid_from_lDAPDisplayNamer   r   r   r   )	r   r   r4  r   r   
syntax_oidrI  r   guid2s	   &&&&     r#   find_revealed_linkdbcheck.find_revealed_link@  s    jjRs~~hZ)b   d&&JJ8T
q6(##Cdjj#**V*<jIGJJ55f=E}	 $
 r   c                   ^ p\        4       p\        4       pV^,          '       d   WgV3# Vf   WgV3# \        VP                  4      : RV: 2p	WP                  9  d   RV P                  V	&   W,           EF?  p
\	        V P
                  V
P                  R4      V4      pVP                  P                  R4      pVf   KK  \        \        P                  ! V4      4      pWP                  ,           pW9  d   WV&   K  V^,          pW9  d+   \        4       W~&   RW~,          R&   \        4       W~,          R&   \        W,          P                  P                  R4      4      p\        VP                  P                  R4      4      pVV8  d3   W,          W~,          R&   W~,          R,          P                  V4       EKH  VV8  d7   WV,          R&   W~,          R,          P                  W,          4       WV&   EK  \        W,          P                  P                  R	4      4      p\        VP                  P                  R	4      4      pVV8  d3   W,          W~,          R&   W~,          R,          P                  V4       EK  WV,          R&   W~,          R,          P                  W,          4       WV&   EKB  	  V^ 8w  d   R
V P                  V	&   WgV3# )1check a linked values for duplicate forward linksNr   Fr1   r   keepr  RMD_VERSIONRMD_LOCAL_USNT)rV   r   r   rW   r   r;   r   r   r   r   r^  rV  r   r   )r   r  r  r  forward_linkIDr  r   duplicate_dictunique_dictr  rI  r   r   guidstrkeystrv1v2u1u2s   &&&&&&             r#   check_duplicate_linksdbcheck.check_duplicate_linksL  sz   f A== ==),SVVlC&?&??=BD%%&9:$$Cdjj#**V*<nMG ::44V<D|$))D/*G~~-F(&-F#1K+)-&15&v.376&x0 [(++BB=QRBWZZ66}EFBBw1<1D&v.&x077@Bw18v&v.&x0778KL&-F#[(++BB?STBWZZ66GHBRx1<1D&v.&x077@-46"6*"8,33K4GH")O %R !=AD%%&9:[99r   c                &   ^ p\        V4      : RV: 2pWPP                  9   d   V P                  V,          # V P                  V4      w  rgV.pRR.p	 V P                  P	                  \        V4      \
        P                  WR7      p
T
^ ,          pT P                  YY6T4      w  rOpYPP                  9   d   T P                  T,          # R#   \
        P                   d0   pTP                  w  rT\
        P                  8w  d   h  Rp?R# Rp?ii ; i)r  r   r   r   r   NF)r   rW   r7  r;   r   ro   r   r   r   r   r  )r   r   r  r  r   r  r  r  r,   r   r   e8r   r   r  r  r  s   &&&&             r#   r  dbcheck.has_duplicate_links  s   ),R,?";";;,,-@AA(,(M(Ml([%%';<	**##R*/ $ DC !f&&s.Zgh 	1[ ";";;,,-@AA || 	77LTs---	s   5C D!$DDc                z   . p^ pVf   Wg3# V\         P                  8w  d   V P                  RV,          4       Wg3# RV P                  9   d   V P                  R4       Wg3#  VR,          ^ ,          p\	        \        \        P                  V4      4      p	RV: RV	: R2p
V P                  P                  V
\         P                  R.. ROR7      pT EF7  p\        T P                  TP                  P                  4       T4      pTP                  P!                  R	4      p\	        \        P                  ! T4      4      pTT9   d   Kv  \        \"        P$                  TR
,          ^ ,          4      pTP&                  P(                   F<  pTP*                  pTP,                  pTP.                  \0        P2                  8X  g   K<   M	  \        P                  ! R4      p^pXpTp^ pTpTpXp^ pTP                  P5                  R\	        T4      4       TP                  P5                  R\	        T4      4       TP                  P5                  R\	        T4      4       TP                  P5                  R\7        T4      4       TP                  P5                  R\	        T4      4       TP                  P5                  R\	        T4      4       TP                  P5                  R\	        T4      4       T^,          pTP9                  T4       EK:  	  Yg3#   \         P                   d   pTP                  w  rh Rp?ii ; i)zMFind all backlinks linking to obj_guid_str not already in forward_unique_dictNz5Not checking for missing forward links for syntax: %ssortedLinks
objectGUID(z=<GUID=z>))r4   r+   r,   r   r   replPropertyMetadataz$ffffffff-4700-4700-4700-000000b13228RMD_ADDTIMERMD_CHANGETIMEr  RMD_INVOCIDRMD_ORIGINATING_USNr
  r	  zQNot checking for missing forward links because the db has the sortedLinks feature)r   search_options:1:2zpaged_results:1:1000)ro   	SYNTAX_DNr   r9   r   r	   r   r   r;   r   SCOPE_SUBTREEr   r   r   r   r  r   r   replPropertyMetaDataBlobctrarray	local_usnoriginating_change_timeattidr   DRSUAPI_ATTID_objectClassr  r
   r   ) r   r  r  r  r  forward_unique_dictmissing_forward_linksr   obj_guidobj_guid_strfilterr   e9r   r   rr  r   r  replr   r(  toriginating_invocidoriginating_usnrmd_addtimermd_changetimer  rmd_invocidrmd_originating_usnrmd_local_usnrmd_versions    &&&&&&                          r#   )find_missing_forward_links_from_backlinks1dbcheck.find_missing_forward_links_from_backlinks  s    !# )77S]]*KKO&' ()77D333KK 6 7)77	<(+Hz$))X>?L)6EF**##v*-*;*;L>.F $ GC A

ADD,=,=,?PI<<66v>D$))D/*G--( h??!"89!<>DXX^^KK	--77g???	 $ #')),R"SOKNI-K"1%MKLL//s;?OPLL//0@#nBUVLL//S^LLL//x?TULL//0EsK^G_`LL//]ASTLL//s;?OP1K!((3} @ &33I || 	77LT	s   "A.L L:&L55L:c                   ^ pVR,          ^ ,          pV P                  V4      w  rgVe   V P                  P                  V4      pMRpVR&9   p	V	'       d   V P                  '       d   / p
MV P	                  WVWg4      w  rJp\        V
4      ^ 8w  Ed   V P                  VW#VX4      w  rWM,          pVP                  4        Uu. uF  qNK  	  ppV^ 8w  d&   V P                  RV: RVP                  : R24       M$V P                  RV: RVP                  : R24       V F  pV P                  RV,          4       V P                  RV,          R	4      '       gF   V P                  VP                  VVP                  P                  4       VP                  W#R
R7       K  VV.,          pK  	  V
P                  4        FS  pV
V,          pVR,           F  pV P                  RV,          4       K  	  V P                  RVR,          ,          4       KU  	  \        V4       Uu. uF  p\        V4      NK  	  ppV P!                  WV4       \"        P$                  ! V^ V4      W&   W,           E
Ft  p\'        V P(                  VP+                  R4      V4      pVP                  P-                  R4      pVf+   V^,          pV P/                  VP                  VVVR4       Ks  \        \0        P2                  ! V4      4      pRR.p\        V4      P5                  4       R8X  d0   VP                  V P6                  8X  d   RpVP9                  R4       MR
pVe   VP9                  V4        V P(                  P;                  RV,          \"        P<                  V. R'OR7      pT'       d   R\G        T^ ,          R,          ^ ,          4      ,          Tn$        R\G        T^ ,          R,          ^ ,          4      ,          Tn%        \        T4      \        T4      8w  d,   T^,          pT PM                  TP                  TTTR4       EK  RT9   ;'       d+    \        TR,          ^ ,          4      PO                  4       R8H  pRT^ ,          9   ;'       d2    \        T^ ,          R,          ^ ,          4      PO                  4       R8H  p T'       dB   TP                  T PP                  9  d'   T'       d   T PS                  YT4       T^,          pEK  T '       Ed[   T PU                  T4      '       EgC   T'       Ed:   T^,          pTP                  P-                  R4      p!T!'       d   RT^ ,          9   d   \W        \X        PZ                  T^ ,          R,          ^ ,          4      p"R
p#T"P\                  P^                   FD  p$T$P`                  \b        Pd                  8X  g   K$  T$Pf                  p%T%\G        T!4      8  g   KB  Rp# M	  T#'       d5   T Pi                  TP                  TTTT^ ,          P                  R4       EK  T Pi                  TP                  TTTT^ ,          P                  R
4       EK  TP                  P-                  R 4      p&^ p'T&e   \G        T&4      p'T'^,          '       gv   Ter   \        T^ ,          P                  4      \        TP                  4      8w  d>   T^,          pT Pk                  TP                  TTTT^ ,          P                  R!4       EK  T^ ,          P                  P-                  R4      TP                  P-                  R4      8w  d>   T^,          pT Pk                  TP                  TTTT^ ,          P                  R4       EK*  T^ ,          P                  P-                  R"4      p(TP                  P-                  R"4      p)T)f0   T(e,   T^,          pT Pm                  TP                  TTTT(4       EK  T)T(8w  d>   T^,          pT Pk                  TP                  TTTT^ ,          P                  R"4       EK  Tf   T^ 8X  d   \        T^ ,          P                  4      \        TP                  4      8w  d\   TPH                  TP                  Po                  4       ,           p*T Pq                  TP                  TT*TT^ ,          P                  4       EK{  T	'       d   T P                  '       d   EK  ^ p+TT^ ,          9   d   T^ ,          T,           F  p,\'        T P(                  T,P+                  R4      4      p-T-P                  P-                  R4      p.T-P                  P-                  R 4      p/^ p0T/e   \G        T/4      p0T0^,          '       d   K  T.T8X  g   K  T+^,          p+K  	  T+^8w  d   T\r        Pt                  8X  g   T\r        Pt                  8X  d{   T^,          '       gl   ^ p1Y,           FS  p2\'        T P(                  T2P+                  R4      4      P                  P-                  R4      p3T3T8X  g   KJ  T1^,          p1KU  	  T+T18X  d   EK  ^ p4Y,           F  p,\'        T P(                  T,P+                  R4      4      p-T-P                  P-                  R4      p.T-P                  P-                  R 4      p/^ p0T/e   \G        T/4      p0T0^,          '       d   K  T.T8X  g   K  T4^,          p4K  	  T+T48X  d   EK  T4T+,
          p5T^,          '       d   T+^ 8X  d7   T^,          pT P                  TP                  TTTP                  TT4       EK  T P                  R#TT4\        TP                  4      TT+\        TP                  4      3,          4       E	K?  T '       d   Q hT P                  R$TT4\        TP                  4      TT+\        TP                  4      3,          4       T5^ 8w  g   E	K  T^,          pT5^ 8  d~   T+^ 8  g   T5^8  d/   T P                  R%\        TP                  4      ,          4       E	K  T Pw                  YTP                  P                  4       TTP                  4       T5^,          p5K  T P                  T^ ,          P                  TTP                  P                  4       TP                  Y#4       T5^,          p5K  	  V# u upi u upi   \"        P>                   dV   pTP@                  w  ppT\"        PB                  8w  d   h Y@PE                  TP                  TTT4      ,          p Rp?E
K  Rp?ii ; i)(z$check a DN attribute for correctnessr  Nz@ERROR: Missing and duplicate forward link values for attribute 'rP  rA  z4ERROR: Duplicate forward link values for attribute 'zMissing   link '%s'z8Schedule re-adding missing forward link for attribute %srU   F)r  r  zDuplicate link '%s'zCorrect   link '%s'r  r1   r   zmissing GUID	isDeletedreplPropertyMetaDatazmsds-hasinstantiatedncsTr  	<GUID=%s>r   z	B:8:%08X:z%08Xz(incorrect instanceType part of Binary DNTRUEr
  r  r  stringr  zHWARNING: Link (back) mismatch for '%s' (%d) on '%s' to '%s' (%d) on '%s'zIERROR: Link (forward) mismatch for '%s' (%d) on '%s' to '%s' (%d) on '%s'z5ERROR: Can't fix missing multi-valued backlinks on %s)membermemberOf)r   r   r   )<r7  r=   r  ri   r  r   r=  rG  r   r   r   r  r  keyssortedr   r  ro   r   r   r;   r   r   r  r   r   lowerry   r   r   r   r   r   r   rw  r   r^  binaryr  upperr   r  r   r	   r   r%  r&  r'  r*  r   DRSUAPI_ATTID_isDeletedr(  rn  r  r  r   r  r   r   r  )6r   r  r4  r  r   r.  r5  rt  reverse_syntax_oidis_member_linkr  r  r-  missing_error_countr   forward_linksr(  r  dddr    rI  r   r   r  r,   fixing_msDS_HasInstantiatedNCsr   e3r   r   
is_deletedtarget_is_deletedr(  r3  
found_datar   deleted_usnrmd_blobr  
target_sidlink_sidbad_dnmatch_countvv_dnv_guidv_blobv_rmd_flagsforward_countww_guidexpected_count
diff_counts6   &&&&                                                  r#   check_dndbcheck.check_dn  sc   |$Q'$($I$I($S!(!%!2!2!V!VWh!i!%!%;;d:::N **3*+1F 5K ~!# >>s?G?P?JL 7!
 .K*5*<*<*>?*>BR*>M?"a'$cff. / aiknkqkqrs*1Q78''(bem(m(GI I..qtt5F/2vv/B/B/Dcff/7@E / G !$ + )--/"6*H++BKK 5 :; &1AfI=>	 0 '-]&;<&;CG&;D<**3$?..tQACM==Cdjj#**V*<jIG ::44V<D|q 223668S'3AC$))D/*G "89EH##%)BBSWS`S`I`15.^,16. ,./jj''[7-B#...3 ?A ( B  .!,s3q6.3I!3L/M!M!'#c!f^.DQ.G*H!Hw<3s8+1$K003Q{| %+ZZC4DQ4G0H0N0N0PTZ0ZJ +s1v 5 g g#c!f[>QRS>T:U:[:[:]ag:gcffD,K,KKPV
 00Dq ""4+E+Eg+N+NSYSY q #JJ==oN	-Q7)(*K*K*-a&1G*H*K M%*
!%A ww'*I*II./kk#.#i.#@ 26J$) "0 & //03Wc!fiiO$##CFFHc7CFIIuU
 zz88EHI#M	 q==%6%Bs1vyy>S_41$K99#&&(CQX:=a&))XO1vyy//77::;\;\]c;ddq 55cffhW69!fiiIQ99%@Jzz88?HJ$:q 8839@*N:%q 55cffhW69!fiiH !(Q;3s1vyy>S_#D
 %^^gjj.G.G.IIF44SVVXv5<c!fiiI$">">"> K CF*Q 122A"4::qxx/?@D!WW;;FCF!WW;;KHF"#K)&)&k"Q )#q( 3 a!;!;;?QUYUoUo?o!A::()!$A%,TZZ&9I%J%M%M%d%dek%lF%~ - 2 "/
 '-7$N]]tzz188F+;<77?77D%"%f+K??T>"a'N # n,'+5Jzz !#1$K..svvx/2GJJ/@/AC f$nc#&&k-{C

OjM M N (((KKc .#cff+);GJJgI I J /q >"Q*q. %CEH_%U V--c.1ff.A.A.C.?.5jj: !OJ..s1vyy:K/2vv/B/B/Dcff/7E !OJW !Z Y @4 =D << 
!wwt3111 AA#&&BJBEBI K K 
s%   
s% s*%6s//uA	uuc                j    VP                   P                   F  pVP                  V8X  g   K  Vu # 	  R # r   )r&  r'  r*  )r   r3  r*  r   s   &&& r#   find_repl_attiddbcheck.find_repl_attid>  s*    Aww%   r   c                |    \        \        P                  V4      pV P                  W24      pVe   VP                  # ^ # )zRead metadata properties and return the originating time for
a given attributeId.

:return: the originating time or 0 if not found
)r	   r   r%  rk  r)  )r   rI  r*  r3  r   s   &&&  r#   get_originating_timedbcheck.get_originating_timeE  s:     (;;SA  -=,,,r   c                ,   \        4       p\        4       p. pVP                  V P                  4      p\        \        P
                  V4      pVP                  P                   F  pV P                  P                  VP                  4      p	VP                  V	P                  4       4       VP                  VP                  4       V P                  P                  V	VR7      p
WP                  8w  g   K  VP                  VP                  4       K  	  W5V3# )z\Read metadata properties and list attributes in it.
raises KeyError if the attid is unknown.is_schema_nc)r   is_child_ofrv   r	   r   r%  r&  r'  r=   get_lDAPDisplayName_by_attidr*  r   rI  r   get_attid_from_lDAPDisplayName)r   r   rI  set_attwrong_attids
list_attidin_schema_ncr3  r   attcorrect_attids   &&&        r#   process_metadatadbcheck.process_metadataR  s     %u
~~dnn5(;;SAA##@@ICKK		$agg& --LLSZf M hM'  )   \22r   c                4   \        \        \        P                  VR,          ^ ,          4      4      p\        P
                  ! V P                  RV,          4      pV P                  P                  V\        P                  V.RR.R7      pV^ ,          p\        P                  ! 4       pWGn
        \        P                  ! Wb,          \        P                  V4      Wr&   V P                  V. R	ORV,          4      '       d   V P                  RV,          4       R# R# )
zre-write replPropertyMetaData elements for a single attribute for a
object. This is used to fix missing replPropertyMetaData elementsr  rB  r"  r   r   'Failed to fix metadata for attribute %szFixed metadata for attribute %sN)r   r   r   )r   r	   r   r   ro   rp   r;   r   r   r   r   r   r   r   r   )r   r  attrguid_strr   r   r  nmsgs   &&&     r#   fix_metadatadbcheck.fix_metadatah  s     z$))S->q-ABCVVDJJh 67jjRs~~dV*>*;*=   > !f{{}''	33G3GN
>>$ MCdJL LKK9D@ALr   c                   VP                   \        P                  ,          '       d   R # RpVP                  \        P                  8X  d   RpMeVP                  \        P
                  8X  d   RpMCVP                  \        P                  8X  d   RpM!VP                  \        P                  8X  d   RpV'       g   R # VP                  P                   \        P                  ,          '       g   R # \        VP                  P                  4      # )NFT)flagsr   SEC_ACE_FLAG_INHERIT_ONLYtype"SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT!SEC_ACE_TYPE_ACCESS_DENIED_OBJECT SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT SEC_ACE_TYPE_SYSTEM_ALARM_OBJECTr   %SEC_ACE_INHERITED_OBJECT_TYPE_PRESENTr   inherited_type)r   acechecks   && r#    ace_get_effective_inherited_type(dbcheck.ace_get_effective_inherited_typex  s    99x999988xBBBEXXCCCEXXBBBEXXBBBEzz("P"PPP3::,,--r   c                <   WP                   9   d   V P                   V,          # R V,          pV P                  P                  V P                  VR.R7      p\	        \        \        P                  V^ ,          R,          ^ ,          4      4      pW@P                   V&   V# )z0(&(ldapDisplayName=%s)(objectClass=classSchema))schemaIDGUID)r*   r4   r,   )rz   r;   r   rv   r   r	   r   r   )r   clsfltr   r4  s   &&   r#   lookup_class_schemaIDGUID!dbcheck.lookup_class_schemaIDGUID  s    )))**3//@3FjjT^^+.'5&6   8 
499c!f^&<Q&?@A'($r   c                   R pW#,          p\        \        P                  V^ ,          4      pRV9   ;'       d+    \        VR,          ^ ,          4      P	                  4       R8H  pV'       d   VR3# \        P                  ! 4       pVP
                  Vn        VP                  Vn        VP                  Vn        VP                  Vn        RpRp	. p
VP                  e   VP                  P                  p
\        ^ \        V
4      4       Fl  pW,          pVP                  \        P                  ,          '       g   VP                  V4       KE  V P!                  V4      pVf   K\  V	e   W8w  d   RpKj  Tp	Kn  	  . p
VP"                  e   VP"                  P                  p
\        ^ \        V
4      4       Fl  pW,          pVP                  \        P                  ,          '       g   VP%                  V4       KE  V P!                  V4      pVf   K\  V	e   W8w  d   RpKj  Tp	Kn  	  V'       d   Wu3# V	f   VR3# Rp VR,          R	,          pVf   V P(                  P+                  V\,        P.                  RR.R.R7      pV^ ,          pRV9   ;'       d+    \        VR,          ^ ,          4      P	                  4       R8H  pV'       d   VR3# VR,          R	,          pV P1                  V4      pW8w  d   Wu3# VR3#   \&         d   p Rp?LRp?ii ; i)
nTSecurityDescriptorr@  rC  NFTobjectClassr   r   rq  )r	   r   
descriptorr   rK  	owner_sid	group_sidr  revisionsaclacesrE  r   r  SEC_ACE_FLAG_INHERITED_ACEsacl_addr  dacldacl_addr   r;   r   ro   r   r  )r   r   r  sd_attrsd_valsdrU  sd_cleanbrokenlast_inherited_typer  rK  r  r4  r  rv  r   r   s   &&&               r#   
process_sddbcheck.process_sd  s   (++VAY7 C'VVCK0@0C,D,J,J,LPV,V
:&&(\\\\KK"7777<<Dq#d)$A'C99xBBBB!!#&55c:Ay".+ "F"#+ %. 7777<<Dq#d)$A'C99xBBBB!!#&55c:Ay".+ "F"#+ %. >!&:	m$R(C ;**##3>>+6*F.?-@ $ BC AA$)VVc!K.2C.D.J.J.LPV.VJDz!M"2&C**3/#>! Dz+  		s   8K6 6LLc                   Rp\        V4      p\        P                  \        P                  ,          pV P	                  RV: RV: R2R4      '       g   V P                  RV: RV: R24       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      Wt&   V P                  VR	V,          .R
V,          4      '       d   V P                  RV: RV: R24       R# R# )z/re-write the SD due to incorrect inherited ACEsr  Fix r  r<  rZ   Not fixing 
Nsd_flags:1:%dFailed to fix attribute %sFixed attribute 'r  '
)r
   r   SECINFO_DACLSECINFO_SACLr   r   ro   r   r   r   r   r   )r   r   r  	sd_brokenr  r  sd_flagsr  s   &&&&    r#   err_wrong_sddbcheck.err_wrong_sd  s    ("((8+@+@@7B ?A[\\KK7B?@{{}**633G3GQ>>$8!; <6@B BKKGRHIBr   c                   Rp\        V4      p\        P                  \        P                  ,          pVP                  e   V\        P
                  ,          pVP                  e   V\        P                  ,          pV P                  RV: RV: RV: 2R4      '       g   V P                  RV: RV: R24       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      Wt&   V P                  VR	V,          .R
V,          4      '       d   V P                  RV: RV: R24       R# R# )zare-write the SD due to not matching the default (optional mode for fixing an incorrect provision)r  NzReset r  z back to provision default?
rm   zNot resetting r  r  zFailed to reset attribute %sr  r  r  )r
   r   r  r  r  SECINFO_OWNERr  SECINFO_GROUPr   r   ro   r   r   r   r   r   )r   r   r  diffr  r  r  r(  s   &&&&    r#   err_wrong_default_sddbcheck.err_wrong_default_sd  s    ("((8+@+@@<<#...H<<#...HSZ\^`d e  hC  D  DKKgrBCKKM''0D0DgN
>>!o8987BD DKKGRHIDr   c                   Rp\        V4      p\        P                  \        P                  ,          pV P	                  RV: RV: R2R4      '       g   V P                  RV: RV: R24       R# \        P                  ! 4       pWn        \        P                  ! V\        P                  V4      Wc&   V P                  P                  V P                  4       V P                  VR	V,          .R
V,          4      '       d   V P                  RV: RV: R24       V P                  P                  V P                  4       R# )z/re-write the SD due to a missing owner or groupr  zFix missing owner or group in r  r<  r[   z"Not fixing missing owner or group r  Nr  r  r  r  r  )r
   r   r  r  r   r   ro   r   r   r   r   r;   set_session_infor   r   r   )r   r   r  r  r  r  r  s   &&&    r#   err_missing_sd_ownerdbcheck.err_missing_sd_owner*  s    ("))H,B,BBWVX Y  \B  C  CKK'SUVW{{}**633G3GQ 	

##D$;$;<>>$8!; <CgMO OKKGRHI

##D$<$<=r   c                   V P                   '       d   R # WP                  9   d   R # \        \        P                  V4      pV P                  V\        P                  4      p\        P                  ! VP                  4      p\        P                  ! 4       pV P                  R,          pWe,
          pW8:  d   R # WW,           p	VR,          p
V
^8:  dO   V P                  RV,          4       V P                  R\        P                  ! V	4      VR,          3,          4       MFV P                  RV,          4       V P                  R\        P                  ! V	4      V
3,          4       V P                  RVP                  VP                   VP"                  VP$                  VP&                  \        P                  ! \        P                  ! VP                  4      4      3,          4       V ;P(                  ^,          un        R# )	Fz`SKIPPING additional checks on object %s which very recently became an expired tombstone (normal)zbINFO: it is expected this will be expunged by the next daily task some time after %s, %d hours agoz+SKIPPING: object %s is an expired tombstonezTINFO: it was expected this object would have been expunged soon after%s, %d days agozHisDeleted: attid=0x%08x version=%d invocation=%s usn=%s (local=%s) at %sTQ i  )rk   r   r	   r   r%  rk  r   rL  sambanttime2unixr)  timer8   r   ctimer*  versionoriginating_invocation_idr6  r(  rl   )r   r   repl_valr3  r@  delete_timecurrent_timetombstone_deltar   expunge_time
delta_dayss   &&&        r#   is_expired_tombstonedbcheck.is_expired_tombstoneI  s   ((( 000 (;;XF((w/N/NO	''	(I(IJyy{00LA*#"4l+
?KK ?ACD E KK '  ::l3Uw5GHI J
 KKEJKKK *  ::l3Z@A B
 	^OO%%77--''JJu001R1RSTbV V 	W 	1$r   c                X   \        \        P                  V4      pV P                  V\        P
                  4      p\        P                  ! VP                  4      pV P                  R,          p. pVP                  P                   F  pVP                  \        P
                  8X  d   K$  VP                  VP                  8:  d   KA  VP                  VP                  8:  d   K^  \        P                  ! VP                  4      pW,
          p	W8:  d   K  VP                  V4       K  	  Wc3# )   r  )r	   r   r%  rk  r   rL  r  r  r)  r8   r&  r'  r*  r(  r   )
r   r  r3  r@  r  r  foundr   change_timer   s
   &&        r#   find_changes_after_deletion#dbcheck.find_changes_after_deletion  s    (;;XF((w/N/NO	''	(I(IJ00LAAww'999{{i111((I,M,MM++A,E,EFK-E' LLO)  , r   c                   a  S P                  V4      w  r4\        V4      ^ 8X  d   R# V 3R lpS P                  RV,          4       V! V4       V F  pV! V4       K  	  R# )r   Fc                   <  SP                   P                  V P                  4      pSP	                  RWP                  V P
                  V P                  V P                  V P                  \        P                  ! \        P                  ! V P                  4      4      3,          4       R#   \         d    R T P                  ,          p Li ; i)<unknown:0x%x08x>zA%s: attid=0x%08x version=%d invocation=%s usn=%s (local=%s) at %sN)r=   rt  r*  r   r   r  r  r6  r(  r  r  r  r  r)  )r   attnamer   s   & r#   report_attid8dbcheck.has_changes_after_deletion.<locals>.report_attid  s    8++HHQ KK[!))33))

5#4#4Q5N5N#OP_R R S  8-78s   %B, ,CCz,ERROR: object %s, has changes after deletionT)r  r   r   )r   r   r  r  r@  r  r   s   f&&    r#   has_changes_after_deletion"dbcheck.has_changes_after_deletion  s\    ;;HEu:?	S 	BRGHYAO  r   c                   V P                  V4      w  r4VP                  V P                  4      pVP                  4       pV P                  P                  VVR 7      p. pV F  p	V	P                  V8X  d   K  V	P                  \        P                  8X  d   K7  V	P                  \        P                  8X  d   KX   V P                  P                  V	P                  4      p
VP                  V
4       K  	  \        V4      ^ 8  d;   V P                  RRP                  V4      ,          4       V P                  R4       R# V P!                  RV: RV P"                  : R2R	4      '       g   V P                  R4       R# V P%                  VR
.RV,          4      '       d   V P                  RV,          4       R# R#   \         d    RT	P                  ,          p
 Li ; i)rq  r  zUnexpeted attributes: %sr   z%Not fixing changes after deletion bugNzDelete broken tombstone object z	 deleted z
 days ago?r   r   ra  rb  )r  rs  rv   get_rdn_namer=   ru  r*  r   DRSUAPI_ATTID_nameDRSUAPI_ATTID_lastKnownParentrt  r   r   r   r   r   r   r8   r"  )r   r   r  r  r@  ry  r  	rdn_attid
unexpectedr   r  s   &&&        r#   err_changes_after_deletion"dbcheck.err_changes_after_deletion  s   ;;HE~~dnn5??$%%DDXBN E P	 
Aww)#ww'444ww'???8++HHQ g&  z?QKK2SXXj5IIJKK?@ "D$:$:!<=]_ _KK?@>>"yk2R79 9KK",-9  8-78s   9%F88GGc                   \        \        P                  V4      pVP                  pR pVP                   F  pVP
                  \        P                  ! R4      8w  d   K*  RpV P                  RWP                  VP                  \        P                  ! \        P                  ! VP                  4      4      V P                   P#                  4       3,          4       K  	  V# )F$00000000-0000-0000-0000-000000000000Ta  ERROR: on replPropertyMetaData of %s, the instanceType on attribute 0x%08x,
                           version %d changed at %s is 00000000-0000-0000-0000-000000000000,
                           but should be non-zero.  Proposed fix is to set to our invocationID (%s).)r	   r   r%  r&  r'  r  r   r   r   r*  r  r  r  r  r  r)  r;   get_invocation_id)r   r   repl_meta_datar3  r&  r  r   s   &&&    r#   "has_replmetadata_zero_invocationid*dbcheck.has_replmetadata_zero_invocationid  s    (;;(*hhA**dii8^.__EKK h ww		::e&7&78Q8Q&RS::779;; <  r   c           	     ~   \        \        P                  V4      pVP                  p\        P
                  ! \        \        P                  ! 4       4      4      pR pVP                   F  pVP                  \        P                  ! R4      8w  d   K*  RpV P                  P                  \        P                  4      p	VP                   ^,           Vn        Whn        \        P                  ! V P                  P%                  4       4      Vn	        Wn        Wn        K  	  V'       Ed   \+        V4      p
\        P,                  ! 4       pWn        V P1                  RV: RV: RV P                  P%                  4       : R2R4      '       g   V P3                  RV: RV: R	24       R
# \        P,                  ! 4       pWn        \        P4                  ! V
\        P6                  V4      W&   V P9                  VR\:        P<                  ,          R.RV,          4      '       d   V P3                  RV: RV: R24       R
# R
# R
# )Fr  Tr  r  zK by setting originating_invocation_id on some elements to our invocationID r<  r_   z-Not fixing zero originating_invocation_id in r  Nr  #local_oid:1.3.6.1.4.1.7165.4.3.14:0r  r  r  r  )r	   r   r%  r&  r  unix2nttimer   r  r'  r  r   r   r;   sequence_numberro   SEQ_NEXTr  r)  r  r6  r(  r
   r   r   r   r   r   r   r   r   r  )r   r   r  r  r3  r&  nowr  r   seqreplBlobr  r  s   &&&&         r#   "err_replmetadata_zero_invocationid*dbcheck.err_replmetadata_zero_invocationid  s   (;;(*hhDIIK 01A**dii8^.__E**,,S\\:C		AAI(+%*.))DJJ4P4P4R*SA' #K  5~H++-CF##'+R1M1M1O%QRvx xY]_abc;;=DG++Hc6J6JDQDJ~~d%58c8c%c%J%L:TAC C bIJC r   c                2   \        \        P                  V4      pVP                  pVP                   F)  p V P
                  P                  VP                  4      pK+  	  R#   \         d*    T P                  R TP                  Y!3,          4         R# i ; i)zIERROR: attributeID 0X%0X is not known in our schema, not fixing %s on %s
N)
r	   r   r%  r&  r'  r=   rt  r*  r   r   )r   r   r  r  r3  r&  r   rz  s   &&&&    r#   err_replmetadata_unknown_attid&dbcheck.err_replmetadata_unknown_attid  s    (;;(*hhA''DDQWWM   hlmlslsuyk~~s   %A""/BBc           
     `	   \        \        P                  V4      pR p\        4       p\        4       p/ p	VP	                  V P
                  4      p
VP                  p\        VP                  R,          R R7      Vn        \        VP                  4       EF  p\        RWP                  3,          4       V P                  P                  VP                  4      pVP                  4       V9   Ed8   V P                  RV: RV: RV: R24       V P!                  R	W!VP                  WV,          P                  3,          R
4      '       g)   V P                  RVP                  WV3,          4        R# RpVP#                  VP                  4       VP$                  W,          P$                  8  dt   VP&                  W,          n        VP(                  W,          n        VP*                  W,          n        VP,                  W,          n        VP$                  W,          n        EK  WV&   VP#                  VP                  4       4       EK  	  VP                   Uu. uF  qP                  V9  g   K  VNK  	  pp\/        V4      ^ 8  Ed   V F  pVP                  V9   g   K  V P                  P                  VP                  4      pV P                  P1                  WR7      pV P                  RV: RV: R24       V P!                  RW!VP                  WV,          P                  3,          R4      '       g)   V P                  RVP                  WW!3,          4        R# RpWn        K  	  V'       d   \        VR,          R R7      VR&   V'       gX   V P                  RV: RV: R24       V P!                  RV: RV: R2R4      '       g   V P                  RV: RV: R24       R# \/        V4      Vn        Wn        \5        V4      p\6        P8                  ! 4       pVVn        \6        P<                  ! V\6        P>                  V4      VV&   V PA                  VR\B        PD                  ,          RR.RV,          4      '       d   V P                  RV: RV: R24       R# R# u upi ) F:NNNc                     V P                   # r   r*  r   s   &r#   <lambda>:dbcheck.err_replmetadata_incorrect_attid.<locals>.<lambda>2  s    qwwr   )keyz
%s: 0x%08xz(ERROR: duplicate attributeID values for r:  r  r  zLFix %s on %s by removing the duplicate value 0x%08x for %s (keeping 0x%08x)?r`   z5Not fixing duplicate value 0x%08x for %s in %s on %s
NTrq  z'ERROR: incorrect attributeID values in zEFix %s on %s by replacing incorrect value 0x%08x for %s (new 0x%08x)?ra   zANot fixing incorrect value 0x%08x with 0x%08x for %s in %s on %s
c                     V P                   # r   r  r  s   &r#   r  r  i  s    r   z&ERROR: unsorted attributeID values in r  z by sorting the attribute list?rb   r  r  r  z#local_oid:1.3.6.1.4.1.7165.4.3.25:0r  r  r  r  )#r	   r   r%  r   rs  rv   r&  rH  r'  reversedr
  r*  r=   rt  rI  r   r   r   r(  r  r)  r  r6  r   ru  countr
   ro   r   r   r   r   r   r   r  )r   r   r  r  rw  r3  r?   rv  remove_attidhash_attry  r&  r   rz  new_listr{  r  r  s   &&&&&             r#    err_replmetadata_incorrect_attid(dbcheck.err_replmetadata_incorrect_attid#  s   (;;(*%u~~dnn5hh 399Q<->?	 #))$A,"gg./##@@ICyy{g%Z]_ceghi''(v+/QWWcC=CVCV*W)X(JL L KK X#$77Cr":!; <  ) ;;!8!88
 -.IIHM)<=<U<UHM9>?>Y>YHM;454E4EHM1./kkHM+ SMKK		$? %D  #yyHy!GG<,GAAyH!77l*++HHQC$($5$5$T$TUX$T$tMKKW[]_ `a++,s/3#PS}GZGZ.[-\]{} }$h'(wwD&M%N OC+G  $Xa[6GH KKdTVWX##'+R%12SU UtR@A M		D>{{}''#2F2FMT
>>$!1D4_4_!_!F!F!H 7=? ? KKD"EF	?I Is   R+3R+c                   R pRV9  d%   V P                  RVP                  ,          4       RpRV9  g-   \        VR,          ^ ,          4      P                  4       R8X  d%   V P                  RVP                  ,          4       RpRV9  d%   V P                  RVP                  ,          4       RpR	V9  g-   \        VR	,          ^ ,          4      P                  4       R8X  d%   V P                  R
VP                  ,          4       RpRV9   d%   V P                  RVP                  ,          4       RpRV9   dQ   \        VR,          ^ ,          4      P                  4       R8X  d%   V P                  RVP                  ,          4       RpRV9  gT   \	        VR,          4      ^8w  g=   \        VR,          ^ ,          4      R8w  g   \        VR,          ^,          4      R8w  d%   V P                  RVP                  ,          4       RpRV9  g   \        VR,          ^ ,          4      R8w  d%   V P                  RVP                  ,          4       RpV# )Fdescriptionz>ERROR: description not present on Deleted Objects container %sTshowInAdvancedViewOnlyFALSEzIERROR: showInAdvancedViewOnly not present on Deleted Objects container %sobjectCategoryzAERROR: objectCategory not present on Deleted Objects container %sisCriticalSystemObjectzIERROR: isCriticalSystemObject not present on Deleted Objects container %s
isRecycledz9ERROR: isRecycled present on Deleted Objects container %sr@  z8ERROR: isDeleted not set on Deleted Objects container %sr  top	containerzBERROR: objectClass incorrectly set on Deleted Objects container %ssystemFlags-1946157056zBERROR: systemFlags incorrectly set on Deleted Objects container %s)r   r   r   rK  r   )r   r  faultys   && r#   is_deleted_deleted_objects"dbcheck.is_deleted_deleted_objects  s   #KKX[^[a[aabF#3.#c:R6STU6V2W2]2]2_cj2jKKcfiflfllmF3&KK[^a^d^ddeF#3.#c:R6STU6V2W2]2]2_cj2jKKcfiflfllmF3KKSVYV\V\\]F##c+&6q&9":"@"@"Bg"MKKRUXU[U[[\F#C,>(?1(D(+C,>q,A(Be(K(+C,>q,A(Bk(QKK\_b_e_eefF#s3}+=a+@'A]'RKK\_b_e_eefFr   c                :   \         P                  ! 4       pVP                  ;Vn        pR V9  d*   \         P                  ! R\         P                  R 4      VR &   RV9  d*   \         P                  ! R\         P                  R4      VR&   RV9  d;   \         P                  ! RV P
                  ,          \         P                  R4      VR&   RV9  d*   \         P                  ! R\         P                  R4      VR&   RV9   d*   \         P                  ! R\         P                  R4      VR&   \         P                  ! R\         P                  R4      VR&   \         P                  ! R	\         P                  R
4      VR
&   \         P                  ! RR.\         P                  R4      VR&   V P                  RV,          R4      '       g   V P                  RV,          4       R# V P                  VR.RV,          4      '       d   V P                  RV,          4       R# R# )r  zContainer for deleted objectsr  rC  r  zCN=Container,%sr  r  r@  r  r  r  r  r  zAFix Deleted Objects container %s by restoring default attributes?rc   .Not fixing missing/incorrect attributes on %s
Nr   z+Failed to fix Deleted Objects container  %sz%Fixed Deleted Objects container '%s'
)
ro   r   r   r   r   rv   r=  r   r   r   )r   r  r  r   s   &&  r#   err_deleted_deleted_objects#dbcheck.err_deleted_deleted_objects  s   {{}vv"#"%"4"45TVYVjVjly"zD#3.-0-?-?H\H\^v-wD)*3&%(%7%78IDNN8Z\_\p\p  sC  &DD!"#3.-0-?-?H\H\^v-wD)*3!$!3!3FC<O<OQ]!^D..vs7K7K[Y[!00@T@TVcd]!00%1EsG[G[]jk] c#%!'(EG GKKIRPQ>>$G"LN NKK@BGHNr   c                   \         P                  ! 4       pW$n        V P                  P	                  4       pV P                  P                  4       '       d'   V P                  R V: RVP                  : R24       R# V P                  RVP                  ,          R4      '       g%   V P                  RVP                  ,          4       R# \         P                  ! V\         P                  V4      WC&   V P                  V. RV: RVP                  : 24      '       d&   V P                  R	V: RVP                  : 24       R# R# )
r  r  z for the RODCNz-Add yourself to the replica locations for %s?r~   r  zFailed to add  for r  )ro   r   r   r;   rx   am_rodcr   r   r   rF  r   )r   r  	cross_refr  r  targets   &&&&  r#   err_replica_locationsdbcheck.err_replica_locations  s    {{}--/::KK4HI O#&66!+,CE EKKISVVTU''0@0@$G
>>$svv$NOOKKT366:; Pr   c                    WP                   P                  8X  d   R # WP                  8X  d   R # WP                  8X  d   R # WP                  8X  d   R # WP
                  8X  d   R # R# )TF)r;   rq   rr   rt   rv   rw   rd  s   &&r#   is_fsmo_roledbcheck.is_fsmo_role  sN    %%%'''r   c                h   ^ pV P                   P                  V4      pW8X  dl   V\        P                  ,          p V P                   P	                  VP                  4       \        P                  . R.R7       V\        P                  ,          pV P                  eK   \        V4      V P                   Uu. uF  p\        V4      NK  	  up9   d   V\        P                  ,          pV#   \        P                   d/   pTP                  w  rVT\        P                  8w  d   h  Rp?LRp?ii ; iu upi )r   r   r   N)r;   rc  r   INSTANCE_TYPE_IS_NC_HEADr   r  ro   r   INSTANCE_TYPE_NC_ABOVEr   r   r   r   r   INSTANCE_TYPE_WRITE)r   r   instancetyper   e4r   r   xs   &&      r#   calculate_instancetypedbcheck.calculate_instancetype  s    **((,=D999L<

!!ryy{#..PR^o]p!q  ; ;;>>%#g,4>>:Z>a3q6>:Z*ZD444L << !ww3111 2 ;[s   <C) 5D/)D,>$D''D,c           	         V P                    Fg  w  r#W8X  g   K  \        P                  ! V P                  P	                  4       4      p\        \        P                  V! VV P                  R 7      4      u # 	  \        h)r   )	r{   r   r   r;   r   r	   r  r   r   )r   r   sd_dndescriptor_fnr   s   &&   r#   get_wellknown_sddbcheck.get_wellknown_sd  sg    &*&8&8"U{%--djj.G.G.IJ
!("5"5"/
9=#HI I '9 r   c                  aa	 Vf   R.oM\        V4      o\        R S 4       4      o	VV	3R lpRS	9   g+   RS	9   g$   VP                  4       P                  4       S	9   d#   SP	                  R4       S	P                  R4       RS	9   d#   VP                  4       RR3 F  pV! V4       K  	  R	pRS	9   d   R
pM8S F2  pV P                  V4      w  rgV^ 8X  d   K  V^,          '       d   K0  R
p M	  V'       d	   V! R4       V! R4       SS	3# )zA helper function for check_object() that calculates the list of
attributes that need to be checked, and returns that as a list
in the original case, and a set normalised to lowercase (for
easy existence checks).
*c              3   @   "   T F  qP                  4       x  K  	  R # 5ir   )rI  ).0r0  s   & r#   	<genexpr>/dbcheck.find_checkable_attrs.<locals>.<genexpr>	  s     0%Qwwyy%s   c                    < V P                  4       S9  d3   SP                  V 4       SP                  V P                  4       4       R # R # r   )rI  r   r   )ar,   lc_attrss   &r#   add_attr.dbcheck.find_checkable_attrs.<locals>.add_attr	  s3    wwy(QQWWY' )r   r   distinguishednamenamer@  r  FTrA  r  )rV  r   r  rI  r   r   r7  )
r   r   r   rA  r?  need_replPropertyMetaDatar5  rs  r,   r@  s
   &&&     @@r#   find_checkable_attrsdbcheck.find_checkable_attrs  s    "EE)E0%00	(
 H8+OO##%1LL LL Xoo'!#% %
 %*!(?(,% AA!D	Q;A::,0)  %+,hr   c           
     1   V P                   '       d   V P                  RV,          4       V P                  W4      w  r4 ^ pV\        P                  ,          pV\        P
                  ,          pV\        P                  ,          pV\        P                  ,          pV P                  P                  V\        P                  RRRRV,          R.VR7      p\!        T4      ^8w  d   T P                  R
T,          4       ^# T^ ,          p
^ p\#        4       p\#        4       pRpT P                  P%                  T
P&                  4      p T P)                  T\*        P,                  P.                  4      pR	pR	pR	pRp^ pR	pT
 F  pTP3                  4       R8X  d!   \5        T
T,          ^ ,          4      R8w  d   RpTP3                  4       R8X  d   \7        T
T,          ^ ,          4      pTP3                  4       R8X  g   K}  T
T,          ^ ,          pK  	  T'       dX   T'       dP   T P9                  TT4      '       d   T^,          pT P;                  TT4       T# T P=                  TT4      '       d   T# T
 E	F  pTR8X  g   TR8X  d   K  TP3                  4       R8X  d   RpTP3                  4       R8X  d   \!        T
T,          4      ^8w  dY   T ;P>                  ^,          un        T P                  R\!        T
T,          4      T\5        T
P&                  4      3,          4       M\5        T
T,          ^ ,          4      pTP3                  4       \5        T
P&                  PA                  4       4      P3                  4       8X  d   Tp\!        T
T,          4      ^8w  dY   T ;P>                  ^,          un        T P                  R\!        T
T,          4      T\5        T
P&                  4      3,          4       M\5        T
T,          ^ ,          4      pTP3                  4       R8X  Ed&   T PC                  YT,          ^ ,          4      '       d+   T^,          pT PE                  TTT
T,          ^ ,          4        T PG                  YT,          ^ ,          4      w  ppp\!        T4      \!        T4      8  g!   \!        T4      ^ 8  g   \K        T4      T8w  d-   T^,          pT PM                  TTT
T,          ^ ,          T4       MJT^ ,          ^ 8w  d=   T ;P>                  ^,          un        T P                  RT: R\5        T4      : R24       EK  TP3                  4       R8X  Ed?   T PO                  Y4      w  ppTe    T PQ                  TTT4       T^,          pEK  TPR                  e   TPT                  f   T PW                  TT4       T^,          pEKX  TT8X  g   T PX                  '       d    T P[                  T4      p\]        \        P^                  T
T,          ^ ,          4      pRpT PX                  '       g   Rp\a        TT\        Pb                  ! T P                  Pe                  4       4      TR7      pTR8w  d    T Pg                  TTT4       T^,          pEK"  EK%  TP3                  4       R8X  d   T P                  Pi                  T Pj                  TT
T,          4      p \K        T 4      \K        T
T,          4      8w  g9   T ^ ,          T
T,          ^ ,          8w  g   T Ra,          T
T,          Ra,          8w  d-   T Pm                  TT\o        T
T,          4      4       T^,          pEK  TP3                  4       R8X  Ed   T
T,          ^ ,          p!T!R8X  d'   T^,          pT Pq                  T
TT
T,          4       EKB  T!R,          Rb8X  d   EKS  T!R,          R 8X  d'   T^,          pT Ps                  T
TT
T,          4       EK  T!^,          ^ 8w  d_   T!^,          ^ 8w  dQ   T!^,          ^ 8w  dC   T!^,          ^ 8w  d5   T!^	,          ^ 8w  d'   T^,          pT Pu                  T
TT
T,          4       EK  \!        T!4      ^,          ^ 8w  d   T^,          pT Pw                  T
T4       EK(  T!^,          ^ 8X  d_   T!^,          ^ 8X  dQ   T!^,          ^ 8X  dC   T!^,          ^ 8w  d5   T!^,          ^ 8X  d'   T^,          pT Py                  T
TT
T,          4       EK  TP3                  4       R!8X  g   TP3                  4       R"8X  d   T
T,          ^ ,          T Pz                  9   dQ   T ;P>                  ^,          un        T P                  R#T: R$T
P&                  : R%T
T,          ^ ,          : R&24       M)T Pz                  P}                  T
T,          ^ ,          4       T
T,           F'  p"T"R'8X  g   K  T P                  TT4       T^,          pK)  	   T Pj                  P                  T4      p#T P                  T4      w  p%p&T Pj                  P                  T4      p'T'\,        P                  ,          '       gE   T'\,        P                  ,          '       g(   T%'       g    TP}                  TP3                  4       4       T#\,        P                  \,        P                  \,        P                  \        P                  39   d   YP                  T
TT#4      ,          pM\#        4       p(T
T,           F  p"T(P}                  T"4       T P                  Pi                  T Pj                  TT".4      p \!        T 4      ^8w  g   T ^ ,          T"8w  g   K\  T P                  TTT
T,          4       T^,          p M	  \!        T
T,          4      \!        T(4      8w  d0   T P                  TTT
T,          \o        T(4      4       T^,          p MTP3                  4       R(8X  g   E	K  T P                  T4      p)\!        T
R),          4      ^8w  g"   \7        T
R),          ^ ,          4      T)8w  g   E	K  T^,          pT P                  T
T)4       E	K  	  T'       g)   R*T9   g   RT9   d   T^,          pT P                  T4       R*T9   g   RT9   d   TfE   T ;P>                  ^,          un        T P                  R+\5        T
P&                  4      ,          4       Tf_   T ;P>                  ^,          un        T P                  R,T
P&                  PA                  4       : R\5        T
P&                  4      : R-24       TEew   R	p*RR..p+T'       dI   T\*        P,                  P                  ,          '       g   Tp*T+R/\,        P                  ,          .,          p+T*f   T
P&                  P                  4       p* \        P                  ! T P                  R0T*,          4      p,T,P                  ^ T
P&                  PA                  4       T4       T
P&                  T8X  d   T
P&                  p,T,T
P&                  8w  d!   T^,          pT P                  T
T,TTTT+4       M`T
P&                  P                  4       T8w  dB   T ;P>                  ^,          un        T P                  R1T: R2T: R3T
P&                  : R-24       Rp.T'       Ed   T
P&                  T8X  d   R6p/R7p0T P                  TT/4      p1T1T08w  d   T P                  R8\5        T4      ,          R94      '       dn   \        P                  ! 4       p2TT2n        \        P                  ! R:\        P                  R;4      T2R;&   T^,          pT P                  P                  T2R<.R=7       M!T P                  R>\5        T4      ,          4       TP                  T4       F  p3T.'       d   T P                  R?T,          4       Rp.T^,          pT P                  R@T3,          4       T P                  RAT3,          RB4      '       g   T P                  RCT3,          4       K  T P                  T
T34       K  	  T P                  T4      '       d0   RDT
9  d)   R*T9   g   RET9   d   T P                  T
4       T^,          p YP                  P                  4       8w  de   \5        TP                  4       4      T P                  9  d=   T P                  P                  TP                  4       \        P                  RR.RF7      pYP                  9   d9   R*T9   d2   T P                  T
4      '       d   T P                  T
4       T^,          pT P                   F  w  p5p$TT58X  g   K  RIT
9   g   K  RJp6T P                  P                  4       '       d   RKp6T6T$9  d)   T P                  T
T$P&                  T64       T^,          pKk  Rp7T$T6,           F/  p8\5        T84      T P                  P                  4       8X  g   K-  Rp7K1  	  T7'       d   K  T P                  T
T$P&                  T64       T^,          pK  	  YP                  8X  d   R*T9   g   RLT9   d   RMT
9  d   T^,          pT P                  '       di   T P                  RNRO4      '       dP   T P                  P                  4         T P                  P                  4        T P                  P                  4        M8T P                  P                  4       '       g   T P                  RPT,          4       YP                  8X  Ed_   RQRR.p9T P                  P                  T P                  \        P                  T9RS7      pT9 F  p:T:T^ ,          9  d   K  \7        T^ ,          T:,          ^ ,          4      p;T;^ ,	          p<RTT;,          p=T;^ 8w  g   KN  T=T<8  g   KW  T P                  RUT=T<T=T<3,          4       T ;P>                  ^,          un        K  	  RQT^ ,          9  d2   T P                  RVT,          4       T ;P>                  ^,          un         T P                  P                  4       w  p>p<T P                  Pe                  4       p?T>T<8:  Ed   RWT?T>3,          p@ T P                  P                  RXT@,          \        P                  . RS7      pTe   T P                  RYX@: RZT^ ,          P&                  : R[T: 24       T^,          pT P                  R\T@: R]T: R^2R_4      '       dg   T P                  P                  4          T P                  P                  4       pATAT>8  g   K$  XA^,           p> T P                  P                  4        EK	   T# T>^,          p>EK   T# T#   \        P                   d`   pTP                  w  rT\        P                  8X  d7   T P                  '       d   T P                  RT,          4        R	p?^#  R	p?^ # h R	p?ii ; i  \0         d    R	p ELi ; i  \0         d)    T^,          pT PI                  TTT
T,          4        EK  i ; i  \0         d     EK  i ; i  \         d(   p$T P                  T
T4       T^,          p R	p$?$EK=  R	p$?$ii ; i  \         d:   p-T ;P>                  ^,          un        T P                  R4T* R524        R	p-?-EL(R	p-?-ii ; i  \        P                   d   p4T4P                  w  rT\        P                  8X  db   T'       d:   T P                  RGT
P&                  ,          4       T P                  RH4        R	p4?4ELKT P                  T
4       T^,          p R	p4?4ELkh R	p4?4ii ; i   T P                  P                  4        h ; i  \        P                   d2   p-T-P                  w  rT\        P                  8w  d   h R	p R	p-?-EL)R	p-?-ii ; i   T P                  P                  4        h ; i  \        P                   dK   pBTBP                  w  rT P                  R`T	,          4       T ;P>                  ^,          un         R	pB?BT# R	pB?Bii ; i)czcheck one objectChecking object %sr   r   r   r  r   )r*   r+   r   r,   z)ERROR: Object %s disappeared during checkNz,ERROR: Object %s failed to load during checkF	isdeletedr  Tsystemflagsreplpropertymetadatar   distinguishedNameobjectclassrD  z1ERROR: Not fixing num_values(%d) for '%s' on '%s'z4ERROR: Not fixing incorrect initial attributeID in 'z' on 'z', it should be objectClassntsecuritydescriptor)ignoreAdditionalACEsr/   userparameters    :N   N:N   Ns   IAAgACAAIAAgACAAIAAgattributeid	governsidzError: r  r  z. already exists as an attributeId or governsIdr   r.  r  r9  z(ERROR: Not fixing missing 'name' on '%s'zERROR: Not fixing missing 'rA  r   r  z
RDN=RDN,%szERROR: Not fixing r  z on 'z#ERROR: could not handle parent DN 'z': skipping RDN checksi0  l   )x1cB& z-Fix isDeleted originating_change_time on '%s'rQ   rC  r@  r   r   z4Not fixing isDeleted originating_change_time on '%s'zOn object %sz7ERROR: Attribute %s not present in replication metadataz-Fix missing replPropertyMetaData element '%s'rP   z4Not fixing missing replPropertyMetaData element '%s'r  fsmoroleowner)r*   r+   r   z'WARNING: parent object not found for %szFNot moving to LostAndFound (tombstone garbage collection in progress?)repsFromr2   r3   ridsetreferencesr7   z,Allocate the missing RID set for RID master?r   z^No RID Set found for this server: %s, and we are not the RID Master (so can not self-allocate)rIDAllocationPoolrIDPreviousAllocationPoolr)   l    z!Invalid RID pool %d-%d, %d >= %d!z No rIDAllocationPool found in %sz%s-%dz<SID=%s>zSID r!  z' conflicts with our current RID set in zFix conflict between SID z and RID pool in z by allocating a new RID?rh   zCouldn't get available RIDs: %srq  s                   )vr>   r   rF  r   r  r  r  r  r;   r   ro   r   r   r   r   rn   r   r   rc  r   r   r  r   r   r   rI  r   r   r  r  r  r   r  r  r  r|  r  rH  r  r  r  r  r  r  rj   r6  r	   r  r   r   r   r  rD  r=   rW  rV  r  r  r  r  r  r   r   r>  r  r   r  r7  $get_systemFlags_from_lDAPDisplayNameDS_FLAG_ATTR_NOT_REPLICATEDDS_FLAG_ATTR_IS_CONSTRUCTEDr   DSDB_SYNTAX_OR_NAMEDSDB_SYNTAX_STRING_DNr#  rh  rM  r[  r1  r  re  #SYSTEM_FLAG_DISALLOW_MOVE_ON_DELETEr  r  rp   set_componentr  get_rdn_value
ValueErrorrn  r   r   r   r   r'  
differencer  r(  r  r   r   r  r   r  r  r   r"  r%  rx   r   r   r  create_own_rid_setr  r  r   free_rid_boundsallocate_rid)Cr   r   r   search_attrsr@  r  r   e10r   r   r  r   set_attrs_from_mdset_attrs_seengot_objectclassnc_dndeleted_objects_dnobject_rdn_attrobject_rdn_valr  r@  r  repl_meta_data_valr4  list_attid_from_mdrw  r  r  well_known_sd
current_sdrP  r  rJ  
userparamsrI  r  r  r5  rt  flagrG  r  	parent_dnr   expected_dnrv  show_dnisDeletedAttIdexpectedTimeDooriginatingr  rz  e11dns_partlocationr  loc
pool_attrs	pool_attrpoolhighlownext_free_ridr   sidallocated_ridr!  sC   &&&                                                                r#   r   dbcheck.check_object)	  s   <<<KK,r12 "&!:!:2!O	H...H...H---H---H**##3>>(9(9(8(7((B(<.& +7 $ 8C" s8q=KKFKL!fE

&&svv.	&!%!=!=e>Cjj>j>j"l 	!H~~;.s8}Q'(G3 $I~~=0!#h-"23~~#99%(]1%5"  +..r3EFFq //4FG""((-?@@""H48/B#B~~=0"&~~6)s8}%*))Q.)KK S!$S]!3Xs366{ K!L M  #3x=#34H~~3svv':':'<#=#C#C#EE"*s8}%*))Q.)KK S!$S]!3Xs366{ K!L M &)Xq)9%:N~~#99::28}Q?OPP1$K;;B#h-XYJZ[//M!4DE J&(:L ()C0B,CC,'!+/04FF1$K99"hHVWHXZfg
 *!,1--2-%-s2w%8 9 ~~#99"&//"":Y(%%b"i81$K<<'2<<+?--b"51$K++t/I/I/I!(,(=(=b(A ",H,?,?,/M!,<">J ,1(555/3,'z(0(8(89R9R9T(U=QSD rz11"mTJ#q( ~~=0!ZZAA$BSBSU]_bck_lm
 *%H)>> ms8}Q'77 nHb(9977Hd3x=FYZ1$K~~#33 ]1-
%1$K11#xXO_7_(??1$K223#h-P !mq( mq( mq( mq( mq(  1$K00hHN_q(A-1$K//X> mq( mq( mq( mq( mq(  1$K33C3x=Q~~=0HNN4D4Sx=#t'B'BB))Q.)KK#+SVVS]15E5E!G H //33CM!4DE 8}}#:,,R:1$K	 %!..RRS[\
 )-(M(Mh(W%F%$$II(SD4;;;;t????""8>>#34d88$:R:R"88#--I I }}S(JGG x==CJJsO!%!E!EdFWFWYadgch!iJ:!+z!}/C33B#h-P#q( ) s8}%V4--b(CM4PV<X1$K~~>1*.*E*Eb*I's>*+q0CN8KA8N4OSj4j1$K//5LMk n C8O}7P1K((,8Ov1%%*%F#cff+VW&%%*%H[H[H]_bcfcici_jklI)95H#ejj&T&TTT 2I-0Z0ZZ[[ FFMMO	N!ffTZZ1KL ))!SVV-@-@-BHM66//"%&&K#&&(1$K%%c;*Hh@VV))+~=))Q.)KK_ESEHVV!M N vv++!' "5"778JN[.0''(WZ]^`Za(acvww"{{}"$,/,>,>vsG[G[]h,i[)#q(

))$-)I $Z]`ac]d$de%001BCKK 34#Gq UX[[\''(WZ](]_qrrKK VY\ \]!!#s+ D R  c)sh/U]B]))#.q 	ZZ//11c"))+6Fdkk6Yjj''RYY[2CEU1V ( X 000SH_..s33005q #22OXsX~*"36::%%''=H3&..sCFFHE1$Kx==C3x4::#?#?#AA $ ) u..sCFFHE1$K'  3* ###h"4"@%S0  1$K)))++ -:,HJ J !JJ88:& $

 = = ? !JJ99;!ZZ//11 %9;=%> ?6  -/JKJ**##*4 $ 6C (	CF*3q6),Q/0rz 4'19KK C!$dC 6!7 8))Q.) ( ##a&0>CD%%*%7+&*jj&@&@&B#t "ZZ668
#t+!Z$??C#"jj//Z#5E69nn68 0 : 7:CFIIr%K L#q(++ 03B-8 -G	H H
 !JJ88:&&*48JJ4K4K4MM'4'E8E8I(-
 !JJ99;!  &*Y ,\ {_ || 	88LTs---&&&KK Kb PQ	*  	& "&	&B   1$K77Hc(mTH $ ! !P  **39q B  3%%*%A) M2 2 3 33v || 	88LTs---KK ISVV TUKK !N O O ++C01$K	|& $

 = = ? %R << #'(vv3#9#99!"	#<& $

 = = ? %_ << + XX
=DE%%*%%h o+sS  BAV- *AX$ -#AX8#AY.<AZ(AZ6 B)BA[= KA^ QA`( R$3A^? UA` U2	A` V-AX!W4AXW7AXXAXXAX!X$AX5X4AX5X8.AY+Y*AY+Y.AY>Y=AY>ZAZ3ZAZ.Z.AZ3Z6A[:[.A[5[5A[:[=A^\*A^\=3A^]6A^^A^^A^^A^<^?A`_&A` ` A``A`%`(Ab`=?AbbAbc                   \         P                  ! V P                  R4      pV P                  '       d   V P	                  RV,          4       V P                  P                  V\         P                  R7      p\        V4      ^8w  d   V P	                  RV,          4       ^# V^ ,          p^ pRV9  d   V P	                  R4       V^,           # \        VR,          ^ ,          4      P                  R4      '       EgL   V P	                  R4       V^,          pV P                  R	4      '       g   V# V P                  P                  \         P                  ! V P                  VR,          ^ ,          P                  R
4      4      \         P                  R.R7      p\        \        \        P                  V^ ,          R,          ^ ,          4      4      p\         P                  ! 4       pWn        \         P"                  ! RV,          \         P$                  R4      VR&   V P'                  V. RRR7      '       d   V P	                  R4       V# )z!check the @ROOTDSE special objectz@ROOTDSErI  )r*   r+   z"Object %s disappeared during checkr  z(ERROR: dsServiceName missing in @ROOTDSEz<GUID=z1ERROR: dsServiceName not in GUID form in @ROOTDSEz"Change dsServiceName to GUID form?r1   r  r)   rB  z+Failed to change dsServiceName to GUID formFr   z"Changed dsServiceName to GUID form)ro   rp   r;   r>   r   r   r   r   r   r	  r  r   r	   r   r   r   r   r   r   r   )r   r   r   r  r   r  r(  s   &      r#   r   dbcheck.check_rootdseU  s   VVDJJ
+<<<KK,r12jjRs~~>s8q=KK<rAB!f #%KKBC?"3'*+66x@@KKKL1K<< DEE""**##

C<PQR<S<Z<Z[a<b)c*-.. $ PC:diiQ1Ea1HIJHAD!$!3!3K(4J474H4H/"[Ao~~a%R]b~cc@Ar   c                F   \         P                  ! 4       p\         P                  ! V P                  R4      Vn        \         P
                  ! R\         P                  R4      VR&   \         P
                  ! R\         P                  R4      VR&   V P                  V. RRR7      # )	zre-index the whole databasez@ATTRIBUTESr  force_reindexr   r  zre-indexed databaseFr   )	ro   r   rp   r;   r   r   rF  r=  r   r   r(  s   & r#   reindex_databasedbcheck.reindex_databasey  sw    KKMvvdjj-0((1A1A?S%((1D1DoV(~~a%:U~KKr   c                    \         P                  ! 4       p\         P                  ! V P                  R4      Vn        \         P
                  ! R\         P                  R4      VR&   V P                  V. RRR7      # )zOreset @MODULES to that needed for current sam.ldb (to read a very old database)z@MODULES
samba_dsdbz@LISTzreset @MODULES on databaseFr   )ro   r   rp   r;   r   r   r   r   r  s   & r#   reset_modulesdbcheck.reset_modules  sY    KKMvvdjj*-''c6J6JGT'
~~a%AE~RRr   )Qr   r   rk   rz   rB   r9   r   r<   r   r   rW   rl   r?   rG   rL   rM   rN   rH   rF   rP   rS   rU   r|   rE   rO   rT   rK   re   r   rc   rd   rg   r^   r}   r   rZ   r[   r~   r`   rb   ra   r_   rY   rh   rQ   rR   rf   rn   rr   r   r   r]   r   rt   r   r   ry   ri   rA   rX   rD   rC   rI   rJ   r:   rm   rj   rw   r   r;   r=   rv   r\   r   r   r8   r   r>   r{   r   r@   )
NFFFFFFFFF)FF)T)Fr   )S__name__
__module____qualname____firstlineno____doc__r   r   r   ro   r$  r   r   r   r  r   r"  r   r/  r7  r>  rM  rW  r[  r   re  rn  rw  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r=  rh  rk  rn  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r(  r1  r6  rF  r   r   r  r  __static_attributes____classdictcell__)__classdict__s   @r#   r&   r&   8   s    )Oyv !%C,=,=!%NiV(G*&	A>>>*N$U.I.SjI@I L$]"M@EE GFH(C&m"!,FA*wOnp i4\
?:BBd4LhT	3,B .,gRJ"J*>>4l  D2".H(#KJ
]G~<I8<$$/bhXHLS Sr   r&   )%ro   r  r  base64r   r   r   r   samba.dcerpcr   r   	samba.ndrr	   r
   r   samba.samdbr   r   samba.descriptorr   r   r   
samba.authr   r   samba.netcmdr   samba.netcmd.fsmor   samba.colourr   r   r   r   r$   r   r&    r   r#   <module>r     s[   (    '      * !  ! 
 5 % 0 H HP-Sf P-Sr   