Deny access from Sql Server Management Studio

Hello!

I’m setting up a new SQL Server 2005 instance which will host a NAV 5Sp1 DB.

I needed to deny access to some NAV tables to some users, so I set up the rights from within NAV and everything is fine. Now I want to make sure that a user who can’t access tables from within NAV can’t access them from, say, SQL Server Management Studio or another external tool. I know I need to assign or deny permissions to the tables to each user, or even to roles I’ll later bind to users, but the problem is that the work is huge (I have custom objects which bring the number of tables well over 1000).

Is there a standard/fast way to accomplish my goal, or do I have to think about it from scratch? I already have ideas, but I hoped a best practice already existed…

Thank you in advance!

Use the Standard security model instead of the ‘enhanced’ one, you’ll only have access to the tables on SQL Server through the NAV client. You should not have to do anything to any of the permissions on SQL Server directly.

Hi!

Well, it doesn’t matter which NAV “Security Model” is set. All “normal” users are assigned to the server- and database-role “public”. Thus, if they are able to logon to the server/database e.g. with non-NAV tools, they have all access-rights of this role.

If you want to restrict access I could think about two options:

  1. Modify the database role “public” by DENYING the access-right for those tables you want to restrict. For example:

USE [Navision]
GO
DENY SELECT, INSERT, UPDATE, DELETE ON [dbo].[CRONUS$Item] TO [public]
GO

This would mean, if the user is accessing the db via NAV the “application role” ("$ndo$shadow" with “Standard”, “$ndo$ar$…” with “Enhanced” Security Model); else the - modified - “database role” “public” would be used.

But actually it is not really recommended to fiddle with standard roles. So I would go for this option:

  1. Create a new “database role” where you set up all table restrictions, e.g. “nav_restrictions”:

USE [Navision]
GO
CREATE ROLE [nav_restrictions] AUTHORIZATION [dbo]
GO
DENY SELECT, INSERT, UPDATE, DELETE ON [dbo].[CRONUS$Item] TO [nav_restrictions]
GO

Assign this role to the relevant users, thus these users have the roles “public” and “nav_restrictions”!

USE [Navision]
GO
EXEC sp_addrolemember N’nav_restrictions’, N’UserXYZ’
GO

Have in mind that a DENY right will always overrule a REVOKE!

If you want to deny access to all tables from this database you don’t need to create your own db role, then you could simply assign the db role “db_denydatareader”:

USE [Navision]
GO
EXEC sp_addrolemember N’db_denydatareader’, N’UserXYZ’
GO

Again, these roles are only effective if the user is accessing without NAV - with NAV always an “application role” will be used which overrules the “database roles”.

Hope this suits your requirements.

Regards,
Jörg

P.S.: uh, I forgot: if you go for the “db_denydatareader” thing you might do the same with “db_denydatawriter”, of course …

Thank you very much to both of you, the second method suggested by Jörg is what I wanted to use in the first place, so I think I’ll go for that, but the explanations where really useful…

Thanks!