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

Method modifydn

scapy/layers/ldap.py:2414–2456  ·  view source on GitHub ↗

Perform a LDAP modify DN request. ..note:: This functions calculates the relative DN and superior required for LDAP ModifyDN automatically. :param entry: the DN of the entry to rename. :param newdn: the new FULL DN of the entry. :returns:

(
        self,
        entry: str,
        newdn: str,
        deleteoldrdn=True,
        controls: List[LDAP_Control] = [],
    )

Source from the content-addressed store, hash-verified

2412 )
2413
2414 def modifydn(
2415 self,
2416 entry: str,
2417 newdn: str,
2418 deleteoldrdn=True,
2419 controls: List[LDAP_Control] = [],
2420 ):
2421 """
2422 Perform a LDAP modify DN request.
2423
2424 ..note:: This functions calculates the relative DN and superior required for
2425 LDAP ModifyDN automatically.
2426
2427 :param entry: the DN of the entry to rename.
2428 :param newdn: the new FULL DN of the entry.
2429 :returns:
2430 """
2431 # RFC4511 sect 4.9
2432 # Calculate the newrdn (relative DN) and superior
2433 newrdn, newSuperior = newdn.split(",", 1)
2434 _, cur_superior = entry.split(",", 1)
2435 # If the superior hasn't changed, don't update it.
2436 if cur_superior == newSuperior:
2437 newSuperior = None
2438 # Send the request
2439 resp = self.sr1(
2440 LDAP_ModifyDNRequest(
2441 entry=entry,
2442 newrdn=newrdn,
2443 newSuperior=newSuperior,
2444 deleteoldrdn=deleteoldrdn,
2445 ),
2446 controls=controls,
2447 timeout=self.timeout,
2448 )
2449 if (
2450 LDAP_ModifyDNResponse not in resp.protocolOp
2451 or resp.protocolOp.resultCode != 0
2452 ):
2453 raise LDAP_Exception(
2454 "LDAP modify failed !",
2455 resp=resp,
2456 )
2457
2458 def close(self):
2459 if self.verb:

Callers

nothing calls this directly

Calls 3

sr1Method · 0.95
LDAP_ExceptionClass · 0.85

Tested by

no test coverage detected