o
    ßý°jB7  ã                   @   s|  d Z ddlmZ ddlmZmZmZm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 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 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% 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/m0Z0 ddl1m2Z2 G dd„ de3ƒZ4G dd„ de4ƒZ5G dd „ d e4ƒZ6G d!d"„ d"e4ƒZ7G d#d$„ d$e4ƒZ8d%S )&Ú
é    )Úlinesepé   )ÚSUBTREEÚDEREF_ALWAYSÚALL_ATTRIBUTESÚDEREF_NEVERé   )ÚDirSync)Úad_modify_password)Úad_unlock_account)Úad_add_members_to_groups)Úad_remove_members_from_groups)ÚADPersistentSearch)ÚPartitionEntryCount)ÚReplicaInfo)ÚListReplicas)Ú	GetBindDn)ÚNmasGetUniversalPassword)ÚNmasSetUniversalPassword)ÚStartTransaction)ÚEndTransaction)Úedir_add_members_to_groups)Úedir_remove_members_from_groups)Úedir_check_groups_memberships)ÚWhoAmI)ÚModifyPassword)Úpaged_search_generatorÚpaged_search_accumulator)ÚPersistentSearchc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚExtendedOperationContainerc                 C   s
   || _ d S ©N)Ú_connection©ÚselfÚ
connection© r&   úˆ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/ldap3/extend/__init__.pyÚ__init__5   s   
z#ExtendedOperationContainer.__init__c                 C   s   t  dd„ t| ƒD ƒ¡S )Nc                 S   s    g | ]}|d  dkrd| ‘qS )r   Ú_z  r&   )Ú.0Úelementr&   r&   r'   Ú
<listcomp>9   s     z7ExtendedOperationContainer.__repr__.<locals>.<listcomp>)r   ÚjoinÚdir©r$   r&   r&   r'   Ú__repr__8   s   z#ExtendedOperationContainer.__repr__c                 C   s   |   ¡ S r!   )r0   r/   r&   r&   r'   Ú__str__;   s   z"ExtendedOperationContainer.__str__N)Ú__name__Ú
__module__Ú__qualname__r(   r0   r1   r&   r&   r&   r'   r    4   s    r    c                   @   s”   e Zd Zddd„Z						ddd„Zeeddddddddd	fd
d„Zddeee	dddd	d	d	d	d	d	d	dfdd„Z
ddeee	dddddf
dd„ZdS )ÚStandardExtendedOperationsNc                 C   ó   t | j|ƒ ¡ S r!   )r   r"   Úsend©r$   Úcontrolsr&   r&   r'   Úwho_am_i@   ó
   ÿÿz#StandardExtendedOperations.who_am_ic                 C   s   t | j||||||ƒ ¡ S r!   )r   r"   r7   )r$   ÚuserÚold_passwordÚnew_passwordÚhash_algorithmÚsaltr9   r&   r&   r'   Úmodify_passwordD   s   úúz*StandardExtendedOperations.modify_passwordr   Féd   Tc                 C   sH   |rt | j|||||||||	|
||ƒS t| j|||||||||	|
||ƒS r!   )r   r"   r   )r$   Úsearch_baseÚsearch_filterÚsearch_scopeÚdereference_aliasesÚ
attributesÚ
size_limitÚ
time_limitÚ
types_onlyÚget_operational_attributesr9   Ú
paged_sizeÚpaged_criticalityÚ	generatorr&   r&   r'   Úpaged_searchT   s:   ôôz'StandardExtendedOperations.paged_searchÚ ú(objectclass=*)c                 C   s`   d}|
r|d7 }|r|d7 }|r|d7 }|r|d7 }|rd}t | j|||||||||	||||ƒS )Nr   r	   r   é   é   F©r   r"   )r$   rC   rD   rE   rF   rG   rH   rI   r9   Úchanges_onlyÚshow_additionsÚshow_deletionsÚshow_modificationsÚshow_dn_modificationsÚnotificationsÚ	streamingÚcallbackÚevents_typer&   r&   r'   Úpersistent_search€   s4   óz,StandardExtendedOperations.persistent_searchc                 C   s$   t | j||||||||d d d |	|
ƒS r!   rT   )r$   rC   rD   rE   rF   rG   rH   rI   r9   r[   r\   r&   r&   r'   Úfunnel_search­   s   óz(StandardExtendedOperations.funnel_searchr!   )NNNNNN)r2   r3   r4   r:   rA   r   r   rO   r   r   r^   r_   r&   r&   r&   r'   r5   ?   sb    

ú
ó-
ð.ör5   c                   @   sz   e Zd Zddd„Zddd„Zddd„Zddd	„Zdd
d„Zddd„Zddd„Z	ddd„Z
ddd„Zddd„Zddd„ZdS )ÚNovellExtendedOperationsNc                 C   r6   r!   )r   r"   r7   r8   r&   r&   r'   Úget_bind_dnÊ   r;   z$NovellExtendedOperations.get_bind_dnc                 C   ó   t | j||ƒ ¡ S r!   )r   r"   r7   )r$   r<   r9   r&   r&   r'   Úget_universal_passwordÎ   ó   þþz/NovellExtendedOperations.get_universal_passwordc                 C   ó   t | j|||ƒ ¡ S r!   )r   r"   r7   )r$   r<   r>   r9   r&   r&   r'   Úset_universal_passwordÓ   ó   ýýz/NovellExtendedOperations.set_universal_passwordc                 C   rb   r!   )r   r"   r7   )r$   Ú	server_dnr9   r&   r&   r'   Úlist_replicasÙ   rd   z&NovellExtendedOperations.list_replicasc                 C   rb   r!   )r   r"   r7   )r$   Úpartition_dnr9   r&   r&   r'   Úpartition_entry_countÞ   rd   z.NovellExtendedOperations.partition_entry_countc                 C   re   r!   )r   r"   r7   )r$   rh   rj   r9   r&   r&   r'   Úreplica_infoã   rg   z%NovellExtendedOperations.replica_infoc                 C   r6   r!   )r   r"   r7   r8   r&   r&   r'   Ústart_transactioné   r;   z*NovellExtendedOperations.start_transactionTc                 C   rb   r!   )r   r"   r7   )r$   Úcommitr9   r&   r&   r'   Úend_transactioní   rd   z(NovellExtendedOperations.end_transactionc                 C   ó   t | j||||d�S ©N)Ú
members_dnÚ	groups_dnÚfixÚtransaction)r   r"   ©r$   ÚmembersÚgroupsrt   ru   r&   r&   r'   Úadd_members_to_groupsò   ó   üz.NovellExtendedOperations.add_members_to_groupsc                 C   rp   rq   )r   r"   rv   r&   r&   r'   Úremove_members_from_groupsù   rz   z3NovellExtendedOperations.remove_members_from_groupsFc                 C   rp   rq   )r   r"   rv   r&   r&   r'   Úcheck_groups_memberships   rz   z1NovellExtendedOperations.check_groups_membershipsr!   ©NN)TN)TT)FT)r2   r3   r4   ra   rc   rf   ri   rk   rl   rm   ro   ry   r{   r|   r&   r&   r&   r'   r`   É   s    









r`   c                	   @   sb   e Zd Zdedddddddf	dd„Zddd	„Zd
d„ Zddd„Zddd„Zde	eddfdd„Z
dS )ÚMicrosoftExtendedOperationsrQ   NFTiÿÿÿc                 C   s    t | j|||||||||	|
d�S )N)
Ú	sync_baseÚsync_filterrG   ÚcookieÚobject_securityÚancestors_firstÚpublic_data_onlyÚincremental_valuesÚ
max_lengthÚhex_guid)r
   r"   )r$   r   r€   rG   r�   r‚   rƒ   r„   r…   r†   r‡   r&   r&   r'   Údir_sync	  s   öz$MicrosoftExtendedOperations.dir_syncc                 C   s   t | j||||ƒS r!   )r   r"   )r$   r<   r>   r=   r9   r&   r&   r'   rA      s   üz+MicrosoftExtendedOperations.modify_passwordc                 C   s   t | j|ƒS r!   )r   r"   )r$   r<   r&   r&   r'   Úunlock_account'  s   ÿz*MicrosoftExtendedOperations.unlock_accountc                 C   ó   t | j|||d�S ©N)rr   rs   rt   )r   r"   ©r$   rw   rx   rt   r&   r&   r'   ry   +  ó
   ýz1MicrosoftExtendedOperations.add_members_to_groupsc                 C   rŠ   r‹   )r   r"   rŒ   r&   r&   r'   r{   1  r�   z6MicrosoftExtendedOperations.remove_members_from_groupsrP   c                 C   s   |rd}t | j|||||ƒS )NF)r   r"   )r$   rC   rE   rG   r[   r\   r&   r&   r'   r^   7  s   ûz-MicrosoftExtendedOperations.persistent_searchr}   )T)r2   r3   r4   r   rˆ   rA   r‰   ry   r{   r   r^   r&   r&   r&   r'   r~     s*    
ö


ûr~   c                   @   s   e Zd Zdd„ ZdS )ÚExtendedOperationsRootc                 C   s4   t  | |¡ t| jƒ| _t| jƒ| _t| jƒ| _d S r!   )	r    r(   r5   r"   Ústandardr`   Únovellr~   Ú	microsoftr#   r&   r&   r'   r(   J  s   zExtendedOperationsRoot.__init__N)r2   r3   r4   r(   r&   r&   r&   r'   rŽ   I  s    rŽ   N)9Ú__doc__Úosr   rP   r   r   r   r   Úmicrosoft.dirSyncr
   Úmicrosoft.modifyPasswordr   Úmicrosoft.unlockAccountr   Úmicrosoft.addMembersToGroupsr   Ú!microsoft.removeMembersFromGroupsr   Úmicrosoft.persistentSearchr   Únovell.partition_entry_countr   Únovell.replicaInfor   Únovell.listReplicasr   Únovell.getBindDnr   Únovell.nmasGetUniversalPasswordr   Únovell.nmasSetUniversalPasswordr   Únovell.startTransactionr   Únovell.endTransactionr   Únovell.addMembersToGroupsr   Únovell.removeMembersFromGroupsr   Únovell.checkGroupsMembershipsr   Ústandard.whoAmIr   Ústandard.modifyPasswordr   Ústandard.PagedSearchr   r   Ústandard.PersistentSearchr   Úobjectr    r5   r`   r~   rŽ   r&   r&   r&   r'   Ú<module>   s<     ?A