src/Classes/AdldapExchange.php
public function deleteAddress($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'])) {
            $mod = [];

            for ($i = 0; $i < $user[0]['proxyaddresses']['count']; $i++) {
                if (strpos($user[0]['proxyaddresses'][$i], 'SMTP:') !== false && $user[0]['proxyaddresses'][$i] == 'SMTP:'.$emailAddress) {
                    $mod['proxyAddresses'][0] = 'SMTP:'.$emailAddress;
                } elseif (strpos($user[0]['proxyaddresses'][$i], 'smtp:') !== false && $user[0]['proxyaddresses'][$i] == 'smtp:'.$emailAddress) {
                    $mod['proxyAddresses'][0] = 'smtp:'.$emailAddress;
                }
            }

            return $this->connection->modDelete($userDn, $mod);
        }

        return false;
    }
public function deleteAddress($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'])) {
            $mod = [];

            for ($i = 0; $i < $user[0]['proxyaddresses']['count']; $i++) {
                if (strpos($user[0]['proxyaddresses'][$i], 'SMTP:') !== false && $user[0]['proxyaddresses'][$i] == 'SMTP:'.$emailAddress) {
                    $mod['proxyAddresses'][0] = 'SMTP:'.$emailAddress;
                } elseif (strpos($user[0]['proxyaddresses'][$i], 'smtp:') !== false && $user[0]['proxyaddresses'][$i] == 'smtp:'.$emailAddress) {
                    $mod['proxyAddresses'][0] = 'smtp:'.$emailAddress;
                }
            }

            return $this->connection->modDelete($userDn, $mod);
        }

        return false;
    }
public function deleteAddress ( $ 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' ] ) ) { $ mod = [ ] ; for ( $ i = 0 ; $ i < $ user [ 0 ] [ 'proxyaddresses' ] [ 'count' ] ; $ i ++ ) { if ( strpos ( $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] , 'SMTP:' ) !== false && $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] == 'SMTP:' . $ emailAddress ) { $ mod [ 'proxyAddresses' ] [ 0 ] = 'SMTP:' . $ emailAddress ; } elseif ( strpos ( $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] , 'smtp:' ) !== false && $ user [ 0 ] [ 'proxyaddresses' ] [ $ i ] == 'smtp:' . $ emailAddress ) { $ mod [ 'proxyAddresses' ] [ 0 ] = 'smtp:' . $ emailAddress ; } } return $ this -> connection -> modDelete ( $ userDn , $ mod ) ; } return false ; }
Remove an address to Exchange.
If you remove a default address the account will no longer have a default,
we recommend changing the default address first.

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

@return bool|string
Remove an address to Exchange . If you remove a default address the account will no longer have a default we recommend changing the default address first .