src/Classes/AdldapUsers.php
public function password($username, $password, $isGUID = false)
    {
        $this->adldap->utilities()->validateNotNull('Username', $username);
        $this->adldap->utilities()->validateNotNull('Password', $password);

        $this->adldap->utilities()->validateLdapIsBound();

        if (!$this->adldap->getUseSSL() && !$this->adldap->getUseTLS()) {
            $message = 'SSL must be configured on your webserver and enabled in the class to set passwords.';

            throw new AdldapException($message);
        }

        $userDn = $this->dn($username, $isGUID);

        if ($userDn === false) {
            return false;
        }

        $add = [];

        $add['unicodePwd'][0] = $this->encodePassword($password);

        $result = $this->connection->modReplace($userDn, $add);

        if ($result === false) {
            $err = $this->connection->errNo();

            if ($err) {
                $error = $this->connection->err2Str($err);

                $msg = 'Error '.$err.': '.$error.'.';

                if ($err == 53) {
                    $msg .= ' Your password might not match the password policy.';
                }

                throw new AdldapException($msg);
            } else {
                return false;
            }
        }

        return true;
    }
public function password($username, $password, $isGUID = false)
    {
        $this->adldap->utilities()->validateNotNull('Username', $username);
        $this->adldap->utilities()->validateNotNull('Password', $password);

        $this->adldap->utilities()->validateLdapIsBound();

        if (!$this->adldap->getUseSSL() && !$this->adldap->getUseTLS()) {
            $message = 'SSL must be configured on your webserver and enabled in the class to set passwords.';

            throw new AdldapException($message);
        }

        $userDn = $this->dn($username, $isGUID);

        if ($userDn === false) {
            return false;
        }

        $add = [];

        $add['unicodePwd'][0] = $this->encodePassword($password);

        $result = $this->connection->modReplace($userDn, $add);

        if ($result === false) {
            $err = $this->connection->errNo();

            if ($err) {
                $error = $this->connection->err2Str($err);

                $msg = 'Error '.$err.': '.$error.'.';

                if ($err == 53) {
                    $msg .= ' Your password might not match the password policy.';
                }

                throw new AdldapException($msg);
            } else {
                return false;
            }
        }

        return true;
    }
public function password ( $ username , $ password , $ isGUID = false ) { $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Username' , $ username ) ; $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Password' , $ password ) ; $ this -> adldap -> utilities ( ) -> validateLdapIsBound ( ) ; if ( ! $ this -> adldap -> getUseSSL ( ) && ! $ this -> adldap -> getUseTLS ( ) ) { $ message = 'SSL must be configured on your webserver and enabled in the class to set passwords.' ; throw new AdldapException ( $ message ) ; } $ userDn = $ this -> dn ( $ username , $ isGUID ) ; if ( $ userDn === false ) { return false ; } $ add = [ ] ; $ add [ 'unicodePwd' ] [ 0 ] = $ this -> encodePassword ( $ password ) ; $ result = $ this -> connection -> modReplace ( $ userDn , $ add ) ; if ( $ result === false ) { $ err = $ this -> connection -> errNo ( ) ; if ( $ err ) { $ error = $ this -> connection -> err2Str ( $ err ) ; $ msg = 'Error ' . $ err . ': ' . $ error . '.' ; if ( $ err == 53 ) { $ msg .= ' Your password might not match the password policy.' ; } throw new AdldapException ( $ msg ) ; } else { return false ; } } return true ; }
Set the password of a user - This must be performed over SSL.

@param string $username The username to modify
@param string $password The new password
@param bool   $isGUID   Is the username passed a GUID or a samAccountName

@return bool

@throws AdldapException
Set the password of a user - This must be performed over SSL .