LdapTools\Utilities\LdapUtilities::getRdnFromDn PHP Метод

getRdnFromDn() публичный статический Метод

Given a full escaped DN return the RDN in escaped form.
public static getRdnFromDn ( string $dn ) : string
$dn string
Результат string
    public static function getRdnFromDn($dn)
    {
        $rdn = self::explodeDn($dn, 0)[0];
        $rdn = explode('=', $rdn, 2);
        return $rdn[0] . '=' . self::escapeValue($rdn[1], null, LDAP_ESCAPE_DN);
    }

Usage Example

Пример #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));
 }
All Usage Examples Of LdapTools\Utilities\LdapUtilities::getRdnFromDn