Adds a new user to the current database.
sp_adduser loginame [, name_in_db [, grpname]]
is the user’s name in master.dbo.syslogins.
is a new name for the user in the current database.
adds the user to an existing group in the database.
Adds “margaret” to the database. Her database user name is the same as her Adaptive Server login name, and she belongs to the default group, “public”:
sp_adduser margaret
Adds “haroldq” to the database. When “haroldq” uses the current database, his name is “harold.” He belongs to the fort_mudge group, as well as to the default group “public”:
sp_adduser haroldq, harold, fort_mudge
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 Adaptive Server. 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.
The permission checks for sp_adduser differ based on your granular permissions settings.
Granular permissions enabled |
With granular permissions enabled, you must be a user with manage any user privilege. |
Granular permissions disabled |
With granular permissions disabled, you must be the database owner, a user with sa_role, or a user with sso_role. |
Values in event and extrainfo columns from the sysaudits table are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
38 |
exec_procedure |
Execution of a procedure |
|
System procedures sp_addalias, sp_addgroup, sp_changegroup, sp_dropalias, sp_dropgroup, sp_helpuser