src/Classes/AdldapExchange.php
public function primaryAddress($username, $emailAddress, $isGUID = false)
    {
        $this->adldap->utilities()->validateNotNull('Username', $username);
        $this->adldap->utilities()->validateNotNull('Email Address', $emailAddress);

        // Find the dn of the user
        $user = $this->adldap->user()->info($username, ['cn', 'proxyaddresses'], $isGUID);

        if ($user[0]['dn'] === null) {
            return false;
        }

        $userDn = $user[0]['dn'];

        if (is_array($user[0]['proxyaddresses'])) {
            $modAddresses = [];

            for ($i = 0; $i < $user[0]['proxyaddresses']['count']; $i++) {
                if (strpos($user[0]['proxyaddresses'][$i], 'SMTP:') !== false) {
                    $user[0]['proxyaddresses'][$i] = str_replace('SMTP:', 'smtp:', $user[0]['proxyaddresses'][$i]);
                }

                if ($user[0]['proxyaddresses'][$i] == 'smtp:'.$emailAddress) {
                    $user[0]['proxyaddresses'][$i] = str_replace('smtp:', 'SMTP:', $user[0]['proxyaddresses'][$i]);
                }

                if ($user[0]['proxyaddresses'][$i] != '') {
                    $modAddresses['proxyAddresses'][$i] = $user[0]['proxyaddresses'][$i];
                }
            }

            return $this->connection->modReplace($userDn, $modAddresses);
        }

        return false;
    }
public function primaryAddress($username, $emailAddress, $isGUID = false)
    {
        $this->adldap->utilities()->validateNotNull('Username', $username);
        $this->adldap->utilities()->validateNotNull('Email Address', $emailAddress);

        // Find the dn of the user
        $user = $this->adldap->user()->info($username, ['cn', 'proxyaddresses'], $isGUID);

        if ($user[0]['dn'] === null) {
            return false;
        }

        $userDn = $user[0]['dn'];

        if (is_array($user[0]['proxyaddresses'])) {
            $modAddresses = [];

            for ($i = 0; $i < $user[0]['proxyaddresses']['count']; $i++) {
                if (strpos($user[0]['proxyaddresses'][$i], 'SMTP:') !== false) {
                    $user[0]['proxyaddresses'][$i] = str_replace('SMTP:', 'smtp:', $user[0]['proxyaddresses'][$i]);
                }

                if ($user[0]['proxyaddresses'][$i] == 'smtp:'.$emailAddress) {
                    $user[0]['proxyaddresses'][$i] = str_replace('smtp:', 'SMTP:', $user[0]['proxyaddresses'][$i]);
                }

                if ($user[0]['proxyaddresses'][$i] != '') {
                    $modAddresses['proxyAddresses'][$i] = $user[0]['proxyaddresses'][$i];
                }
            }

            return $this->connection->modReplace($userDn, $modAddresses);
        }

        return false;
    }
public function primaryAddress ( $ username , $ emailAddress , $ isGUID = false ) { $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Username' , $ username ) ; $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Email Address' , $ emailAddress ) ; // Find the dn of the user $ user = $ this -> adldap -> user ( ) -> info ( $ username , [ 'cn' , 'proxyaddresses' ] , $ isGUID ) ; if ( $ user [ 0 ] [ 'dn' ] === null ) { return false ; } $ userDn = $ user [ 0 ] [ 'dn' ] ; if ( is_array ( $ user [ 0 ] [ 'proxyaddresses' ] ) ) { $ modAddresses = [ ] ; for ( $ i = 0 ; $ i < $ user [ 0 ] [ 'proxyaddresses' ] [ 'count' ] ; $ i ++ ) { if ( strpos ( $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] , 'SMTP:' ) !== false ) { $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] = str_replace ( 'SMTP:' , 'smtp:' , $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] ) ; } if ( $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] == 'smtp:' . $ emailAddress ) { $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] = str_replace ( 'smtp:' , 'SMTP:' , $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] ) ; } if ( $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] != '' ) { $ modAddresses [ 'proxyAddresses' ] [ $ i ] = $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] ; } } return $ this -> connection -> modReplace ( $ userDn , $ modAddresses ) ; } return false ; }
Change the default address.

@param string $username     The username of the user to add the Exchange account to
@param string $emailAddress The email address to make default
@param bool   $isGUID       Is the username passed a GUID or a samAccountName

@return bool|string
Change the default address .