HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //lib64/python3.9/site-packages/ldap/schema/__pycache__/subentry.cpython-39.pyc
a

�.d�>�@s�dZddlZddlmZddlZddlZddlTddlZddl	Z	ej
�
�ZiZe
e����D]"Zeed�r\eeej<ejee<q\e
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.9/site-packages/ldap/schema/subentry.pyrsrc@seZdZdd�Zdd�ZdS)�OIDNotUniquecCs
||_dS�N��desc��selfrr	r	r
�__init__"szOIDNotUnique.__init__cCs
d|jS)NzOID not unique for %sr
�rr	r	r
�__str__%szOIDNotUnique.__str__N�rrrrrr	r	r	r
r src@seZdZdd�Zdd�ZdS)�
NameNotUniquecCs
||_dSrr
rr	r	r
r+szNameNotUnique.__init__cCs
d|jS)NzNAME not unique for %sr
rr	r	r
r.szNameNotUnique.__str__Nrr	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|_t��D].}tj��|j|<i|j|<tj��|j|<q tj�|�}tD�]}t	d|�
|g��D�]�}t|}||�}|��}	|�r|	|j|v�rd|j|	<|dkr�d}
|	}||j|vr�d�|	t
|
�f�}|
d7}
q�|}	n|dk�rt|��||j||	<t|d�rxtj�i�|j��D]B}|�rf||j|v�rfd|j||	<t|��n|	|j||<�q4qxq`t|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)
rZsub_schema_sub_entryZcheck_uniqueness�c�eZ	attr_typeZ
attr_value�se_classZse_instanceZse_idZsuffix_counterZ	new_se_id�namer	r	r
rRsD






zSubSchema.__init__c
Csji}|j��D]V\}}|��D]D}t|�}z|t|�|�Wqty`|g|t|<Yq0qq|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�szSubSchema.ldap_entryNc	
Csp|j|}|rdg}|��D]F\}}|D]8\}}zt||�|vrH|�|�Wq&ty\Yq&0q&qnt|�}|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_keyr3ZfkZfvr	r	r
�listall�s
zSubSchema.listallcCs�|ttfvsJ�|�||�}d}tj�|gi�}|D]}g||<q4|D]z}|�||d�}|j|krdqF|j|ks�Jd�||j|j���|j	p�dD]0}	|�
||	�}
z||
�|�Wq�Yq�0q�qF|S)zm
    Returns a ldap.cidict.cidict dictionary representing the
    tree structure of the schema elements.
    �_Nz>Schema element referenced by {} must be of class {} but was {})r<)�ObjectClass�
AttributeTyper;rr �get_obj�	__class__�formatr�sup�getoidr/)rr7r8r9Ztop_node�treer3�se_oid�se_obj�sZsup_oidr	r	r
rD�s,


��
zSubSchema.treerc	Csn|�d�d��}||j|vr$|Sz|j||}Wn2tyh|r`td�|jt|����n|}Yn0|S)z#
    Get an OID by name or OID
    rrz%No registered {}-OID for nameoroid {})�split�striprrr0rAr�repr)rr+�	nameoroid�raise_keyerrorZnameoroid_strippedZ
result_oidr	r	r
rC�s
zSubSchema.getoidcCsb|j||�||�}zt||�}Wnty:d}Yn0|dur^|jr^|�||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)rrCr5r6rB�get_inheritedattr)rr+rKr,r3r:r	r	r
rM�s
zSubSchema.get_inheritedattrc
Cs\|�||�}z|j||}Wn8tyV|rNtd�|jt|�t|����n|}Yn0|S)z-
    Get a schema element by name or OID
    z:No ldap.schema.{} instance with nameoroid {} and se_oid {})rCrr0rArrJ)rr+rK�defaultrLrErFr	r	r
r?�s�
zSubSchema.get_objc	CsX|pg}t�|j|�|�||���}|rTt|d�rT|D]}t|||�|||��q8|S)zt
    Get a schema element by name or OID with all class attributes
    set including inherited class attributes
    rB)�copyrr#rCr&�setattrrM)rr+rKZ	inheritedr3Zclass_attr_namer	r	r
�get_inheritedobjszSubSchema.get_inheritedobjcCs<|�t|�}z|�t|�}Wnty0YdS0|jSdS)zF
    Get the syntax of an attribute type specified by name or OID
    N)rCr>rQr0Zsyntax)rrKZat_oid�at_objr	r	r
�
get_syntaxszSubSchema.get_syntaxc
Cs�|�tddgfg�}i}|D]*}|�t|d�}|r|jdkrd||j<qd}t|�}|r�|��}||D]}	|�t|	�|vrhqTqh|}qT|S)ze
    Returns OID of structural object class in oc_list
    if any is present. Returns None else.
    �kindrN)rDr=r?rT�oidr(�poprC)
rZoc_listZoc_treeZ
struct_ocsZoc_nameoroidZoc_ser:Zstruct_oc_listrUZ	child_oidr	r	r
�get_structural_ocszSubSchema.get_structural_occCs.|�t|�}|r|jS|�tddgfg�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.
    rTrN)r?�DITContentRuleZauxr;r=)rrKZcontent_ruler	r	r
�get_applicable_aux_classes8sz$SubSchema.get_applicable_aux_classescstjj}tjj���fdd�|D�}i}tj��tj��}}	d|vrd�j|��D]}
|
|	|
j<qT|�rp|�d�}||vr~qdd||<z�j�|}Wnt	y�|r��YqdYn0t
|��s�J�t|d�s�Jt|���t|d�s�Jt|���|j
D](}
�j||
|d�}�j|||d�||<q�|jD]*}
�j||
|d�}�j|||d�|	|<�q&|���fd	d�|jD��qd|�sR��|�}|�rRz�jt|d
d�}Wnt	�y�Yn�0|j
D]*}
�j||
|d�}�j|||d�||<�q�|jD]*}
�j||
|d�}�j|||d�|	|<�q�|jD]6}
�j||
|d�}z
|	|=Wnt	�yLYn0�qt|	�D]}
|
|v�rZ|	|
=�qZ|�r||	fD]�}t|�D]z}
|D]n\}}z�j||
}Wn4t	�y�|�r�t	d|
��||
=Y�q�Yn0t||�|v�r�||
=�q��q��q��q�||	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|]}���|��qSr	�rC��.0�o�r=rr	r
�
<listcomp>bs�z-SubSchema.attribute_types.<locals>.<listcomp>z1.3.6.1.4.1.1466.101.120.111rN�must�may)rLcsg|]}���|��qSr	rZr[r^r	r
r_�s�rz0No attribute type found in sub schema by name %s)r�schemar>r=r rrrUrVr0�
isinstancer&�
ValueErrorr`rCr?ra�extendrBrWrXZnotsr(r5)rZobject_class_listZattr_type_filterrLZignore_dit_content_ruler>Zobject_class_oidsZ	oid_cacheZr_mustZr_mayrRZobject_class_oidZobject_class�arEZ
structural_ocZdit_content_ruleZa_oid�lZafkZafvZschema_attr_typer	r^r
�attribute_typesHs��



�








zSubSchema.attribute_types)r)N)N)r)Nr)N)Nrr)rrr�__doc__rr4r;rDrCrMr?rQrSrWrYrhr	r	r	r
r2s
7

 




�rc
	CsB|��}|�d�r�t�|�}t�|��|�}tj|_|�	|j
p@d|jpHd�|�|j
�}|durfd}n$|jdurvt}n|j}|j||d�}|��~n,t|�}tj|dd�}|��|jd\}}tj��}	|p�i}|��D]@\}
}|
tvr�z|	|
�|�Wq�t�y||	|
<Yq�0q�|dk�r6tj�|	�}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.
  )zldap:zldaps:zldapi:�N)�attrsr)Zmax_entriesr)rI�
startswith�ldapurlZLDAPUrlrZ
initializeZ
initializeUrlZVERSION3Zprotocol_versionZ
simple_bind_sZwhoZcredZsearch_subschemasubentry_sZdnrkr!Zread_subschemasubentry_sZunbind_sr�ldifZLDIFRecordList�parseZall_recordsr r-rrer0rbr)
ZuriZtrace_levelZldap_urlrgZsubschemasubentry_dnZs_tempZschema_attrsZ	ldif_fileZldif_parserZsubschemasubentry_entryZat�avZparsed_sub_schemar	r	r
�urlfetch�sB


�

rq)r)rirOZurllib.requestrZldap.cidictrZldap.schemaZldap.schema.modelsrmrnr rr.r(�varsrr]r&rr!rdrrrrrqr	r	r	r
�<module>s*