HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/self/root/lib64/python3.6/site-packages/ldap/schema/__pycache__/subentry.cpython-36.pyc
3

�`a�>�@s�dZddlZddlZddlZddlmZddlTddlZddl	Z	ej
j
�ZiZx4e
e�j��D]"Zeed�r^eeej<ejee<q^We
e�ZGdd�de�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
�Zddd�ZdS)zd
ldap.schema.subentry -  subschema subentry handling

See https://www.python-ldap.org/ for details.
�N)�urlopen)�*�schema_attributec@seZdZdS)�SubschemaErrorN)�__name__�
__module__�__qualname__�r	r	� /usr/lib64/python3.6/subentry.pyrsrc@seZdZdd�Zdd�ZdS)�OIDNotUniquecCs
||_dS)N)�desc)�selfrr	r	r
�__init__#szOIDNotUnique.__init__cCs
d|jS)NzOID not unique for %s)r)r
r	r	r
�__str__&szOIDNotUnique.__str__N)rrrrrr	r	r	r
r!src@seZdZdd�Zdd�ZdS)�
NameNotUniquecCs
||_dS)N)r)r
rr	r	r
r,szNameNotUnique.__init__cCs
d|jS)NzNAME not unique for %s)r)r
r	r	r
r/szNameNotUnique.__str__N)rrrrrr	r	r	r
r*src@s~eZdZdZddd�Zdd�Zddd	�Zdd
d�Zd d
d�Zdd�Z	d!dd�Z
d"dd�Zdd�Zdd�Z
dd�Zd#dd�ZdS)$�	SubSchemaa-
  Arguments:

  sub_schema_sub_entry
      Dictionary usually returned by LDAP search or the LDIF parser
      containing the sub schema sub entry

  check_uniqueness
      Defines whether uniqueness of OIDs and NAME is checked.

      0
        no check
      1
        check but add schema description with work-around
      2
        check and raise exception if non-unique OID or NAME is found

  Class attributes:

  sed
    Dictionary holding the subschema information as pre-parsed
    SchemaElement objects (do not access directly!)
  name2oid
    Dictionary holding the mapping from NAMEs to OIDs
    (do not access directly!)
  non_unique_oids
    List of OIDs used at least twice in the subschema
  non_unique_names
    List of NAMEs used at least twice in the subschema for the same schema element
  �c
Cs�i|_i|_i|_i|_x:tj�D].}tjj�|j|<i|j|<tjj�|j|<q"Wtjj|�}�x0tD�]&}�xt	d|j
|g��D�]}t|}||�}|j�}	|o�|	|j|k�rd|j|	<|dk�rd}
|	}xD||j|kr�dj|	t
|
�f�}|
d7}
q�W|}	n|dk�rt|��||j||	<t|d�r�xZtjjij|j��D]B}|�rx||j|k�rxd|j||	<t|��n|	|j||<�qFWq�WqhWt|j�|_dS)Nr�;��names)�name2oid�sedZnon_unique_oidsZnon_unique_names�SCHEMA_CLASS_MAPPING�values�ldap�cidict�SCHEMA_ATTRS�filter�getZget_id�join�strr�hasattr�fromkeysrr�list)
r
Zsub_schema_sub_entryZcheck_uniqueness�c�eZ	attr_typeZ
attr_value�se_classZse_instanceZse_idZsuffix_counterZ	new_se_id�namer	r	r
rSsD





zSubSchema.__init__c
Csti}xj|jj�D]\\}}xR|j�D]F}t|�}y|t|j|�Wq"tk
rf|g|t|<Yq"Xq"WqW|S)zB
    Returns a dictionary containing the sub schema sub entry
    )r�itemsrr �SCHEMA_ATTR_MAPPING�append�KeyError)r
�entryr&�elements�seZse_strr	r	r
�
ldap_entry�szSubSchema.ldap_entryNc	
Csz|j|}|rng}xb|j�D]L\}}xB|D]:\}}yt||�|krL|j|�Wq*tk
rbYq*Xq*WqWnt|�}|S)zf
    Returns a list of OIDs of all available schema
    elements of a given schema element class.
    )rr(�getattrr*�AttributeErrorr#)	r
�schema_element_class�schema_element_filters�avail_se�resultZse_keyr.ZfkZfvr	r	r
�listall�s
zSubSchema.listallcCs�|ttgkst�|j||�}d}tjj|gi�}x|D]}g||<q6Wx�|D]~}|j||d�}|j|krjqL|j|ks�td||j|jf��x>|j	p�dD]0}	|j
||	�}
y||
j|�Wq�Yq�Xq�WqLW|S)zm
    Returns a ldap.cidict.cidict dictionary representing the
    tree structure of the schema elements.
    �_Nz>Schema element referenced by %s must be of class %s but was %s)r7)�ObjectClass�
AttributeType�AssertionErrorr6rr�get_obj�	__class__r�sup�getoidr*)r
r2r3r4Ztop_node�treer.�se_oid�se_obj�sZsup_oidr	r	r
r?�s(


zSubSchema.treercCsp|jd�dj�}||j|kr$|Sy|j||}Wn4tk
rj|rbtd|jt|�f��n|}YnX|S)z#
    Get an OID by name or OID
    rrz%No registered %s-OID for nameoroid %s)�split�striprrr+r�repr)r
r&�	nameoroid�raise_keyerrorZnameoroid_strippedZ
result_oidr	r	r
r>�s
zSubSchema.getoidcCsd|j||j||�}yt||�}Wntk
r<d}YnX|dkr`|jr`|j||jd|�}|S)z�
    Get a possibly inherited attribute specified by name
    of a schema element specified by nameoroid.
    Returns None if class attribute is not set at all.

    Raises KeyError if no schema element is found by nameoroid.
    Nr)rr>r0r1r=�get_inheritedattr)r
r&rFr'r.r5r	r	r
rH�s
zSubSchema.get_inheritedattrcCs^|j||�}y|j||}Wn:tk
rX|rPtd|jt|�t|�f��n|}YnX|S)z-
    Get a schema element by name or OID
    z:No ldap.schema.%s instance with nameoroid %s and se_oid %s)r>rr+rrE)r
r&rF�defaultrGr@rAr	r	r
r;�s
zSubSchema.get_objcCs\|pg}tj|j|j|j||���}|rXt|d�rXx"|D]}t|||j|||��q:W|S)zt
    Get a schema element by name or OID with all class attributes
    set including inherited class attributes
    r=)�copyrrr>r!�setattrrH)r
r&rFZ	inheritedr.Zclass_attr_namer	r	r
�get_inheritedobjs
zSubSchema.get_inheritedobjcCs<|jt|�}y|jt|�}Wntk
r0dSX|jSdS)zF
    Get the syntax of an attribute type specified by name or OID
    N)r>r9rLr+Zsyntax)r
rFZat_oid�at_objr	r	r
�
get_syntaxszSubSchema.get_syntaxc
Cs�|jtddgfg�}i}x2|D]*}|jt|d�}|r|jdkrd||j<qWd}t|�}x8|r�|j�}x&||D]}	|jt|	�|krpPqpW|}qZW|S)ze
    Returns OID of structural object class in oc_list
    if any is present. Returns None else.
    �kindrN)r?r8r;rO�oidr#�popr>)
r
Zoc_listZoc_treeZ
struct_ocsZoc_nameoroidZoc_ser5Zstruct_oc_listrPZ	child_oidr	r	r
�get_structural_ocs
zSubSchema.get_structural_occCs.|jt|�}|r|jS|jtddgfg�SdS)a
    Return a list of the applicable AUXILIARY object classes
    for a STRUCTURAL object class specified by 'nameoroid'
    if the object class is governed by a DIT content rule.
    If there's no DIT content rule all available AUXILIARY
    object classes are returned.
    rOrN)r;�DITContentRuleZauxr6r8)r
rFZcontent_ruler	r	r
�get_applicable_aux_classes9sz$SubSchema.get_applicable_aux_classescs@tjj}tjj���fdd�|D�}i}tjj�tjj�}}	d|krhx �j|j�D]}
|
|	|
j<qVW�x|�r�|jd�}||kr�qld||<y�j�|}Wnt	k
r�|r��wlYnXt
|��s�t�t|d�s�tt
|���t|d�s�tt
|���x4|jD]*}
�j||
|d�}�j|||d�||<�qWx4|jD]*}
�j||
|d�}�j|||d�|	|<�q6W|j��fd	d�|jD��qlW|�sv�j|�}|�rvy�jt|d
d�}Wnt	k
�r�Yn�Xx4|jD]*}
�j||
|d�}�j|||d�||<�q�Wx4|jD]*}
�j||
|d�}�j|||d�|	|<�qWxB|jD]8}
�j||
|d�}y
|	|=Wnt	k
�rnYnX�q:Wx"t|	�D]}
|
|k�r�|	|
=�q�W|�r8x�||	gD]�}x�t|�D]v}
xn|D]f\}}y�j||
}Wn0t	k
�r|�rt	d|
��||
=PYnXt||�|k�r�||
=P�q�W�q�W�q�W||	fS)a�
    Returns a 2-tuple of all must and may attributes including
    all inherited attributes of superior object classes
    by walking up classes along the SUP attribute.

    The attributes are stored in a ldap.cidict.cidict dictionary.

    object_class_list
        list of strings specifying object class names or OIDs
    attr_type_filter
        list of 2-tuples containing lists of class attributes
        which has to be matched
    raise_keyerror
        All KeyError exceptions for non-existent schema elements
        are ignored
    ignore_dit_content_rule
        A DIT content rule governing the structural object class
        is ignored
    csg|]}�j�|��qSr	)r>)�.0�o)r8r
r	r
�
<listcomp>dsz-SubSchema.attribute_types.<locals>.<listcomp>z1.3.6.1.4.1.1466.101.120.111rN�must�may)rGcsg|]}�j�|��qSr	)r>)rUrV)r8r
r	r
rW�srz0No attribute type found in sub schema by name %s)r�schemar9r8rrrrPrQr+�
isinstancer:r!�
ValueErrorrXr>r;rY�extendr=rRrSZnotsr#r0)r
Zobject_class_listZattr_type_filterrGZignore_dit_content_ruler9Zobject_class_oidsZ	oid_cacheZr_mustZr_mayrMZobject_class_oidZobject_class�ar@Z
structural_ocZdit_content_ruleZa_oid�lZafkZafvZschema_attr_typer	)r8r
r
�attribute_typesIs�




zSubSchema.attribute_types)r)N)N)r)Nr)N)Nrr)rrr�__doc__rr/r6r?r>rHr;rLrNrRrTr`r	r	r	r
r3s
7

 




rc
CsH|j�}|jd
�r�tj|�}tj|j�|�}tj|_|j	|j
p@d|jpHd�|j|j
�}|dkrfd}n$|jdkrvt}n|j}|j||d�}|j�~n,t|�}tj|dd�}|j�|jd	\}}tjj�}	|p�i}xN|j�D]B\}
}|
tkr�y|	|
j|�Wq�tk
�r||	|
<Yq�Xq�W|dk�r<tjj|	�}nd}||fS)z�
  Fetches a parsed schema entry by uri.

  If uri is a LDAP URL the LDAP server is queried directly.
  Otherwise uri is assumed to point to a LDIF file which
  is loaded with urllib.
  �ldap:�ldaps:�ldapi:�N)�attrsr)Zmax_entriesr)rbrcrd)rD�
startswith�ldapurlZLDAPUrlrZ
initializeZ
initializeUrlZVERSION3Zprotocol_versionZ
simple_bind_sZwhoZcredZsearch_subschemasubentry_sZdnrfrZread_subschemasubentry_sZunbind_sr�ldifZLDIFRecordList�parseZall_recordsrr(rr]r+rZr)
ZuriZtrace_levelZldap_urlr_Zsubschemasubentry_dnZs_tempZschema_attrsZ	ldif_fileZldif_parserZsubschemasubentry_entryZat�avZparsed_sub_schemar	r	r
�urlfetch�s@





rl)r)rarJZldap.cidictrZldap.schemaZldap.compatrZldap.schema.modelsrhrirrr)r#�varsrrVr!rrr\rrrrrlr	r	r	r
�<module>s*