Saturday, April 9, 2016

Checking which users can run which procedures in SQL Anywhere

If you're interested in getting the security information on your SQL Anywhere stored procedures, you can use this little query:

select su.user_name, sp.proc_name from SYS.SYSPROCPERM sg
inner join SYS.SYSUSER su on su.user_id = sg.grantee 
inner join SYS.SYSPROCEDURE sp on sp.proc_id = sg.proc_id

You'll get a list of grants, with the grantee user's name and the name of the procedure on which execute permission has been granted.

If you're just interested in one user's permissions, use this:

select sp.proc_name from SYS.SYSPROCPERM sg
inner join SYS.SYSUSER su on su.user_id = sg.grantee 
inner join SYS.SYSPROCEDURE sp on sp.proc_id = sg.proc_id
where su.user_name = 'USERNAME'

You'll just get a list of procedures that the user can run.

(Tested on SQL Anywhere 11. May or may not work on other versions or similar products.)

No comments:

Post a Comment