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   Fd   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