
    =OOf                        d Z ddl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 dd	lmZ dd
lmZ ddlmZ ddlmZmZmZ ddlmZmZmZ ddlmZmZ ddl 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*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>  G d de?      Z@ G d de?      ZA G d deA      ZB G d deA      ZCy# e$ r	 ddlmZ Y w xY w)
    N)OrderedDict   )linesep)deepcopy)STRING_TYPESSEQUENCE_TYPES
MODIFY_ADDMODIFY_REPLACE   )WritableAttribute)	ObjectDef)AttrDef)LDAPKeyErrorLDAPCursorErrorLDAPCursorAttributeError)check_json_dictformat_jsonprepare_for_stream)operation_to_ldifadd_ldif_header)safe_dnsafe_rdnto_dn)to_stdout_encoding)CaseInsensitiveWithAliasDict)get_config_parameter)STATUS_VIRTUALSTATUS_WRITABLESTATUS_PENDING_CHANGESSTATUS_COMMITTEDSTATUS_DELETEDSTATUS_INITSTATUS_READY_FOR_DELETIONSTATUS_READY_FOR_MOVINGSTATUS_READY_FOR_RENAMINGSTATUS_MANDATORY_MISSINGSTATUSESINITIAL_STATUSES)RESULT_SUCCESS)loglog_enabledERRORBASICPROTOCOLEXTENDEDc                   >    e Zd ZdZd Zd Zd Zd Zd Ze	d        Z
y)	
EntryStatezTContains data on the status of the entry. Does not pollute the Entry __dict__.

    c                     || _         d | _        d | _        t        | _        t               | _        t               | _        d | _        || _	        d | _
        d | _        t               | _        |j                  r|j                  | _        y d | _        y N)dn_initial_status_tor#   statusr   
attributesraw_attributesresponsecursororigin	read_timer   changes
definitionselfr5   r<   s      U/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/ldap3/abstract/entry.py__init__zEntryState.__init__:   sv    #!68:<"}$//DO"DO    c                    | j                   r| j                  dt        | j                        z   dz   | j                  | j                  k7  r| j                  dz   ndz   | j                  z   dz   | j
                  r| j
                  j                         ndz   t        z   }|ddj                  t        | j                  j                                     z   t        z   z  }|d| j                  j                  r.dj                  t        | j                  j                              nd	z   t        z   z  }|d
dj                  t        | j                  j                  j                                     z   t        z   z  }|d| j                  rdnd	z   t        z   z  }|d| j                   r | j                   j"                  j$                  nd	z   t        z   z  }|S t&        j)                  |       S )NDN:  - STATUS: ,   - READ TIME: <never>zattributes: zobject def: z<None>zattr defs: z
response: presentzcursor: )__dict__r5   r   r6   r8   r>   	isoformatr   joinsortedr9   keysr@   _object_class_attributesr;   r<   	__class____name__object__repr__)rB   rs     rC   rX   zEntryState.__repr__K   s   ==TWW0+DGG44}Dimi}i}  BF  BM  BM  jMI]I]`dId  SU  V  Y]  Yd  Yd  d  gw  w  Y]  Yg  Yg  {  {I  {I  {S  {S  {U  mv  w  zA  AA$))F4??3G3G3I,J"KKgUUAW[WfWfWtWt499VDOO4Q4Q-R#S  {C  D  GN  N  NA6$//2M2M2R2R2T+U!VVY```AdmmJWTTAt{{44==RZ[^eeeAH??4((rE   c                 "    | j                         S r4   rX   rB   s    rC   __str__zEntryState.__str__W       }}rE   c                 :    t        | j                        }d |d<   |S )Nr<   )dictrN   )rB   cpys     rC   __getstate__zEntryState.__getstate__Z   s    4==!H
rE   c                    t        d      D cg c]  }|j                          }}|t        vr:dt        |      z   }t	        t
              rt        t
        d||        t        |      |t        v r|| _	        || _
        |t        k(  rt        | _	        |t        k(  rt        | _	        | j                  t        k(  s&| j                  t        k(  r| j                  t        k(  r| j                   j"                  D ]|  }| j                   j"                  |   j$                  s'|j                         |vs:|| j&                  vs| j&                  |   j(                  sb|| j*                  vsqt,        | _
         y  y y y c c}w )N*IGNORED_MANDATORY_ATTRIBUTES_IN_OBJECT_DEFzinvalid entry status %s for <%s>)r   lowerr(   strr,   r-   r+   r   r)   r6   r8   r"   r   r!   r   r    r@   rT   	mandatoryr9   virtualr?   r'   )rB   r8   v/conf_ignored_mandatory_attributes_in_object_deferror_messageattrs         rC   
set_statuszEntryState.set_status_   sW   Nb  dP  OQ  ;R1779  ;R7  ;R!3c&kAM5!E=->!-00%%#)D ^##1D %%#2D ;;.(T[[<R-RW[WkWko}W}33 ??..t4>>4::<  XG  DGDOO3tt7L7T7TZ^fjfrfrZr&>	 X~-R ;Rs   E8c                     | j                   S r4   )r:   r\   s    rC   entry_raw_attributeszEntryState.entry_raw_attributest   s    """rE   N)rV   
__module____qualname____doc__rD   rX   r]   rb   rn   propertyrp    rE   rC   r2   r2   5   s4    #"
)
* # #rE   r2   c                      e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zed        Zed        Zed        Zed        Zed        Zd Zed        Zed        Zed        Zed        Zed        ZddZddZy)	EntryBasea  The Entry object contains a single LDAP entry.
    Attributes can be accessed either by sequence, by assignment
    or as dictionary keys. Keys are not case sensitive.

    The Entry object is read only

    - The DN is retrieved by entry_dn
    - The cursor reference is in _cursor
    - Raw attributes values are retrieved with _raw_attributes and the _raw_attribute() methods
    c                 &    t        ||      | _        y r4   )r2   _staterA   s      rC   rD   zEntryBase.__init__   s     V,rE   c                 ,   | j                   rs| j                  fdt        | j                        z   dz   | j                  j                  | j
                  k7  r| j                  j                  dz   ndz   | j
                  z   dz   | j                  r| j                  j                         ndz   t        z   }| j                  j                  rt        | j                  j                        D ]  }| j                  j                  |   sHt        | j                  j                  |   d      s@| j                  j                  |   j                  sd|dt        | j                  j                  |         z   t        z   z  } |S t        j                  |       S )	NrG   rH   rI   rJ   rK   rL   r?   z    )rN   entry_dnr   ry   r6   entry_statusentry_read_timerO   r   r9   rQ   hasattrr?   reprrW   rX   )rB   rY   rm   s      rC   rX   zEntryBase.__repr__   s   ==T]]6+DMM::]Jvz  wB  wB  wR  wR  VZ  Vg  Vg  wgt{{OjOjmqOq  mo  p  sw  sD  sD  D  GW  W  C  S  S  [_  [o  [o  [y  [y  [{  Yb  c  fm  mA{{%%"4;;#9#9: SD{{--d3@V@VW[@\^g8hmqmxmx  nD  nD  EI  nJ  nR  nRVd4;;+A+A$+G&HH7RRS H??4((rE   c                 "    | j                         S r4   r[   r\   s    rC   r]   zEntryBase.__str__   r^   rE   c              #   x   K   | j                   j                  D ]  }| j                   j                  |     y wr4   )ry   r9   rB   	attributes     rC   __iter__zEntryBase.__iter__   s9     // 	4I++((33	4 	s   8:c                 F    	 | j                  |       y# t        $ r Y yw xY w)NTF)__getitem__r   )rB   items     rC   __contains__zEntryBase.__contains__   s*    	T" 		s    	  c                    t        |t              r*|dk(  rt        j                  | |      S dj	                  |j                               j                         }d }| j                  j                  j                         D ]  }||j                         k(  s|} n |s@| j                  j                  j                         D ]  }||j                         k(  s|} n |sC| j                  j                  j                         D ]  }|dz   |j                         k(  s|} n |sC| j                  j                  j                         D ]  }|dz   |j                         k(  s|} n |sB| j                  j                  j                         D ]  }|dz   |j                         v s|} n |sB| j                  j                  j                         D ]  }|dz   |j                         v s|} n |s1d|z  }t        t              rt        t        d||        t        |      | j                  j                     S d}t        t              rt        t        d||        t        |      )Nry   rJ   ;binaryz;rangezattribute '%s' not foundre   attribute name must be a string)
isinstancer   rW   __getattr__rP   splitrf   ry   r9   rR   aliasesr,   r-   r+   r   rB   r   
attr_foundrm   rl   s        rC   r   zEntryBase.__getattr__   s/   dL)x))$55774::<(..0DJ..335 4::<'!%J  KK22::< Dtzz|+%)
  KK22779 Di'4::<7%)
  KK22::< Di'4::<7%)
  KK22779 Dh$**,6%)
  KK22::< Dh$**,6%)
  <t Cu%}mTB.}==;;))$//9u}mT:&}55rE   c                 0   |dk(  rt         j                  | ||       y || j                  j                  v r1d|z  }t	        t
              rt        t
        d||        t        |      d|z  }t	        t
              rt        t
        d||        t        |      )Nry   zattribute '%s' is read onlyre   z#entry is read only, cannot add '%s')rW   __setattr__ry   r9   r,   r-   r+   r   )rB   r   valuerl   s       rC   r   zEntryBase.__setattr__   s    8tT51T[[+++;dBM5!E=->*=99CdJM5!E=->*=99rE   c                    t        |t              rdj                  |j                               j	                         }d }| j
                  j                  j                         D ]  }||j	                         k(  s|} n |s@| j
                  j                  j                         D ]  }||j	                         k(  s|} n |sC| j
                  j                  j                         D ]  }|dz   |j	                         k(  s|} n |sC| j
                  j                  j                         D ]  }|dz   |j	                         k(  s|} n |s1d|z  }t        t              rt        t        d||        t        |      | j
                  j                     S d}t        t              rt        t        d||        t        |      )NrJ   r   zkey '%s' not foundre   zkey must be a string)r   r   rP   r   rf   ry   r9   rR   r   r,   r-   r+   r   r   s        rC   r   zEntryBase.__getitem__   s   dL)774::<(..0DJ..335 4::<'!%J  KK22::< Dtzz|+%)
  KK22779 Di'4::<7%)
  KK22::< Di'4::<7%)
  6 =u%}mTB"=11;;))$//.u}mT:=))rE   c                 V    t        |t              r| j                  |j                  k(  S yNFr   rw   r{   rB   others     rC   __eq__zEntryBase.__eq__  "    eY'==ENN22rE   c                 V    t        |t              r| j                  |j                  k  S yr   r   r   s     rC   __lt__zEntryBase.__lt__  r   rE   c                 .    | j                   j                  S r4   )ry   r5   r\   s    rC   r{   zEntryBase.entry_dn  s    {{~~rE   c                 .    | j                   j                  S r4   )ry   r<   r\   s    rC   entry_cursorzEntryBase.entry_cursor      {{!!!rE   c                 .    | j                   j                  S r4   )ry   r8   r\   s    rC   r|   zEntryBase.entry_status  r   rE   c                 .    | j                   j                  S r4   )ry   r@   r\   s    rC   entry_definitionzEntryBase.entry_definition  s    {{%%%rE   c                 .    | j                   j                  S r4   ry   r:   r\   s    rC   rp   zEntryBase.entry_raw_attributes  s    {{)))rE   c                 h    || j                   j                  v r| j                   j                  |   S dS )z

        :param name: name of the attribute
        :return: raw (unencoded) value of the attribute, None if attribute is not found
        Nr   )rB   names     rC   entry_raw_attributezEntryBase.entry_raw_attribute"  s0     484;;;U;U3Ut{{))$/_[__rE   c                     | j                   j                  D cg c](  }| j                   j                  |   j                  s'|* c}S c c}w r4   )r   rT   rh   r   s     rC   entry_mandatory_attributesz$EntryBase.entry_mandatory_attributes*  sQ    +/+@+@+L+L  HiPTPePePqPqr{P|  QG  QG	  H  	H  Hs   (A	A	c                 \    t        | j                  j                  j                               S r4   )listry   r9   rR   r\   s    rC   entry_attributeszEntryBase.entry_attributes.  s     DKK**//122rE   c                 j    t        d | j                  j                  j                         D              S )Nc              3   P   K   | ]  \  }}|t        |j                        f   y wr4   )r   values).0attribute_keyattribute_values      rC   	<genexpr>z5EntryBase.entry_attributes_as_dict.<locals>.<genexpr>4  s,       NJj=Zi]H_-C-C$DE  Ns   $&)r`   ry   r9   itemsr\   s    rC   entry_attributes_as_dictz"EntryBase.entry_attributes_as_dict2  sI      Nnrnyny  oE  oE  oK  oK  oM  N  N  	NrE   c                 .    | j                   j                  S r4   )ry   r>   r\   s    rC   r}   zEntryBase.entry_read_time6  s    {{$$$rE   c                 .    | j                   j                  S r4   )ry   r?   r\   s    rC   _changeszEntryBase._changes:  s    {{"""rE   Nc           	          t               } j                  |d<   |r3|s"t         fd j                  D              |d<   n j                  |d<   |r<|s"t         fd j                  D              |d<   nt         j                        |d<   t        t
        u rt        |       t        j                  |d||dt        d      }|r|j                  |       |S )	Nr5   c              3   `   K   | ]%  }j                   |   s|j                   |   f ' y wr4   )r   r   keyrB   s     rC   r   z*EntryBase.entry_to_json.<locals>.<genexpr>D  sL       0j^a  GK  Gd  Gd  eh  Gid6S6STW6X0Y  0j   ..r9   c              3   `   K   | ]%  }j                   |   s|j                   |   f ' y wr4   )rp   r   s     rC   r   z*EntryBase.entry_to_json.<locals>.<genexpr>J  sG       )WSVw{  xQ  xQ  RU  xV#t/H/H/M)N  )Wr   rawT),z: )ensure_ascii	sort_keysindentcheck_circulardefault
separators)r`   r{   r   rp   rg   bytesr   jsondumpsr   write)	rB   r   r   sortstreamchecked_attributesinclude_empty
json_entryjson_outputs	   `        rC   entry_to_jsonzEntryBase.entry_to_json>  s    V
==
4 +/  0jei  fC  fC  0j  ,j
<(+/+H+H
<( $(  )WZ^ZsZs  )W  %W
5!$()B)B$C
5!%<J'jj.2+/(.04)4,79 LL%rE   c                 b   t        d| j                  j                  g||      }t        |      }|xs t        }|j                  |      }|rb|j                         dk(  r/t        dg      d   }|j                  t        ||z   |z                |j                  t        ||z   |z                |S )NsearchResponse)
sort_orderr   -)	r   ry   r;   r   r   rP   tellr   r   )rB   
all_base64line_separatorr   r   
ldif_linesldif_outputheaders           rC   entry_to_ldifzEntryBase.entry_to_ldif^  s    &'7$++:N:N9OQ[hrs
$Z0
'27$))*5{{}!(#/2/0G.0XYZLL+K.,H>,YZ[rE   )F   TNTT)FNNN)rV   rq   rr   rs   rD   rX   r]   r   r   r   r   r   r   r   rt   r{   r   r|   r   rp   r   r   r   r   r}   r   r   r   ru   rE   rC   rw   rw   y   s   	-	),6\:!*F   " " " " & & * *` H H 3 3 N N % % # #@
rE   rw   c                       e Zd ZdZddZy)Entrya  The Entry object contains a single LDAP entry.
    Attributes can be accessed either by sequence, by assignment
    or as dictionary keys. Keys are not case sensitive.

    The Entry object is read only

    - The DN is retrieved by entry_dn
    - The Reader reference is in _cursor()
    - Raw attributes values are retrieved by the _ra_attributes and
      _raw_attribute() methods

    Nc                 B   t        d      }| j                  j                  s.d}t        t              rt        t        d||        t        |      ||| j                  j                  j                  rB| j                  j                  }| j                  j                  t        |t              r|ng z   }nd| v r| j                  j                  }|s.d}t        t              rt        t        d||        t        |      t        |t              s"t        || j                  j                  ||      }|rnt        |t               r|g}t        |t              rM|D ]E  }||j"                  vsd|d|d}t        t              rt        t        d||        t        |       ng }|s$d	d
lm}	  |	| j                  j(                  |      }
n|}
|r3|
j+                  | j,                  t/        |      | j0                  z         }n[|
j3                  | j4                  j6                        }|
j8                  j;                  |       | j<                  |j4                  _        | |j4                  _         g }g }g }g }|j4                  j@                  j                  j"                  D ]n  }|j4                  j@                  j                  j"                  |   }||jB                  k7  sA||j4                  jD                  vs&||jB                  z   |j4                  jD                  vs|j                  j"                  |jB                     }tG        |jB                  ||jH                  |jJ                  |jL                  |jN                  |jP                  |jR                  |jT                  |jV                  |jX                        }|j                  }|j;                  |       |j;                  |       t[        |||
      }|jB                  |j4                  jD                  v r|j4                  jD                  |jB                     jX                  |_,        |j4                  jD                  |jB                     j\                  |_.        |j4                  jD                  |jB                     j                  |_        |j4                  jD                  |jB                     j6                  |_        |j;                  ||f       |j;                  |jB                         q |D ]  \  }}||j4                  jD                  |<     |D ]  }|j4                  jD                  |=  |D ]  }|j                  }||z  } |D ]  }|j                  }||z  } |j4                  j_                  t`               |S )N(ABSTRACTION_OPERATIONAL_ATTRIBUTE_PREFIXz2schema must be available to make an entry writablere   objectclassz8object class must be specified to make an entry writablezattribute 'z' not in schema for ''r   )Writer)
r   validate	pre_query
post_queryr   dereference_dndescriptionrh   single_valuealias)1r   r   schemar,   r-   r+   r   r@   rS   r   _auxiliary_classr   r	   r   r   r   r   rT   r<   r   
connection_refresh_objectr{   r   r   _create_entryry   r;   entriesappendr}   r>   r=   r   r9   r   r   r   r   r   r   r   rh   r   other_namesr   
raw_valuesrn   r   )rB   
object_defwriter_cursorr9   custom_validatorauxiliary_class!conf_operational_attribute_prefixrl   r   r   writable_cursorwritable_entryattr_to_addattr_to_removeobject_def_to_addobject_def_to_removerm   original_attrold_attr_defnew_attr_defodnew_attros                          rC   entry_writablezEntry.entry_writablex  s'   ,@Ak,l)  ''PM5!E=->!-00  ++99!22@@
"&"7"7"H"H_ijy  |J  `KO  QS  #T$&!--44
VM5!E=->!-00*i0&z43D3D3K3KM]_no
*l3(\
*n5!+ =I 
(>(>>W`bl(m&u-}mTJ-m<<= J&$T%6%6%A%A:NO+O,<<T]]DQ[L\_c_t_tLtuN,::4;;;O;OPN##**>:.2.B.BN!!+'+$!"))00AAMM 	:D*1188IIUUVZ[M})))t>;P;P;[;[/[  `A  DQ  DV  DV  `V  ^l  ^s  ^s  ^~  ^~  `~->>JJ=K]K]^&}'9'9+/0=0F0F1>1H1H2?2J2J/</D/D6C6R6R3@3L3L1=1G1G4@4M4M-:-F-F
 H $44$++L9!((6,\>?[ %%)>)>)I)II+9+@+@+K+KML^L^+_+k+kH(*8*?*?*J*J=K]K]*^*i*iH'&4&;&;&F&F}GYGY&Z&a&aHO(6(=(=(H(HI[I[(\(e(eH%""D(#34%%m&8&895	:< * 	>ND(5=N!!,,T2	>" 	7D%%006	7. 	J//AOA	 , 	J//AOA	 	((9rE   )NNNNN)rV   rq   rr   rs   r	  ru   rE   rC   r   r   k  s    brE   r   c                   f    e Zd Zd Zd Zd Zed        ZddZd Z	d Z
dd	Zd
 Zd Zed        Zy)WritableEntryc                 :    |t         ur| j                  ||       y y r4   )Ellipsisr   )rB   r   r   s      rC   __setitem__zWritableEntry.__setitem__  s     S%( !rE   c                    t        d      D cg c]  }|j                          }}|dk(  r t        |t              r|| j                  d<   y |t
        ur|| j                  j                  j                  v s|j                         |v r|| j                  j                  vr[t        | j                  j                  j                  |   | | j                        }|| j                  j                  t        |      <   | j                  j                  |   j                  |       y d|z  }t        t              rt!        t        d||        t#        |      y c c}w )N#ATTRIBUTES_EXCLUDED_FROM_OBJECT_DEFry   )r<   attribute '%s' not definedre   )r   rf   r   r2   rN   r  r   r@   rT   ry   r9   r   rg   setr,   r-   r+   r   )rB   r   r   rj   (conf_attributes_excluded_from_object_defnew_attributerl   s          rC   r   zWritableEntry.__setattr__  s;   G[  ]B  HC  4D!AGGI  4D0  4D8
5* =&+DMM(# t((33???4::<S{C{t{{555$5d6G6G6R6R6^6^_c6dfjsw  tE  tE  %FM8EDKK**3t95&&t,007 > Eu%}mTB.}== ! 4Ds   Ec                    t        |t              r|dk(  r| j                  d   S dj                  |j	                               j                         }| j                  j                  j                         D ]0  }||j                         k(  s| j                  j                  |   c S  | j                  j                  j                         D ]0  }||j                         k(  s| j                  j                  |   c S  || j                  j                  v rt        | j                  j                  |   | | j                        | j                  j                  |<   | j                  j                  j                  |       | j                  j                  |   S d|z  }t        t               rt#        t         d||        t%        |      d}t        t               rt#        t         d||        t%        |      )Nry   rJ   r  re   r   )r   r   rN   rP   r   rf   ry   r9   rR   r   r   rT   r   r   addr,   r-   r+   r   )rB   r   rm   rl   s       rC   r   zWritableEntry.__getattr__  s   dL)x}}X..774::<(..0D..335 84::<';;11$778 ..668 84::<';;11$778 t,,888/@AVAVAbAbcgAhjnpt  qB  qB  0C&&t,!!,,006{{--d33:TAM5!E=->*=99=M5!E=->*=99rE   c                 `    | j                   D cg c]  }| |   j                  s| c}S c c}w r4   )r   ri   )rB   rm   s     rC   entry_virtual_attributesz&WritableEntry.entry_virtual_attributes  s(    !%!6!6M$t*:L:LMMMs   ++Nc                    |r| j                   j                          | j                  t        k(  r| j                   j                  j                  | j                  |      }| j                   j                  j                  j                  s,| j                   j                  j                  |d      \  }}}n| j                   j                  j                  j                  r|\  }}}}n`| j                   j                  j                  }| j                   j                  j                  }| j                   j                  j                  }| j                   j                  |||       |d   t        k(  r}| j                  }| j                   j"                  r| j                   j                  j$                  | j                   j"                  j                   j                  j$                  k(  r| j                   j"                  j                   }	| j                   j"                  j&                  j)                          t+        ||	      | j                   j"                  j&                  d<   | j                   j"                  j                   j-                  t.               | j                   }	| j&                  j)                          t+        ||	      | _        | j                   j-                  t.               yy| j                  t0        k(  r| j                   j                  j3                  | j                  dj5                  t7        | j                              | j                   j8                        }| j                   j                  j                  j                  s,| j                   j                  j                  |d      \  }}}n| j                   j                  j                  j                  r|\  }}}}n`| j                   j                  j                  }| j                   j                  j                  }| j                   j                  j                  }| j                   j                  |||       |d   t        k(  r3t;        dj5                  t7        | j                              dz   | j                   j8                  z         | j                   _        |r| j?                         r| j                   j"                  r| j                   j                  j$                  | j                   j"                  j                   j                  j$                  k(  r/| j                  | j                   j"                  j                   _        | j                   j-                  t@               d | j                   _        yy| j                  tB        k(  rdj5                  t7        | j                   j8                              }
| j                   j                  j3                  | j                  |
      }| j                   j                  j                  j                  s,| j                   j                  j                  |d      \  }}}n| j                   j                  j                  j                  r|\  }}}}n`| j                   j                  j                  }| j                   j                  j                  }| j                   j                  j                  }| j                   j                  |||       |d   t        k(  r|
dz   dj5                  tE        | j                        d	d        z   | j                   _        |r| j?                         r| j                   j"                  r| j                   j                  j$                  | j                   j"                  j                   j                  j$                  k(  r/| j                  | j                   j"                  j                   _        | j                   j-                  t@               d | j                   _        yy| j                  tF        tH        fv rg }| jJ                  D ]d  }|| j                   jL                  vs$| j                   jL                  |   jN                  s?|| jP                  vsN|jS                  d
|z   d
z          f ddj5                  |      d| j                  }tU        tV              rtY        tV        d||        t[        |      | j                  t\        k(  r| jP                  r| j^                  j`                  r| jP                  D ]  }| j                   jb                  jd                  |   jf                  | j                   jb                  jd                  |   jh                  z   }| jj                  D ]  }||v s t | j^                  j`                  D ]^  }||v s| j                   jl                  tF        k(  r%| jP                  d   d   d	   jS                  |       J| xjj                  |z  c_5        `  | j                   jl                  tF        k(  rfto               }| jP                  D ]  }| jP                  |   d   d	   ||<    | j                   j                  jq                  | j                  d ||      }n;| j                   j                  js                  | j                  | jP                  |      }| j                   j                  j                  j                  s,| j                   j                  j                  |d      \  }}}n| j                   j                  j                  j                  r|\  }}}}n`| j                   j                  j                  }| j                   j                  j                  }| j                   j                  j                  }| j                   j                  |||       |d   t        k(  r|r| j?                         r| j                   j"                  ro| j                   j                  j$                  | j                   j"                  j                   j                  j$                  k(  r| D ]  }|jt                  | j^                  jv                  v s&|jt                  | j                   j"                  j^                  jv                  vs]| j                   j"                  j                   jx                  j{                  | j                   jx                  jv                  |jt                             | j                   j"                  j                   j}                  | j                   j                        }| j                   j"                  j&                  j)                          |j                   | j                   j"                  j&                  d<   | D ]q  }t        |d      r| j                   j"                  j                   jL                  |jt                     | j                   j"                  j&                  |jt                  <   s | j                  | j                   j"                  j                   _A        n| j                          | j                   j-                  t@               yy)NT)get_requestresultry   F+)new_superiorr   r   r   zmandatory attributes rI   z missing in entry re   objectClassr   ri   )Cr   _reset_historyr|   r$   r   deleter{   strategysyncget_responsethread_safer;   r  request_store_operation_in_historyr*   ry   r=   serverrN   clearr2   rn   r"   r%   	modify_dnrP   r   r7   r   r5   entry_refreshr!   r&   r   r   r'   r   r9   ri   r   r   r,   r-   r+   r   r    r   r   r   attribute_typesmandatory_inoptional_inr   r6   r`   r  modifyr   rT   r@   add_attributer   r~   r}   r>   entry_discard_changes)rB   refreshcontrolsclear_historyr  r;   r%  _r5   r<   rdnmissing_attributesrm   rl   attr_classesobject_class	aux_classnew_attributes
temp_entrys                      rC   entry_commit_changesz"WritableEntry.entry_commit_changes  s   ,,. 99&&1188QF$$//88==,0,=,=,H,H,U,UV\jn,U,o)&'$$//88DD390Avx#00;;DDH!..99@@F"//::BBG99'68Th>1]];;%%$*;*;*F*F*M*MQUQ\Q\QcQcQpQpQ{Q{  RC  RC  +C![[//<<FKK&&//557<Fr6<RDKK&&//9KK&&--88H**##%(V4&&~6"99&&11;;DMM388T\]a]j]jTkKl{  |G  |G  |K  |K;  LF$$//88==,0,=,=,H,H,U,UV\jn,U,o)&'$$//88DD390Avx#00;;DDH!..99@@F"//::BBG99'68Th>1!((4==2I)JS)PSWS^S^SbSb)b!c))+;;--$2C2C2N2N2U2UY]YdYdYkYkYxYx  ZD  ZD  ZK  ZK  3K;?==DKK..558&&'78"&";;((8DKKOO45C&&11;;DMM3OF$$//88==,0,=,=,H,H,U,UV\jn,U,o)&'$$//88DD390Avx#00;;DDH!..99@@F"//::BBG99'68Th>1!$sSXXeDMM6J126N-O!O))+;;--$2C2C2N2N2U2UY]YdYdYkYkYxYx  ZD  ZD  ZK  ZK  3K;?==DKK..558&&'78"&>3K"LL!#77 B 6 66$++:P:PQU:V:^:^dhptp}p}d}&--dTkD.@AB NRYYWiMjlplylyzM5!E=->!-00"88}}((99 $ F'+'8'8'?'?'O'OPT'U'b'beieveve}e}  fN  fN  OS  fT  f`  f`  (`,0,<,< 
FL+|; %
F
 .2-B-B-S-S F	#,#<'+{{'B'Bn'T(,m(DQ(G(J(Q(QR[(\(,(8(8I(E(8FF ;;...@%)VN $ I/3}}T/B1/Ea/Ht,I!..99==dmmTSacklF!..99@@PTP]P]_ghF((33<<AA040A0A0L0L0Y0YZ`nr0Y0s-Hfg((33<<HH7=468W#'#4#4#?#?#H#H!%!2!2!=!=!D!D"&"3"3">">"F"F!!==gvxX(#~5--/#{{11d6G6G6R6R6Y6Y]a]h]h]o]o]|]|  ^H  ^H  ^O  ^O  7O,0 !UD'+xx43H3H3T3T'TY]YaYaimititi{i{  jM  jM  jY  jY  ZY(,(:(:(G(G(R(R(`(`aearara}a}  bJ  bJ  KO  KS  KS  bT  )U!U .2[[-?-?-L-L-Z-Z[_[f[f[o[o-p
 $ 2 2 ; ; A A CHRHYHY 2 2 ; ;H E,0 !D+24	+BPTP[P[PbPbPiPiPtPtuyu}u}P~(:(:(C(CDHH(M! GKFZFZ 2 2 9 9 C224KK**+;<rE   c                     | j                   j                          | j                  j                  | j                  j                         y r4   )r   r(  ry   rn   r6   r\   s    rC   r0  z#WritableEntry.entry_discard_changes  s.    t{{::;rE   c                     | j                   t        t        t        fvr;d| j                   z   }t	        t
              rt        t
        d||        t        |      | j                  j                  t               y )Nz%cannot delete entry, invalid status: re   )
r|   r   r!   r$   r,   r-   r+   r   ry   rn   )rB   rl   s     rC   entry_deletezWritableEntry.entry_delete  s]    _6FHa$bbCdFWFWWM5!E=->!-0089rE   c                 l    | j                   j                  r| j                   j                  | ||      ryy)z;

        Refreshes the entry from the LDAP Server
        TF)r   r   refresh_entry)rB   triessecondss      rC   r*  zWritableEntry.entry_refresh  s1    
 ''  ..tUGDrE   c                 &   | j                   t        t        t        fvr;d| j                   z   }t	        t
              rt        t
        d||        t        |      t        |      | j                  _
        | j                  j                  t               y )Nz#cannot move entry, invalid status: re   )r|   r   r!   r%   r,   r-   r+   r   r   ry   r7   rn   )rB   destination_dnrl   s      rC   
entry_movezWritableEntry.entry_move  sm    _6FH_$``ADDUDUUM5!E=->!-00!.167rE   c                    | j                   t        t        t        fvr;d| j                   z   }t	        t
              rt        t
        d||        t        |      || j                  _	        | j                  j                  t               y )Nz%cannot rename entry, invalid status: re   )r|   r   r!   r&   r,   r-   r+   r   ry   r7   rn   )rB   new_namerl   s      rC   entry_renamezWritableEntry.entry_rename  sh    _6FHa$bbCdFWFWWM5!E=->!-00"89rE   c                     | j                   S r4   )r   r\   s    rC   entry_changeszWritableEntry.entry_changes  s    }}rE   )TNT)r   r   )rV   rq   rr   r  r   r   rt   r  r<  r0  r?  r*  rF  rI  rK  ru   rE   rC   r  r    s[    )>&:2 N NIV<:	8:  rE   r  )Drs   r   collectionsr   ImportErrorutils.ordDictosr   copyr   rJ   r   r	   r
   r   r   r   	objectDefr   attrDefr   core.exceptionsr   r   r   
utils.convr   r   r   protocol.rfc2849r   r   utils.dnr   r   r   
utils.reprr   utils.ciDictr   utils.configr   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   core.resultsr*   	utils.logr+   r,   r-   r.   r/   r0   rW   r2   rw   r   r  ru   rE   rC   <module>r\     s   4 ,'   G G (    U U I I A / / + 7 /U U U U ) J JA# A#Ho odoI odkI k  ,+,s   C CC