sp_adduser

Adds a new user to the current database.

Syntax

sp_adduser loginame [, name_in_db [, grpname]]

Parameters

Examples

Usage

There are additional considerations when using sp_adduser:
  • The database owner executes sp_adduser to add a user name to the sysusers table of the current database, enabling the user to access the current database under his or her own name.

  • Specifying a name_in_db parameter gives the new user a name in the database that is different from his or her login name in SAP ASE. The ability to assign a user a different name is provided as a convenience. It is not an alias, as provided by sp_addalias, since it is not mapped to the identity and privileges of another user.

  • A user and a group cannot have the same name.

  • A user can be a member of only one group other than the default group, “public”. Every user is a member of the default group, “public”. Use sp_changegroup to change a user’s group.

  • In order to access a database, a user must either be listed in sysusers (with sp_adduser) or mapped to another user in sysalternates (with sp_addalias), or there must be a “guest” entry in sysusers.

See also grant, revoke, use in Reference Manual: Commands.

Permissions

The permission checks for sp_adduser differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with manage any user privilege.

Disabled

With granular permissions disabled, you must be the database owner, a user with sa_role, or a user with sso_role.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_addalias
sp_addgroup
sp_changegroup
sp_dropalias
sp_dropgroup
sp_helpuser