+
    cj)                     F   R t ^ RIt^ RIt ^ RIt^ RIHu H	t
 ^ RIHt R tR tR tR tR tR	]R
]R]R]R]R]/tR tR tR tR tR tR tR tRR lt]R8X  d   ^ RItRt]! ]P>                  4      ^ 8X  d?   ] ! R]P>                  ^ ,          ,          ]PB                  R7       ]PD                  ! ^4       ]P>                  ^,          t#]! ]P>                  4      ^8  d   ]P>                  ^,          t]! ]#]4       R# R#   ] d   t]P                  R4       h RtAii ; i)z(Generate LDIF from Github documentation.Nz'Please install python3-markdown package)
get_stringc                     R R . R 3# N description
attributessds   &&&B/usr/lib/python3/dist-packages/samba/ms_forest_updates_markdown.pynoopr   %   s    $D!!    c                 0   V P                  R 4      '       dc   V P                  R4      '       dL   V'       dD   VP                  4       R8X  d/   V'       d'   VP                  4       R8X  d   R\        V 4      RR.R3# RR. VP                  4       R8w  d   V3# R3# )zGranting the zto gMSA accounts.n/amodifyzadd: appliesToz/appliesTo: 7b8b558a-93a5-4af7-adca-c017e67f1057N)
startswithendswithlowerextract_dn_or_noner   s   &&&r
   parse_grantr   *   s    //011	
((*e3	
e#,[9!#TU 	 dBbhhjE&9DDtDDr   c                 f    \        V 4      pR T\        W14      VP                  4       R8w  d   V3# R3# )addr   N)
extract_dnextract_attribr   )r   r   r	   dns   &&& r
   	parse_addr   8   s6    	K	 B2~b5RXXZ5=Pr[[VZ[[r   c                 b    R \        V 4      \        V4      VP                  4       R8w  d   V3# R3# )r   r   N)r   extract_replace_attribr   r   s   &&&r
   	parse_setr   >   s<    (5":.((*%B1 1+/1 1r   c                 x    R  pRV! V 4      ^ ,          RRV,          .R3RV! V 4      ^,          RRV,          .R3.# )c                 *    R V 9   d   R# RV 9   d   R# R# )z
Sam-Domainz
Domain-DNSN)z${DOMAIN_DN}zCN=Sam-Domain,${SCHEMA_DN})z${...}zCN=Domain-DNS,${SCHEMA_DN}r   texts   &r
   extract_dn_ace!parse_ace.<locals>.extract_dn_aceH   s!    4AAT!;;r   r   zreplace: nTSecurityDescriptorz+nTSecurityDescriptor: ${DOMAIN_SCHEMA_SD}%sNz"replace: defaultSecurityDescriptorz,defaultSecurityDescriptor: ${OLD_SAMBA_SD}%sr   )r   r   r	   r"   s   &&& r
   	parse_acer$   F   si     ~k215-;b@BCGI ~k2152<rACDHJK Kr   GrantingCreatedSet	Added ACEUpdatedCallc                   V P                  RR4      p V P                  RR4      p \        P                  ! RV 4      P                  ^ 4      pVR8X  d   R# VP	                  R4      '       d   VP                  R	R
4      pVR,           # V# )zS
Extract a DN from the textual description
:param text:
:return: DN in string form
z in the Schema partition.z,${SCHEMA_DN}z  in the Configuration partition.z,${CONFIG_DN}z!([CDO][NCU]=.*?,)*([CDO][NCU]=.*)zQCN=ad://ext/AuthenticationSilo,CN=Claim Types,CN=Claims Configuration,CN=Servicesz^CN=ad://ext/AuthenticationSilo,CN=Claim Types,CN=Claims Configuration,CN=Services,${CONFIG_DN}z&,CN=Extended-Rights" to gMSA accounts.z" to gMSA accounts. )replaceresearchgroupr   )r!   r   s   & r
   r   r   i   s     <<3_ED<<:OLD	6	=	C	CA	FB 
``o 
{{;<<ZZ-r2O##Ir   c                *     \        V 4      #     R# ; i)zU
Same as above, but returns None if it doesn't work
:param text:
:return: DN or None
N)r   r    s   &r
   r   r      s    $s   
 c                   \         P                  P                  W 4      p\        VR4      ;_uu_ 4       pV F  pVw  rgrVP	                  RV,          4       VP	                  RV,          4       \        V4      ^ 8  d(   VP	                  RP                  V4      R,           4       V	e   VP	                  RV	,          4       VP	                  R4       K  	  RRR4       R#   + '       g   i     R# ; i)z
Save ldif to disk for each updates
:param filename: filename use ([OPERATION NUM]-{GUID}.ldif)
:param answers: array of tuples generated with earlier functions
:param out_folder: folder to prepend
wdn: %s
changetype: %s

NnTSecurityDescriptor: D:%s
-

)ospathjoinopenwritelen)
filenameanswers
out_folderr:   ldifanswerchanger   attribr	   s
   &&&       r
   	save_ldifrF      s     77<<
-D	dCDF%+"FJJzB'JJ)F236{Q

499V,t34~

9B>?JJw  
s   B#C!!C2	c                   RpV Ft  pVw  rVrxVRV,          ,          pVRV,          ,          p\        V4      ^ 8  d    VRP                  V4      R,           ,          pVe   VRV,          ,          pVR,          pKv  	  W2V &   R# )z
Save ldif to an output dictionary
:param guid: GUID to store
:param answers: array of tuples generated with earlier functions
:param out_dict: output dictionary
r,   r4   r5   r6   Nr7   r8   )r>   r;   )	guidr@   out_dictrB   rC   rD   r   rE   r	   s	   &&&      r
   
save_arrayrJ      s     D!'F
R"V++v;?DIIf%,,D>2R77D  TNr   c                   VP                  R4       Uu. uF3  q"P                  4       R8w  g   K  VR8w  g   K"  VP                  R4      NK5  	  ppV Uu. uF-  q"P                  R4      '       d   VP	                  RR4      MTNK/  	  ppV Uu. uF-  q"P                  R4      '       d   VP	                  RR4      MTNK/  	  ppV Uu. uF+  q"P                  4       P                  R	4      '       d   K)  VNK-  	  ppV# u upi u upi u upi u upi )
z
Extract the attributes as an array from the attributes column
:param dn: parsed from markdown
:param attributes: from markdown
:return: attribute array (ldif-type format)
-   r   r,   - z: Truez: TRUEz: Falsez: FALSEzmsds-claimpossiblevalues)splitr   lstripr   r-   r   )r   r   xrE   s   &&  r
   r   r      s     '1&6&6v&>a&>'')uBTnYZ^`Y`nahhtn&>FaTZ[TZqzz(/C/Caii(+JTZF[W]^W]RSI1F1Faii	9-AMW]F^XAwwy';';<V'WaaFXM b[^Xs'   C:C:C:3C?3D&D	0D	c                V   V P                  R4       Uu. uF3  qP                  4       R8w  g   K  VR8w  g   K"  VP                  R4      NK5  	  ppV Uu. uF$  pRVP                  R4      ^ ,          ,          V3NK&  	  ppV UUu. uF  qD F  q3NK  	  K  	  pppV# u upi u upi u uppi )z
Extract the attributes as an array from the attributes column
(for replace)
:param attributes: from markdown
:return: attribute array (ldif-type format)
rL   r   r,   rM   zreplace: %s:)rN   r   rO   )r   rP   lineslinepairs   &    r
   r   r      s     &0%5%5f%=`%=eAS^XY]_X_^QXXd^%=E`DIJEDmdjjoa00$7EEJ#5edTTeE5L aJ5s   BBB*B B%c                     V P                   ;'       g    R R P                  R V  4       4      ,           V P                  ;'       g    R ,           # )r,   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   )	innertext).0es   & r
   	<genexpr>innertext.<locals>.<genexpr>   s     *c	!cs   )r!   r;   tail)tags   &r
   rX   rX      s=    HHNN
*c**+	R r   c           	     ~   \        V 4      ;_uu_ 4       pVP                  4       p\        P                  ! RRV4      p\        P                  ! RRV4      p\        P                  ! RRV4      p\        P                  ! VRR7      pR	R	R	4       XP                  R
R4      p\        P                  ! RV,           R,           4      pV EF  pVP                  '       g   K  R	pVP                  P                  R4      '       da   \        \        P                  ! VRR7      4      P                  4        U	u. uF&  q^\        V	4      ^,
           P                  R4      NK(  	  pp	MVP                  P                  R4      '       d`   \        \        P                  ! VRR7      4      P                  4        U	u. uF&  q^\        V	4      ^,
           P                  R4      NK(  	  pp	V'       g   EK&  VR,           EF  p
\        P                  ! RV
^ ,          4      pV'       d:   VP!                  ^4      pVP!                  ^4      P#                  ^4      : RV: R2pRpV
^,          P                  R4      '       g   V
^,          P                  R4      '       dm   V
^,          P                  R4      R,          V
^&   \%        V
^,          V
^,          V
^,          4      pX'       d   Ve   \'        WV4       M\)        XW4       EK  \*         Fw  pV
^,          P                  V4      '       g   K#  Rp\*        V,          ! V
^,          V
^,          V
^,          4      pX'       d   Ve   \'        W.V4       M\)        XV.V4        M	  V'       d   EK  \-        V
4      h	  EK  	  R	#   + '       g   i     EL%; iu up	i u up	i )z
Read Github documentation to produce forest wide updates
:param in_file: Forest-Wide-Updates.md
:param out_folder: output folder
:param out_dict: output dictionary
z<p>z<br />zCN=\\<forest root domainzCN=<forest root domainzCN=<forest root domain.*?>z${FOREST_ROOT_DOMAIN}xhtml)output_formatNzCN=Schema,%wsz${SCHEMA_DN}z<root>z</root>z
|Operationr!   )method|z| Operationz | :   NNzOperation (\d+): {(.*)}z-{z}.ldifFr&   r(   rR   T)r<   readr.   submarkdownr-   ET
fromstringr!   r   r   tostring
splitlinesr>   rN   matchr0   zfillr$   rF   rJ   operation_map	Exception)in_filerA   rI   update_filecontenthtmltreenodeupdatesrP   updateoutputrH   r?   foundresult	operations   &&&              r
   read_ms_markdownr}      s    
g+""$&&! " &&41 " &&60 "   /68 
$ <<8D==D945Dyyy99-- ""++d6"BCNNPRP 783q6A:,,S1P  RGYY!!-00 ""++d6"BCNNPRP 9:3q6A:,,U3P  R7!"++"<fQiH!<<?D17a1F1Fq1I4PH!9''	22fQi6J6J;6W6W !'q	 4R 8F1I&vay&)VAYGFJ$:!(J?"4:!.Iay++I66 $!.y!9&)VAYPVWXPY!Z#
(>%h*E&tfXx@ "/ u#F++K & - 
8RRs   A1N!1,N52,N:!N2	__main__r,   z4Usage: %s <Forest-Wide-Updates.md> [<output folder>])file)NN)$__doc__r.   r9   rh   ImportErrorrZ   add_notexml.etree.ElementTreeetreeElementTreeri   samba.commonr   r   r   r   r   r$   ro   r   r   rF   rJ   r   r   rX   r}   __name__sysrA   r>   argvprintstderrexitrq   r   r   r
   <module>r      s9  . / 	 	
 # " #"

E\1K* y	9y
D ,	 (* 
P,j zJ
388}DQRT[^[e[efhhqkG
388}qXXa[
Wj) _  
JJ89	
s   D D 	DD 