How to associate an existing user to a site in a multisite setup programmatically

After looking the code the create user, i found that that I can do:

$userdata = get_user_by('login', 'user1'); 
add_existing_user_to_blog( array( 'user_id' => $userdata->ID, 'role' => 'author'));

Fix: was missing closing )