The syUserInRole() function is used to find whether a user is assigned to specific server or database roles for SQL Server.
syUserInRole(user_ID, role {, database})
• user_ID – A string specifying the ID of a user in Microsoft Dynamics GP.
• role – A string specifying the role being examined. Use one of the following constants:
Constant |
Description |
---|---|
ROLE_SYSADMIN |
Members of the sysadmin fixed server role can perform any activity in the database. |
ROLE_SECURITYADMIN |
Members of the securityadmin fixed server role manage logins and their properties. They can GRANT, DENY, and REVOKE server-level permissions. They can also GRANT, DENY, and REVOKE database-level permissions. Additionally, they can reset passwords for SQL Server logins. |
ROLE_DBCREATOR |
Members of the dbcreator fixed server role can create, alter, drop, and restore any database. |
ROLE_DBOWNER* |
Members of the db_owner fixed database role can perform all configuration and maintenance activities on the database. |
ROLE_DBACCESSADMIN* |
Members of the db_accessadmin fixed database role can add or remove access for Windows logins, Windows groups, and SQL Server logins. |
ROLE_DBSECURITYADMIN* |
Members of the db_securityadmin fixed database role can modify role membership and manage permissions. |
ROLE_DBBACKUPOPERATOR* |
Members of the db_backupoperator fixed database role can backup the database. |
*Requires the database to be specified |
• database – An optional string parameter specifying the database for which access is being examined. This parameter must be supplied when querying whether a user is assigned to a specific role for the database.
A boolean. The value true indicates the user is in the specified role, while false indicates the user is not.
The 'User ID' global variable contains the user ID for the user currently logged into Microsoft Dynamics GP. The 'Intercompany ID' global variable contains the database name for the current company’s database.