January 5, 2012 at 6:29 am
Can you remove the denys and check if the user still has those permissions?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 5, 2012 at 6:31 am
try this: maybe the login is a sysadmin:
you'll need to change the name of the login to your specific login/sql user in question:
EXECUTE AS LOGIN='ThatSpecificSQLUser';
--the auditing snippet below works fine in a
--login trigger,
--database trigger
--or any stored procedure.
SELECT
getdate() AS EventDate,
DB_NAME() AS DBName,
HOST_NAME() AS HostName,
APP_NAME() AS ApplicationName,
OBJECT_NAME(@@PROCID) AS ProcedureName,
USER_ID() AS Userid,
USER_NAME() AS UserName,
SUSER_ID() AS sUserid,
SUSER_SNAME() AS sUserName,
IS_SRVROLEMEMBER ('sysadmin') AS [Is_ServerAdmin_Sysadmin],
IS_MEMBER('db_owner') AS [Is_DB_owner],
IS_MEMBER('db_ddladmin') AS [Is_DDL_Admin],
IS_MEMBER('db_datareader') AS [Is_DB_Datareader],
ORIGINAL_LOGIN() AS [ORIGINAL_LOGIN],
client_net_address AS ipaddress,
auth_scheme AS AuthenticationType
FROM sys.dm_exec_connections where session_id = @@spid;
REVERT;
Lowell
January 5, 2012 at 10:22 am
GilaMonster (1/5/2012)
Can you remove the denys and check if the user still has those permissions?
Tried it, then right back to updates and altering ;(
January 5, 2012 at 10:23 am
Lowell (1/5/2012)
try this: maybe the login is a sysadmin:you'll need to change the name of the login to your specific login/sql user in question:
I get
'Msg 297, Level 16, State 1, Line 6
The user does not have permission to perform this action.'
when i run it.
Thank you
January 5, 2012 at 10:26 am
ajsnyman (1/5/2012)
Tried it, then right back to updates and altering ;(
remove the denials and the re run the script below and post the exact results
select dp.name, dbp.state_desc, dbp.permission_name, dbp.class_desc
from sys.database_principals dp inner join sys.database_permissions dbp
on dp.principal_id = dbp.grantee_principal_id
where dp.name = 'yoursqlacct'
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 5, 2012 at 10:37 am
Ok, here is the results:
namestate_descpermission_nameclass_desc
horizonReaderGRANTCONNECTDATABASE
horizonReaderDENYALTERSCHEMA
I am unable to remove the last entry due to an exception occurring.
But this deny also does not do anything, I am still able to alter.
Thanks you for your help.
January 5, 2012 at 10:37 am
db_datareader is granted for only Select
check out this : http://msdn.microsoft.com/en-us/library/ms189612(v=SQL.105).aspx
January 5, 2012 at 10:39 am
also, what does this return
select dp.state_desc, dp.permission_name, dp.class_desc, sch.name
from sys.database_permissions dp
inner join sys.schemas sch on dp.grantor_principal_id = sch.principal_id
where dp.class = 3
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 5, 2012 at 10:40 am
Thank you Ankit Shah, it seems that I'm having a funny variant of this role, for mine allow alter and update.
January 5, 2012 at 10:44 am
Perry, it returns the following:
state_descpermission_nameclass_descname
GRANTCONTROLSCHEMAdbo
GRANTCONTROLSCHEMAthys
GRANTCONTROLSCHEMApvn
GRANTCONTROLSCHEMAa
GRANTCONTROLSCHEMAutility
GRANTCONTROLSCHEMAutil
GRANTCONTROLSCHEMAmdt
DENYALTERSCHEMAdb_datareader
Hmm, i guess this should not be a factor, but this db was ported from 2005 where it was created to now 2008 R2.
January 5, 2012 at 10:48 am
And there you have your answer. GRANT CONTROL ON SCHEMA dbo essentially gives full control to the dbo schema and supercedes the db_datareader database role.
January 5, 2012 at 10:48 am
ajsnyman (1/5/2012)
GRANTCONTROLSCHEMAdbo
That'll do the job... That's full control over the schema
Could it be an explicit grant (not a role)?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 5, 2012 at 11:04 am
Thank you all so much, can't believe how many hours whent into this silly thing.
I now looked at the dbo schema's permissions and there is a public user with explicit grant permission allowed for user 'public'.
To be honest, it seems I do not understand the function of the CONTROL permission.
I guess this will also mean that all the db users will have this permission?
I should not have any problems removing this permission? Other than that I will have to check up on my current users still work 🙂
Thanks again :w00t::w00t:
January 5, 2012 at 11:28 am
ajsnyman (1/5/2012)
To be honest, it seems I do not understand the function of the CONTROL permission.
CONTROL is the highest available within the database. CONTROL implies all other permissions.
Granting CONTROL at the schema level is quite brave IMHO 🙂
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 5, 2012 at 11:34 am
ajsnyman (1/5/2012)
To be honest, it seems I do not understand the function of the CONTROL permission.
Full and complete permissions to the object and anything within it. (for example, a sysadmin has the permission CONTROL SERVER). So control on the schema means that the users could do anything to the schema (including drop it) and do anything to any of the objects within the schema (read, update, alter, create, drop, etc)
I guess this will also mean that all the db users will have this permission?
Yes. Every single user (and maybe even logins that don't explicitly have access to this DB) will have it
I should not have any problems removing this permission? Other than that I will have to check up on my current users still work 🙂
Maybe not that simple... Reducing permissions means you'll need to test all the apps to make sure nothing breaks,
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 15 posts - 16 through 30 (of 32 total)
You must be logged in to reply to this topic. Login to reply