getRdnFromDn() public static method

Given a full escaped DN return the RDN in escaped form.
public static getRdnFromDn ( string $dn ) : string
$dn string
return string
コード例 #1
0
 /**
  * Moves an object from one container/OU to another in LDAP.
  *
  * @param LdapObject $ldapObject
  * @param string $container
  */
 public function move(LdapObject $ldapObject, $container)
 {
     $event = new LdapObjectMoveEvent(Event::LDAP_OBJECT_BEFORE_MOVE, $ldapObject, $container);
     $this->dispatcher->dispatch($event);
     $container = $event->getContainer();
     $this->validateObject($ldapObject);
     $operation = new RenameOperation($ldapObject->get('dn'), LdapUtilities::getRdnFromDn($ldapObject->get('dn')), $container, true);
     $this->connection->execute($operation);
     // Update the object to reference the new DN after the move...
     $newDn = LdapUtilities::getRdnFromDn($ldapObject->get('dn')) . ',' . $container;
     $ldapObject->refresh(['dn' => $newDn]);
     $ldapObject->getBatchCollection()->setDn($newDn);
     $this->dispatcher->dispatch(new LdapObjectMoveEvent(Event::LDAP_OBJECT_AFTER_MOVE, $ldapObject, $container));
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function toOperation()
 {
     // If this is a move operation to a new OU and we have a DN already, then we can figure out the RDN.
     if (is_null($this->newRdn) && !is_null($this->newSuperior)) {
         $rdn = LdapUtilities::getRdnFromDn($this->dn);
     } else {
         $rdn = $this->newRdn;
     }
     return new RenameOperation($this->dn, $rdn, $this->newSuperior, $this->deleteOldRdn);
 }