Ë
    þI¶d@/  ã                   óî   — d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZmZmZ  G d„ de«      Z G d„ d	e«      Z G d
„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)é    N)Ú	bitFields)Úsystem_session)ÚSamDB)ÚCommandÚCommandErrorÚSuperCommandÚOptionc            	       ó    — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dde¬«       e
ddd	ed
d¬«      gZdgZ	 	 dd„Zy)Úcmd_schema_attribute_modifya¸  Modify attribute settings in the schema partition.

    This commands allows minor modifications to attributes in the schema. Active
    Directory does not allow many changes to schema, but important modifications
    are related to indexing. This command overwrites the value of searchflags,
    so be sure to view the current content before making changes.

    Example1:
    samba-tool schema attribute modify uid \
        --searchflags="fATTINDEX,fPRESERVEONDELETE"

    This alters the uid attribute to be indexed and to be preserved when
    converted to a tombstone.

    Important search flag values are:

    fATTINDEX: create an equality index for this attribute.
    fPDNTATTINDEX: create a container index for this attribute (ie OU).
    fANR: specify that this attribute is a member of the ambiguous name
         resolution set.
    fPRESERVEONDELETE: indicate that the value of this attribute should be
         preserved when the object is converted to a tombstone (deleted).
    fCOPY: hint to clients that this attribute should be copied.
    fTUPLEINDEX: create a tuple index for this attribute. This is used in
          substring queries.
    fSUBTREEATTINDEX: create a browsing index for this attribute. VLV searches
          require this.
    fCONFIDENTIAL: indicate that the attribute is confidential and requires
          special access checks.
    fNEVERVALUEAUDIT: indicate that changes to this value should NOT be audited.
    fRODCFILTEREDATTRIBUTE: indicate that this value should not be replicated to
          RODCs.
    fEXTENDEDLINKTRACKING: indicate to the DC to perform extra link tracking.
    fBASEONLY: indicate that this attribute should only be displayed when the
           search scope of the query is SCOPE_BASE or a single object result.
    fPARTITIONSECRET: indicate that this attribute is a partition secret and
           requires special access checks.

    The authoritative source of this information is the MS-ADTS.
    ú%prog attribute [options]©Ú	sambaoptsÚversionoptsÚcredoptsz--searchflagszSearch Flags for the attribute)ÚhelpÚtypeú-Hú--URLú%LDB URL for database or target serverÚURLÚH©r   r   ÚmetavarÚdestÚ	attributeNc                 ó  — |€t        d«      ‚d }|�ƒd}|j                  d«      }|D �	cg c]   }	|	j                  «       j                  «       ‘Œ" }}	|D ]@  }
|
t        d   j                  «       vrt        d|
z  «      ‚dt        d   |
   z
  }|d|z  z  }ŒB |j                  «       }|j                  |«      }t        |t        «       ||¬«      }|j                  «       }d	|›d|›�}t        j                  «       }t        j                  ||«      |_        |�1t        j                  t!        |«      t        j"                  d
«      |d
<   |j%                  |«       |j'                  «        | j(                  j+                  d|z  «       y c c}	w )Nz#A value to modify must be provided.r   ú,Úsearchflagsz$Unknown flag '%s', please see --helpé   é   ©ÚurlÚsession_infoÚcredentialsÚlpzcn=ÚsearchFlagszmodified %s)r   ÚsplitÚ
capitalizeÚswapcaser   ÚkeysÚget_loadparmÚget_credentialsr   r   Ú	schema_dnÚldbÚMessageÚDnÚdnÚMessageElementÚstrÚFLAG_MOD_REPLACEÚmodifyÚset_schema_update_nowÚoutfÚwrite)Úselfr   r   r   r   r   r   Úsearchflags_intÚflagsÚxÚflagÚbit_locr%   ÚcredsÚsamdbr-   Úattr_dnÚms                     ú5/usr/lib/python3/dist-packages/samba/netcmd/schema.pyÚrunzcmd_schema_attribute_modify.runY   sƒ  € ð ÐÜÐDÓEÐEð ˆØÐ"ØˆOØ×%Ñ% cÓ*ˆEð 9>Ö>°1�Q—\‘\“^×,Ñ,Õ.Ð>ˆEÐ>Øò C�Øœy¨Ñ7×<Ñ<Ó>Ñ>Ü&Ð'MÐPTÑ'TÓUÐUØœy¨Ñ7¸Ñ=Ñ=�à"1°Q¸'±\Ñ"B‘ðCð ×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð —O‘OÓ%‰	â )©9Ð5ˆä�K‰K‹MˆÜ�v‰v�e˜WÓ%ˆŒàÐ&Ü"×1Ñ1Ü�OÓ$¤c×&:Ñ&:¸Mó KˆAˆmÑð 	�‰�QŒØ×#Ñ#Ô%Ø�	‰	�‰˜¨Ñ/Õ0ùò7 ?s   ©%F)NNNNN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚsynopsisÚoptionsÚSambaOptionsÚVersionOptionsÚCredentialsOptionsÚtakes_optiongroupsr	   r3   Útakes_optionsÚ
takes_argsrD   © ó    rC   r   r       st   „ ñ'ðP +€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆÐ%EÈCÔPÙˆt�WÐ#JØ ¨Sô	2ð€Mð �€Jà>BØ*.ô)1rS   r   c                   óˆ   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«      gZd
gZdd„Zy)Úcmd_schema_attribute_showzÑShow details about an attribute from the schema.

    Schema attribute definitions define and control the behaviour of directory
    attributes on objects. This displays the details of a single attribute.
    r   r   r   r   r   r   r   r   r   Nc                 ó¦  — |j                  «       }|j                  |«      }t        |t        «       ||¬«      }|j	                  «       }	dj                  |«      }
|j                  |	t        j                  |
¬«      }t        |«      dk(  rt        d|z  «      ‚t        |«      dkD  rt        d|z  «      ‚d|d   j                  «       v rªd }	 t        t        |d   d   «      «      }g }t        d
   j                  «       D ],  }|ddt        d
   |   z
  z  z  dk7  sŒ|j!                  |«       Œ. t        |«      dkD  r7|d   j#                  t        j$                  |t        j&                  d«      «       |j)                  |d   t        j*                  «      }| j,                  j/                  |«       y # t        $ r t        d	|d   d   z  «      ‚w xY w)Nr!   zJ(&(objectClass=attributeSchema)(|(lDAPDisplayName={0})(cn={0})(name={0})))©ÚbaseÚscopeÚ
expressionr   zNo schema objects matched "%s"r    zPMultiple schema objects matched "%s": this is a serious issue you should report!r&   zJInvalid schemaFlags value "%s": this is a serious issue you should report!r   r   ÚsearchFlagsDecoded)r+   r,   r   r   r-   ÚformatÚsearchr.   ÚSCOPE_SUBTREEÚlenr   r*   Úintr3   Ú
ValueErrorr   ÚappendÚaddr2   ÚFLAG_MOD_ADDÚ
write_ldifÚCHANGETYPE_NONEr7   r8   )r9   r   r   r   r   r   r%   r?   r@   r-   ÚfiltÚresÚflags_iÚoutr=   Ú	user_ldifs                   rC   rD   zcmd_schema_attribute_show.runš   sÙ  € Ø×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð —O‘OÓ%ˆ	à[×bÑbÐclÓmˆà�l‰l 	´×1BÑ1BØ&*ð ó ,ˆô ˆs‹8�qŠ=ÜÐ?À)ÑKÓLÐLÜˆs‹8�aŠ<ÜÐqÐt}Ñ}Ó~Ð~ð& ˜C ™FŸK™K›MÑ)ØˆGðIäœc # a¡&¨Ñ"7Ó8Ó9�ð ˆCÜ! -Ñ0×5Ñ5Ó7ò %�Ø˜a B¬°=Ñ)AÀ$Ñ)GÑ$GÑHÑIÈQÓNØ—J‘J˜tÕ$ð%ô �3‹x˜!Š|Ø�A‘—
‘
œ3×-Ñ-¨c´3×3CÑ3CÐEYÓZÔ[à×$Ñ$ S¨¡V¬S×-@Ñ-@ÓAˆ	Ø�	‰	�‰˜	Õ"øô ò IÜ"Ð#oÐruÐvwÑrxð  zGñ  sHñ  $Hó  Ið  IðIús   ÃF2 Æ2G©NNNNrE   rR   rS   rC   rU   rU   …   s`   „ ñð
 +€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JØ ¨Sô	2ð€Mð
 �€Jô4#rS   rU   c                   óˆ   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«      gZd
gZdd„Zy)Úcmd_schema_attribute_show_ocz©Show what objectclasses MAY or MUST contain an attribute.

    This is useful to determine "if I need uid, what objectclasses could be
    applied to achieve this."
    r   r   r   r   r   r   r   r   r   Nc                 ó€  — |j                  «       }|j                  |«      }t        |t        «       ||¬«      }|j	                  «       }	dj                  |«      }
dj                  |«      }|j                  |	t        j                  |
dg¬«      }|j                  |	t        j                  |dg¬«      }| j                  j                  d«       |D ]&  }| j                  j                  d|d   d   z  «       Œ( | j                  j                  d	«       |D ]&  }| j                  j                  d|d   d   z  «       Œ( y )
Nr!   zE(&(objectClass=classSchema)(|(mayContain={0})(systemMayContain={0})))zG(&(objectClass=classSchema)(|(mustContain={0})(systemMustContain={0})))Úcn)rX   rY   rZ   Úattrsz--- MAY contain ---
z%s
r   z--- MUST contain ---
)r+   r,   r   r   r-   r\   r]   r.   r^   r7   r8   )r9   r   r   r   r   r   r%   r?   r@   r-   Úmay_filtÚ	must_filtÚmay_resÚmust_resÚmsgs                  rC   rD   z cmd_schema_attribute_show_oc.runæ   s6  € Ø×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð —O‘OÓ%ˆ	ð9ß9?¹À	Ó9Jð 	ð;ß;A¹6À)Ó;Lð 	ð —,‘, I´S×5FÑ5FØ*2¸4¸&ð ó Bˆà—<‘< Y´c×6GÑ6GØ+4¸T¸Fð  ó Dˆð 	�	‰	�‰Ð/Ô0Øò 	3ˆCØ�I‰I�O‰O˜F S¨¡Y¨q¡\Ñ1Õ2ð	3ð 	�	‰	�‰Ð0Ô1Øò 	3ˆCØ�I‰I�O‰O˜F S¨¡Y¨q¡\Ñ1Õ2ñ	3rS   rl   rE   rR   rS   rC   rn   rn   Ñ   s`   „ ñð
 +€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JØ ¨Sô	2ð€Mð
 �€Jô3rS   rn   c                   óˆ   — e Zd ZdZdZej                  ej                  ej                  dœZ	 e
dddedd¬	«      gZd
gZdd„Zy)Úcmd_schema_objectclass_showzòShow details about an objectClass from the schema.

    Schema objectClass definitions define and control the behaviour of directory
    objects including what attributes they may contain. This displays the
    details of an objectClass.
    z%prog objectclass [options]r   r   r   r   r   r   r   ÚobjectclassNc                 ó~  — |j                  «       }|j                  |«      }t        |t        «       ||¬«      }|j	                  «       }	dj                  |«      }
|j                  |	t        j                  |
¬«      }|D ]=  }|j                  |t        j                  «      }| j                  j                  |«       Œ? y )Nr!   zF(&(objectClass=classSchema)(|(lDAPDisplayName={0})(cn={0})(name={0})))rW   )r+   r,   r   r   r-   r\   r]   r.   r^   re   rf   r7   r8   )r9   ry   r   r   r   r   r%   r?   r@   r-   rg   rh   rv   rk   s                 rC   rD   zcmd_schema_objectclass_show.run  s³   € Ø×#Ñ#Ó%ˆØ×(Ñ(¨Ó,ˆä˜!¬.Ó*:Ø"'¨Bô0ˆð —O‘OÓ%ˆ	ð=ß=C¹VÀKÓ=Pð 	ð �l‰l 	´×1BÑ1BØ&*ð ó ,ˆð ò 	'ˆCØ×(Ñ(¨¬c×.AÑ.AÓBˆIØ�I‰I�O‰O˜IÕ&ñ	'rS   rl   rE   rR   rS   rC   rx   rx     s`   „ ñð -€Hð ×)Ñ)Ø×-Ñ-Ø×.Ñ.ñÐñ 	ˆt�WÐ#JØ ¨Sô	2ð€Mð
  �€Jô'rS   rx   c                   óP   — e Zd ZdZi Z e«       ed<    e«       ed<    e«       ed<   y)Úcmd_schema_attributez4Query and manage attributes in the schema partition.r5   ÚshowÚshow_ocN)rF   rG   rH   rI   Úsubcommandsr   rU   rn   rR   rS   rC   r|   r|   ,  s1   „ Ù>Ø€KÙ7Ó9€K�ÑÙ3Ó5€K�ÑÙ9Ó;€K�	ÒrS   r|   c                   ó(   — e Zd ZdZi Z e«       ed<   y)Úcmd_schema_objectclassz7Query and manage objectclasses in the schema partition.r}   N)rF   rG   rH   rI   r   rx   rR   rS   rC   r�   r�   4  s   „ ÙAØ€KÙ5Ó7€K�ÒrS   r�   c                   ó<   — e Zd ZdZi Z e«       ed<    e«       ed<   y)Ú
cmd_schemazSchema querying and management.r   ry   N)rF   rG   rH   rI   r   r|   r�   rR   rS   rC   rƒ   rƒ   :  s$   „ Ù)à€KÙ3Ó5€K�ÑÙ!7Ó!9€K�ÒrS   rƒ   )r.   Úsamba.getoptÚgetoptrK   Úsamba.ms_schemar   Ú
samba.authr   Úsamba.samdbr   Úsamba.netcmdr   r   r   r	   r   rU   rn   rx   r|   r�   rƒ   rR   rS   rC   ú<module>rŠ      s|   ðó& Ý Ý %Ý %Ý ÷ó ôb1 'ô b1ôJI# ô I#ôX.3 7ô .3ôb'' 'ô ''ôT<˜<ô <ô8˜\ô 8ô:�õ :rS   