MCPcopy Index your code
hub / github.com/secdev/scapy / add

Method add

scapy/layers/ldap.py:2370–2412  ·  view source on GitHub ↗

Perform a LDAP add request. :param attributes: the attributes to add. We support two formats: - a list of LDAP_Attribute (or LDAP_PartialAttribute) - a dict following {attribute: [list of values]} :returns:

(
        self,
        entry: str,
        attributes: Union[Dict[str, List[Any]], List[ASN1_Packet]],
        controls: List[LDAP_Control] = [],
    )

Source from the content-addressed store, hash-verified

2368 )
2369
2370 def add(
2371 self,
2372 entry: str,
2373 attributes: Union[Dict[str, List[Any]], List[ASN1_Packet]],
2374 controls: List[LDAP_Control] = [],
2375 ):
2376 """
2377 Perform a LDAP add request.
2378
2379 :param attributes: the attributes to add. We support two formats:
2380 - a list of LDAP_Attribute (or LDAP_PartialAttribute)
2381 - a dict following {attribute: [list of values]}
2382
2383 :returns:
2384 """
2385 # We handle the two cases in the type of attributes
2386 if isinstance(attributes, dict):
2387 attributes = [
2388 LDAP_Attribute(
2389 type=ASN1_STRING(k),
2390 values=[
2391 LDAP_AttributeValue(
2392 value=ASN1_STRING(x),
2393 )
2394 for x in v
2395 ],
2396 )
2397 for k, v in attributes.items()
2398 ]
2399
2400 resp = self.sr1(
2401 LDAP_AddRequest(
2402 entry=ASN1_STRING(entry),
2403 attributes=attributes,
2404 ),
2405 controls=controls,
2406 timeout=self.timeout,
2407 )
2408 if LDAP_AddResponse not in resp.protocolOp or resp.protocolOp.resultCode != 0:
2409 raise LDAP_Exception(
2410 "LDAP add failed !",
2411 resp=resp,
2412 )
2413
2414 def modifydn(
2415 self,

Callers 9

add_keywordsMethod · 0.45
parse_txt_hdrsMethod · 0.45
__pois_to_requestsMethod · 0.45
dijkstraMethod · 0.45
__init__Method · 0.45
network_statsMethod · 0.45

Calls 7

sr1Method · 0.95
ASN1_STRINGClass · 0.90
LDAP_AttributeClass · 0.85
LDAP_AttributeValueClass · 0.85
LDAP_AddRequestClass · 0.85
LDAP_ExceptionClass · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected