Core\Ldap\Change::removeAll
Core\Ldap\Change::removeAll(string $attribute): Core\Ldap\ChangeCore\Ldap\Change::removeAll( string $attribute, ): Core\Ldap\Change
Returns a Core\Ldap\Change that removes an attribute and every value it has from a directory entry. You give only the attribute's name.
The change does nothing on its own. You put it in a list and pass the list to a connection's modify method. modify sends every change in the list in one request, so the server makes all of them or none of them.
Good to know: the entry must have the attribute. If it does not, modify throws an LdapError. replace with null also removes an attribute, and it works when the attribute is missing. A name that is not an attribute name throws a LogicError at once.
Parameters
$attributestringThe attribute's name, such asdescription. It cannot betainted.
Return value
Returns Core\Ldap\Change. The change.
Errors
LogicErrorattributeis not an attribute name.
Examples
Clear the pager number
<?nvs// Shows how to prepare a change that removes an attribute from a user.
var $clear = Core\Ldap\Change::removeAll('pager');// The user has no `pager` value after `modify` sends this list. This prints 1.array<Core\Ldap\Change> $changes = [$clear];echo Core\Arr::count($changes), "\n";1Clear several attributes
<?nvs// Shows how to build one change for each attribute in a list.
array<string> $names = ['pager', 'mobile', 'facsimileTelephoneNumber'];array<Core\Ldap\Change> $changes = [];foreach ($names as string $name) { $changes[] = Core\Ldap\Change::removeAll($name);}// This prints 3.echo Core\Arr::count($changes), "\n";3An empty name
<?nvs// Shows the error for an empty attribute name.
try { var $clear = Core\Ldap\Change::removeAll(''); echo "the change is ready\n";} catch (LogicError $refusal) { // This prints the error message. echo $refusal->message, "\n";}Core\Ldap\Change::removeAll: `` is not an attribute name. A name starts with a letter and has only letters, digits and `-`, such as `sAMAccountName`