public function setPassword($password)
    {
        $this->validateSecureConnection();

        $encodedPassword = Utilities::encodePassword($password);

        if ($this->exists) {
            // If the record exists, we need to add a batch replace
            // modification, otherwise we'll receive a "type or
            // value" exists exception from our LDAP server.
            return $this->addModification(
                $this->newBatchModification(
                    $this->schema->unicodePassword(),
                    LDAP_MODIFY_BATCH_REPLACE,
                    [$encodedPassword]
                )
            );
        } else {
            // Otherwise, we are creating a new record
            // and we can set the attribute normally.
            return $this->setFirstAttribute(
                $this->schema->unicodePassword(),
                $encodedPassword
            );
        }
    }
public function setPassword($password)
    {
        $this->validateSecureConnection();

        $encodedPassword = Utilities::encodePassword($password);

        if ($this->exists) {
            // If the record exists, we need to add a batch replace
            // modification, otherwise we'll receive a "type or
            // value" exists exception from our LDAP server.
            return $this->addModification(
                $this->newBatchModification(
                    $this->schema->unicodePassword(),
                    LDAP_MODIFY_BATCH_REPLACE,
                    [$encodedPassword]
                )
            );
        } else {
            // Otherwise, we are creating a new record
            // and we can set the attribute normally.
            return $this->setFirstAttribute(
                $this->schema->unicodePassword(),
                $encodedPassword
            );
        }
    }
public function setPassword ( $ password ) { $ this -> validateSecureConnection ( ) ; $ encodedPassword = Utilities :: encodePassword ( $ password ) ; if ( $ this -> exists ) { // If the record exists, we need to add a batch replace // modification, otherwise we'll receive a "type or // value" exists exception from our LDAP server. return $ this -> addModification ( $ this -> newBatchModification ( $ this -> schema -> unicodePassword ( ) , LDAP_MODIFY_BATCH_REPLACE , [ $ encodedPassword ] ) ) ; } else { // Otherwise, we are creating a new record // and we can set the attribute normally. return $ this -> setFirstAttribute ( $ this -> schema -> unicodePassword ( ) , $ encodedPassword ) ; } }
Sets the password on the current user.

@param string $password

@throws AdldapException When no SSL or TLS secured connection is present.

@return $this
Sets the password on the current user .