When you add a remote user, you must add both the login ID and the remote login ID on the server being set up as the user's remote server. The login ID is the ID on the server that is set up as the user's remote server. The remote login ID maps the login ID on the remote server to the login ID on the user's local server.
This login ID will be used as the remote user's login ID on this remote server.
To add a remote login ID, you use sp_addremotelogin to map the user's login ID on the user's local server to the new login ID on this remote server.
sp_addremotelogin remoteserver [, login_ID [, remotename]]
where
When a remote login is received, the local server tries to map the remote user to a local user in three different ways.
The following examples show the different ways to add remote users. If you want to change from one method to the other, you must use sp_dropremotelogin to remove the old mapping, as described later in this chapter in Dropping Remote Users.
For example, suppose all the users in your business use the local server ACCOUNTS. You set up the EXPENSES server as a remote server for ACCOUNTS. Before users can access remote procedures on EXPENSES from ACCOUNTS, you must give them remote login IDs.
You must use the remote server EXPENSES to do the following procedures. The first example maps a user to a particular login ID.
From the Server Manager window, select EXPENSES. From the Manage menu, choose Logins. From the Manage Logins dialog box, add the salesmgr login ID.
sp_addremotelogin accounts, salesmgr, chris
The next example maps all users to one remote login ID.
From the Server Manager window, select EXPENSES. From the Manage menu, choose Logins. From the Manage Logins dialog box, add the salesgroup login ID.
sp_addremotelogin accounts, salesgroup
This inserts a NULL in the sysremotelogins table. Note that you can only map users on a server once with a NULL.
The last example maps all users to the same local and remote login IDs.
From the Server Manager window, select EXPENSES. From the Manage menu, choose Logins. From the Manage Logins dialog box, add the following login IDs: john, steve, mary, and john.
sp_addremotelogin accounts
This inserts NULL in the remoteusername column in the sysremotelogins table and - 1 in the suid column.
You can map users only once with a null value. You can have only one NULL value per server in the sysremotelogins table.
When you add a login ID, the login ID is entered in the syslogins table. When you add a remote login ID, SQL Server checks the syslogins table and then adds the remote login ID to the sysremotelogins table. When you view the sysservers table, the local server (the server you are logged in to) has a srvid (server identification) of 0.