public function testUserToModifySchemaContainerFailure() { $attributes = $this->stubbedUserAttributes(); $user = new User($attributes); $user->setAttribute('container', ''); $this->setExpectedException('Adldap\\Exceptions\\AdldapException'); $user->toModifySchema(); }
public function modify($username, $attributes, $isGUID = false) { $user = new User($attributes); $user->setAttribute('username', $username); if ($user->getAttribute('password') && !$this->connection->canChangePasswords()) { throw new AdldapException('SSL/TLS must be configured on your webserver and enabled in the class to set passwords.'); } // Find the dn of the user $userDn = $this->dn($username, $isGUID); if ($userDn === false) { return false; } // Translate the update to the LDAP schema $mod = $this->adldap->ldapSchema($user->toModifySchema()); $enabled = $user->getAttribute('enabled'); // Check to see if this is an enabled status update if (!$mod && !$enabled) { return false; } if ($enabled) { $controlOptions = ['NORMAL_ACCOUNT']; } else { $controlOptions = ['NORMAL_ACCOUNT', 'ACCOUNTDISABLE']; } $mod['userAccountControl'][0] = $this->accountControl($controlOptions); // Do the update return $this->connection->modify($userDn, $mod); }