src/Classes/AdldapUsers.php
public function modify($username, $attributes, $isGUID = false)
    {
        $user = new User($attributes);

        /*
         * Set the username attribute manually so it's properly
         * validated using toModifySchema method
         */
        $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);
    }
public function modify($username, $attributes, $isGUID = false)
    {
        $user = new User($attributes);

        /*
         * Set the username attribute manually so it's properly
         * validated using toModifySchema method
         */
        $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);
    }
public function modify ( $ username , $ attributes , $ isGUID = false ) { $ user = new User ( $ attributes ) ; /*
         * Set the username attribute manually so it's properly
         * validated using toModifySchema method
         */ $ 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 ) ; }
Modify a user.

@param string $username   The username to query
@param array  $attributes The attributes to modify.  Note if you set the enabled attribute you must not specify any other attributes
@param bool   $isGUID     Is the username passed a GUID or a samAccountName

@return bool|string

@throws AdldapException
Modify a user .