Showing posts with label permissions. Show all posts
Showing posts with label permissions. Show all posts

Monday, March 26, 2012

Permissions...

I have been looking for an example of applying permissions to all the
tables, view, stored procs, etc., in X sql database without much luck.
Clearly, it's simple to do for a single record but I have over 500 tables,
views, etc., that need to have permissions assigned for SELECT, INSERT,
UPDATE and DELETE for the tables (EXECUTE for the stored procs).
The must be an example that I am missing that allows me to assign all these
permissions quickly, we have a tool within our application but since I have
no permission currently set I cannot even get to that tool to run it.
Thanks again - I always get assistance from users here! It's the best part
about moving our app from VFP data to SQL data.
Chrisyou can put users in db_datareader and db_datawriter roles to get select,
insert, delete and update permissions.
"Chris Marsh" <cmarsh@.synergy-intl.com> wrote in message
news:%23tnwBCWXFHA.2348@.TK2MSFTNGP14.phx.gbl...
>I have been looking for an example of applying permissions to all the
>tables, view, stored procs, etc., in X sql database without much luck.
>Clearly, it's simple to do for a single record but I have over 500 tables,
>views, etc., that need to have permissions assigned for SELECT, INSERT,
>UPDATE and DELETE for the tables (EXECUTE for the stored procs).
> The must be an example that I am missing that allows me to assign all
> these permissions quickly, we have a tool within our application but since
> I have no permission currently set I cannot even get to that tool to run
> it.
> Thanks again - I always get assistance from users here! It's the best
> part about moving our app from VFP data to SQL data.
> Chris
>|||Hi,
Use the database level fixed roles db_datareader and db_datawriter to
assign SELECT, UPDATE, INSERT, DELETE previlages for all
TABLES/VIEW. But for stored procedure Execution rights there is no roles
available. Only way is to give Execute previlages individually.
GRANT EXEC on Proc_name to Username
If you have numerous procs then write a small script to query the sysobjects
table for Xtype ='P' to get all the procedure names and use the above Grant
statement inside a cursor.
Thanks
Hari
Sql Server Mvp
"Chris Marsh" <cmarsh@.synergy-intl.com> wrote in message
news:%23tnwBCWXFHA.2348@.TK2MSFTNGP14.phx.gbl...
>I have been looking for an example of applying permissions to all the
>tables, view, stored procs, etc., in X sql database without much luck.
>Clearly, it's simple to do for a single record but I have over 500 tables,
>views, etc., that need to have permissions assigned for SELECT, INSERT,
>UPDATE and DELETE for the tables (EXECUTE for the stored procs).
> The must be an example that I am missing that allows me to assign all
> these permissions quickly, we have a tool within our application but since
> I have no permission currently set I cannot even get to that tool to run
> it.
> Thanks again - I always get assistance from users here! It's the best
> part about moving our app from VFP data to SQL data.
> Chris
>|||Thank you!!!!!
"Hari Pra" <hari_pra_k@.hotmail.com> wrote in message
news:exHE4XWXFHA.628@.tk2msftngp13.phx.gbl...
> Hi,
> Use the database level fixed roles db_datareader and db_datawriter to
> assign SELECT, UPDATE, INSERT, DELETE previlages for all
> TABLES/VIEW. But for stored procedure Execution rights there is no roles
> available. Only way is to give Execute previlages individually.
> GRANT EXEC on Proc_name to Username
> If you have numerous procs then write a small script to query the
> sysobjects table for Xtype ='P' to get all the procedure names and use the
> above Grant
> statement inside a cursor.
> Thanks
> Hari
> Sql Server Mvp
>
> "Chris Marsh" <cmarsh@.synergy-intl.com> wrote in message
> news:%23tnwBCWXFHA.2348@.TK2MSFTNGP14.phx.gbl...
>|||Thank you!!!!
"Richard Ding" <rding@.acadian-asset.com> wrote in message
news:eHa6nNWXFHA.2128@.TK2MSFTNGP14.phx.gbl...
> you can put users in db_datareader and db_datawriter roles to get select,
> insert, delete and update permissions.
>
> "Chris Marsh" <cmarsh@.synergy-intl.com> wrote in message
> news:%23tnwBCWXFHA.2348@.TK2MSFTNGP14.phx.gbl...
>sql

permissions..

How do I change permissions so I can access a linkedserver I create?If you created it you should already have permissions ??|||Permissions default to members of the sysadmin and setupadmin fixed server roles.

Permissions!

I am an absolute newbie as far as granting, revoking & denying
permissions to database objects are concerned. So please help me. I
went through BOL but couldn't understand many aspects.
This is what I want to do:
I have a SQL Server 7.0 database table which has 6 columns. I want that
only 3 users should be allowed to access this table. Out of these 3
users, the first user should be allowed to access the records of only
the first 2 columns, the second user should be allowed to access the
records of the next 2 columns only & the third user should be allowed
to access the records of the last 2 columns. How do I implement this?
Do I have to create new Users/Roles to implement this & then GRANT,
REVOKE or DENY permissions to these 3 users? Does 3 users mean I have
to create 3 new Users?
Now I access SQL Server from an ASP application using the following
ConnectionString:
objConn.Open
" Provider=SQLOLEDB;Server=(local);Databas
e=ARPAN;UID=sa;PWD="
When I open Query Analyzer & connect, the SQL Server drop-down menu
lists only 1 option which is 'ARPAN' (without the quotes). Under
'Connection Information', the 'Use SQL Server authentication' radio
button is checked & the Login Name is sa. The Password field is blank.
Please note that I login to my Windows 2000 Professional machine using
Administrator as the login name & a password.
This is what I did but failed:
I executed the following query in Query Analyzer:
DENY SELECT ON tblTry(FName,LName) TO dbo
but after that when I executed SELECT * FROM tblTry in QA, the records
under the columns named FName & LName were also retrieved along with
the records of the rest of the columns. Even opening the table tblTry
in Enterprise Manager displayed all the records under the columns FName
& LName along with the records of the rest of the columns! So what did
the DENY statement do?
I would be highly obliged if someone could please explain me the steps
required to do this in detail.
Thanks,
Arpan
> DENY SELECT ON tblTry(FName,LName) TO dbo
First, be aware that 'dbo' is a special user that has full permissions.
Database permissions are not checked for the 'dbo' user so it serves no
purpose to assign permissions to 'dbo'. Also, logins that are a member of
the sysadmin fixed server role map to the 'dbo' user in all databases so
permissions are not checked in any database for sysadmin role members.

> objConn.Open
> " Provider=SQLOLEDB;Server=(local);Databas
e=ARPAN;UID=sa;PWD="
Never use the 'sa' login for routine application access and assign a strong
password to this login. A blank 'sa' password is a very bad thing.

> I have a SQL Server 7.0 database table which has 6 columns. I want that
> only 3 users should be allowed to access this table. Out of these 3
> users, the first user should be allowed to access the records of only
> the first 2 columns, the second user should be allowed to access the
> records of the next 2 columns only & the third user should be allowed
> to access the records of the last 2 columns. How do I implement this?
> Do I have to create new Users/Roles to implement this & then GRANT,
> REVOKE or DENY permissions to these 3 users? Does 3 users mean I have
> to create 3 new Users?
You will need individual logins/users so that SQL Server can identify users
properly and check user permissions. These may be either standard SQL
logins or Windows accounts. For SQL authentication, specify the
individual's login and password in your connection string. For Windows
auth, specify 'Integrated Security=SSPI' instead of the login and password.
It's not required to use database roles to manage security but it's
generally recommended because it simplifies security administration. With
roles, you can setup security once and then control access through role
membership.
Although column permissions can be used to control column data visibility,
you might find it easier to create views and grant permissions on views
rather than to the underlying table. This technique allows you to control
data access both vertically (columns) and horizontally (Rows). Below is a
script that illustrates how you can implement this with both SQL and Windows
authentication. See The Books Online for details and examples.
USE MyDatabase
GO
CREATE TABLE dbo.tblTry
(
FName varchar(30),
LName varchar(30),
Col3 int,
Col4 int,
Col5 int,
Col6 int
)
GO
CREATE VIEW dbo.View1 AS
SELECT FName, LName FROM dbo.tblTry
GO
CREATE VIEW dbo.View2 AS
SELECT Col3, Col4 FROM dbo.tblTry
GO
CREATE VIEW dbo.View3 AS
SELECT Col5, Col6 FROM dbo.tblTry
GO
--setup security
EXEC sp_addrole 'Role1'
EXEC sp_addrole 'Role2'
EXEC sp_addrole 'Role3'
GO
GRANT SELECT ON View1 TO Role1
GRANT SELECT ON View2 TO Role2
GRANT SELECT ON View3 TO Role3
GO
--setup access (SQL authentication)
EXEC sp_addlogin 'User1', 'User1Password'
EXEC sp_addlogin 'User2', 'User2Password'
EXEC sp_addlogin 'User3', 'User2Password'
EXEC sp_grantdbaccess 'User1'
EXEC sp_grantdbaccess 'User2'
EXEC sp_grantdbaccess 'User3'
EXEC sp_addrolemember 'Role1', 'User1'
EXEC sp_addrolemember 'Role2', 'User2'
EXEC sp_addrolemember 'Role3', 'User3'
GO
--setup access (Windows authentication)
EXEC sp_grantlogin 'MyDomain\User1'
EXEC sp_grantlogin 'MyDomain\User2'
EXEC sp_grantlogin 'MyDomain\User3'
EXEC sp_grantdbaccess 'MyDomain\User1'
EXEC sp_grantdbaccess 'MyDomain\User2'
EXEC sp_grantdbaccess 'MyDomain\User3'
EXEC sp_addrolemember 'Role1', 'User1'
EXEC sp_addrolemember 'Role2', 'User2'
EXEC sp_addrolemember 'Role3', 'User3'
GO
Hope this helps.
Dan Guzman
SQL Server MVP
"Arpan" <arpan_de@.hotmail.com> wrote in message
news:1125803777.338446.195820@.g44g2000cwa.googlegroups.com...
>I am an absolute newbie as far as granting, revoking & denying
> permissions to database objects are concerned. So please help me. I
> went through BOL but couldn't understand many aspects.
> This is what I want to do:
> I have a SQL Server 7.0 database table which has 6 columns. I want that
> only 3 users should be allowed to access this table. Out of these 3
> users, the first user should be allowed to access the records of only
> the first 2 columns, the second user should be allowed to access the
> records of the next 2 columns only & the third user should be allowed
> to access the records of the last 2 columns. How do I implement this?
> Do I have to create new Users/Roles to implement this & then GRANT,
> REVOKE or DENY permissions to these 3 users? Does 3 users mean I have
> to create 3 new Users?
> Now I access SQL Server from an ASP application using the following
> ConnectionString:
> objConn.Open
> " Provider=SQLOLEDB;Server=(local);Databas
e=ARPAN;UID=sa;PWD="
> When I open Query Analyzer & connect, the SQL Server drop-down menu
> lists only 1 option which is 'ARPAN' (without the quotes). Under
> 'Connection Information', the 'Use SQL Server authentication' radio
> button is checked & the Login Name is sa. The Password field is blank.
> Please note that I login to my Windows 2000 Professional machine using
> Administrator as the login name & a password.
> This is what I did but failed:
> I executed the following query in Query Analyzer:
> DENY SELECT ON tblTry(FName,LName) TO dbo
> but after that when I executed SELECT * FROM tblTry in QA, the records
> under the columns named FName & LName were also retrieved along with
> the records of the rest of the columns. Even opening the table tblTry
> in Enterprise Manager displayed all the records under the columns FName
> & LName along with the records of the rest of the columns! So what did
> the DENY statement do?
> I would be highly obliged if someone could please explain me the steps
> required to do this in detail.
> Thanks,
> Arpan
>|||Thank you very very very very very much, Dan, for your help. I am now
able to do what I wanted to do. I really appreciate the effort you have
put in to enlighten me on the "Permissions" issue. You have indeed
given me quite a detailed explanation.
Yeah, you are correct......using 'sa' & a blank password does
compromise on security. Henceforth I will ensure that I don't repeat
this again.
You have suggested using 'Integrated Security=SSPI' instead of login &
password for Windows authorization. Can you please show me what should
the ConnectionString look like in that case?
Lastly I have been told by a SQL expert that it is not possible to
assign column permissions in SQL Server to control column data
visibility but you are saying otherwise. Can you please give me some
idea on how to go about it or maybe suggest a few sites which deals
with assigning column permissions?
Thanks once again for your help.
Regards,
Arpan|||> You have suggested using 'Integrated Security=SSPI' instead of login &
> password for Windows authorization. Can you please show me what should
> the ConnectionString look like in that case?
"Provider=SQLOLEDB;Data Source=(local);Initial Catalog=ARPAN;Integrated
Security=SSPI"

> Lastly I have been told by a SQL expert that it is not possible to
> assign column permissions in SQL Server to control column data
> visibility but you are saying otherwise. Can you please give me some
> idea on how to go about it or maybe suggest a few sites which deals
> with assigning column permissions?
You can control access to specific columns using column permissions but this
doesn't control visibility. For example, 'SELECT *' will fail if the user
doesn't have SELECT permissions on all table columns. A column list needs
to be specified for those columns the user has permissions to access.
IMHO, views are better for controlling access to specific columns since this
allows columns to be made invisible. This technique is described on the
Books Online under 'Using Views as Security Mechanisms'
<adminsql.chm::/ad_security_5whf.htm>.
Hope this helps.
Dan Guzman
SQL Server MVP
"Arpan" <arpan_de@.hotmail.com> wrote in message
news:1125937401.336692.78350@.f14g2000cwb.googlegroups.com...
> Thank you very very very very very much, Dan, for your help. I am now
> able to do what I wanted to do. I really appreciate the effort you have
> put in to enlighten me on the "Permissions" issue. You have indeed
> given me quite a detailed explanation.
> Yeah, you are correct......using 'sa' & a blank password does
> compromise on security. Henceforth I will ensure that I don't repeat
> this again.
> You have suggested using 'Integrated Security=SSPI' instead of login &
> password for Windows authorization. Can you please show me what should
> the ConnectionString look like in that case?
> Lastly I have been told by a SQL expert that it is not possible to
> assign column permissions in SQL Server to control column data
> visibility but you are saying otherwise. Can you please give me some
> idea on how to go about it or maybe suggest a few sites which deals
> with assigning column permissions?
> Thanks once again for your help.
> Regards,
> Arpan
>|||Your suggestions have indeed been very helpful, Dan. Thanks for the
same.
I tried using the ConnectionString you have cited in an ASP application
but it throws the following error:
---
Login failed for user 'ARPAN\IUSR_ARPAN'.
---
Why this error?
There's another question I would like to ask you regarding Permissions
in SQL Server. After executing the queries you had provided, I am now
able to restrict users' access to the different columns but any user
can access the different views & play with the records by viewing the
records in Enterprise Manager. Is there any way to overcome this?
BTW, what is IMHO?
Thanks once again,
Regards,
Arpan|||Sorry Dan....forgot to ask another question.
Assume that instead of 3 users, there are, say, 100 users. Does that
mean that 100 views have to be created - one for each user? If yes,
then this means that the ASP application that will be accessing the
columns must have 100 If...Else statements with the ConnectionString
having different UIDs & Passwords something like this (assuming that
each user has to enter a password in the ASP application first before
proceeding further):
---
Dim strPassword
strPassword=3DRequest.Form("pwd") 'collecting the password the user has
entered
If(strPassword=3D"pwd1") Then
" Provider=3DSQLOLEDB;Server=3D(local);Dat
abase=3DARPAN;UID=3Duid1;PWD=3Dpas=
s1=AD"
ElseIf(strPassword=3D"pwd2") Then
" Provider=3DSQLOLEDB;Server=3D(local);Dat
abase=3DARPAN;UID=3Duid2;PWD=3Dpas=
s2"
ElseIf(strPassword=3D"pwd3") Then
" Provider=3DSQLOLEDB;Server=3D(local);Dat
abase=3DARPAN;UID=3Duid3;PWD=3Dpas=
s3"
.=2E...........
.=2E...........
.=2E...........
End If
---
This will be a tedious & monotonous approach! Would you suggest some
other workaround to this?
Also the ConnectionString that uses 'Integrated Security=3DSSPI' doesn't
include any UserID & Password; so how will SQL Server know which user
is trying to access data & restrict data access accordingly?
Thanks once again,
Regards,
Arpan|||> Login failed for user 'ARPAN\IUSR_ARPAN'.
The 'ARPAN\IUSR_ARPAN' login referenced in the error message is the Windows
account used for anonymous access. This account is used because your web
application is configured for anonymous access instead of integrated
security. Is this an intranet app? The details on how to use Windows
authentication under the end user's security context depend on the version
of IIS and whether you are running AD. You can search for relevant MSDN
articles at http://msdn.microsoft.com/

> There's another question I would like to ask you regarding Permissions
> in SQL Server. After executing the queries you had provided, I am now
> able to restrict users' access to the different columns but any user
> can access the different views & play with the records by viewing the
> records in Enterprise Manager. Is there any way to overcome this?
Access to the data is limited to the permissions you have granted regardless
of the method used to access the data.
- user must have a valid SQL Login
- user must have been granted database access
- user must have permssions, direct or via role membership, on the objects

> BTW, what is IMHO?
http://www.answers.com/topic/imho
Hope this helps.
Dan Guzman
SQL Server MVP
"Arpan" <arpan_de@.hotmail.com> wrote in message
news:1125949593.398597.234660@.g44g2000cwa.googlegroups.com...
> Your suggestions have indeed been very helpful, Dan. Thanks for the
> same.
> I tried using the ConnectionString you have cited in an ASP application
> but it throws the following error:
> ---
> Login failed for user 'ARPAN\IUSR_ARPAN'.
> ---
> Why this error?
> There's another question I would like to ask you regarding Permissions
> in SQL Server. After executing the queries you had provided, I am now
> able to restrict users' access to the different columns but any user
> can access the different views & play with the records by viewing the
> records in Enterprise Manager. Is there any way to overcome this?
> BTW, what is IMHO?
> Thanks once again,
> Regards,
> Arpan
>|||It seems you want to display different data based on the password the user
entered. In this case, you can connect using a common login (unknown to the
end user). You can then either build SQL differently depending on the
password or render data differently depending on the password. You only
need to grant SQL permissions to the application login and users won't be
able to access the data outside your application.
Hope this helps.
Dan Guzman
SQL Server MVP
"Arpan" <arpan_de@.hotmail.com> wrote in message
news:1125952217.382925.241690@.g14g2000cwa.googlegroups.com...
Sorry Dan....forgot to ask another question.
Assume that instead of 3 users, there are, say, 100 users. Does that
mean that 100 views have to be created - one for each user? If yes,
then this means that the ASP application that will be accessing the
columns must have 100 If...Else statements with the ConnectionString
having different UIDs & Passwords something like this (assuming that
each user has to enter a password in the ASP application first before
proceeding further):
---
Dim strPassword
strPassword=Request.Form("pwd") 'collecting the password the user has
entered
If(strPassword="pwd1") Then
" Provider=SQLOLEDB;Server=(local);Databas
e=ARPAN;UID=uid1;PWD=pass1_"
ElseIf(strPassword="pwd2") Then
" Provider=SQLOLEDB;Server=(local);Databas
e=ARPAN;UID=uid2;PWD=pass2"
ElseIf(strPassword="pwd3") Then
" Provider=SQLOLEDB;Server=(local);Databas
e=ARPAN;UID=uid3;PWD=pass3"
............
............
............
End If
---
This will be a tedious & monotonous approach! Would you suggest some
other workaround to this?
Also the ConnectionString that uses 'Integrated Security=SSPI' doesn't
include any UserID & Password; so how will SQL Server know which user
is trying to access data & restrict data access accordingly?
Thanks once again,
Regards,
Arpan|||Yes Dan you are absolutely correct....I want to display different data
depending upon the password the user entered. You have suggested either
building SQL differently depending on the password or rendering data
differently depending on the password. Now if I am not mistaken, this
means that the ASP application must have 100 If....Else statements for
100 users & that is exactly what I want a workaround for. Please
correct me if I have misinterpreted your advice.
I believe citing an example as what you have done earlier would be
highly beneficial.
Sorry for all the trouble I am giving you.
Thanks once again for the co-operation you have extended towards me,
Regards,
Arpan|||> Now if I am not mistaken, this
> means that the ASP application must have 100 If....Else statements for
> 100 users & that is exactly what I want a workaround for.
Rather than hard-code the list in your app, a better approach would be to
store this data externally and then build the appropriate SQL statement
depending on the user's identity. The simplistic example below shows how
one could store this user configuration data in SQL Server.
CREATE TABLE Users
(
UserId varchar(30) NOT NULL
CONSTRAINT PK_Users PRIMARY KEY,
Password varchar(30) NOT NULL
)
INSERT INTO Users VALUES('User1', 'Passwrd1')
INSERT INTO Users VALUES('User2', 'Passwrd2')
INSERT INTO Users VALUES('User3', 'Passwrd3')
CREATE TABLE UserViews
(
UserId varchar(30) NOT NULL,
TableName sysname NOT NULL,
SqlStatement varchar(4000),
CONSTRAINT PK_UserViews
PRIMARY KEY(UserId, TableName),
CONSTRAINT FK_UserViews_Users
FOREIGN KEY(UserId)
REFERENCES Users(UserId)
)
INSERT INTO UserViews VALUES('User1', 'Table1', 'SELECT Col1, Col2 FROM
Table1')
INSERT INTO UserViews VALUES('User2', 'Table1', 'SELECT Col3, Col4 FROM
Table1')
INSERT INTO UserViews VALUES('User3', 'Table1', 'SELECT Col5, Col6 FROM
Table1')
GO
Your application can then retrieve the desired SQL Statement based on the
current user identity and then execute query:
SELECT SqlStatement FROM UserViews WHERE UserId = ? AND TableName = ?
Note that you don't need different SQL logins with this method, assuming
individual users access SQL Server only from your application.
Hope this helps.
Dan Guzman
SQL Server MVP
"Arpan" <arpan_de@.hotmail.com> wrote in message
news:1126046628.322404.42890@.g44g2000cwa.googlegroups.com...
> Yes Dan you are absolutely correct....I want to display different data
> depending upon the password the user entered. You have suggested either
> building SQL differently depending on the password or rendering data
> differently depending on the password. Now if I am not mistaken, this
> means that the ASP application must have 100 If....Else statements for
> 100 users & that is exactly what I want a workaround for. Please
> correct me if I have misinterpreted your advice.
> I believe citing an example as what you have done earlier would be
> highly beneficial.
> Sorry for all the trouble I am giving you.
> Thanks once again for the co-operation you have extended towards me,
> Regards,
> Arpan
>

permissions xp_cmdshell

Hi!!!
which permissions are necessary to execute xp_cmdshell?
-->without being SA
Error:
Msg 50001, Level 1, State 50001
xpsql.cpp: Error 87 from GetProxyAccount on line 604
tanks!!!You will need to set up a proxy account first using
"xp_sqlagent_proxy_account". Then you should get the permission associated
with the account you "set" up as your proxy account.
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Joao Mossmann" <mossmann@.feevale.br> wrote in message
news:%234YPh1rLEHA.1556@.TK2MSFTNGP10.phx.gbl...
> Hi!!!
> which permissions are necessary to execute xp_cmdshell?
> -->without being SA
> Error:
> Msg 50001, Level 1, State 50001
> xpsql.cpp: Error 87 from GetProxyAccount on line 604
>
> tanks!!!
>
>|||Heres what Ive done in SQL 2000. RClick the SQL Agent/ props/ job system/
uncheck Only users with SA bla bla.../ fill in appropriate credentials. Most
imprtantly, DO NOT set permissions on xp_cmdshell itself.
"Joao Mossmann" <mossmann@.feevale.br> wrote in message
news:%234YPh1rLEHA.1556@.TK2MSFTNGP10.phx.gbl...
> Hi!!!
> which permissions are necessary to execute xp_cmdshell?
> -->without being SA
> Error:
> Msg 50001, Level 1, State 50001
> xpsql.cpp: Error 87 from GetProxyAccount on line 604
>
> tanks!!!
>
>

permissions xp_cmdshell

Hi!!!
which permissions are necessary to execute xp_cmdshell?
-->without being SA
Error:
Msg 50001, Level 1, State 50001
xpsql.cpp: Error 87 from GetProxyAccount on line 604
tanks!!!
You will need to set up a proxy account first using
"xp_sqlagent_proxy_account". Then you should get the permission associated
with the account you "set" up as your proxy account.
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Joao Mossmann" <mossmann@.feevale.br> wrote in message
news:%234YPh1rLEHA.1556@.TK2MSFTNGP10.phx.gbl...
> Hi!!!
> which permissions are necessary to execute xp_cmdshell?
> -->without being SA
> Error:
> Msg 50001, Level 1, State 50001
> xpsql.cpp: Error 87 from GetProxyAccount on line 604
>
> tanks!!!
>
>
|||Heres what Ive done in SQL 2000. RClick the SQL Agent/ props/ job system/
uncheck Only users with SA bla bla.../ fill in appropriate credentials. Most
imprtantly, DO NOT set permissions on xp_cmdshell itself.
"Joao Mossmann" <mossmann@.feevale.br> wrote in message
news:%234YPh1rLEHA.1556@.TK2MSFTNGP10.phx.gbl...
> Hi!!!
> which permissions are necessary to execute xp_cmdshell?
> -->without being SA
> Error:
> Msg 50001, Level 1, State 50001
> xpsql.cpp: Error 87 from GetProxyAccount on line 604
>
> tanks!!!
>
>

permissions xp_cmdshell

Hi!!!
which permissions are necessary to execute xp_cmdshell?
-->without being SA
Error:
Msg 50001, Level 1, State 50001
xpsql.cpp: Error 87 from GetProxyAccount on line 604
tanks!!!You will need to set up a proxy account first using
"xp_sqlagent_proxy_account". Then you should get the permission associated
with the account you "set" up as your proxy account.
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"Joao Mossmann" <mossmann@.feevale.br> wrote in message
news:%234YPh1rLEHA.1556@.TK2MSFTNGP10.phx.gbl...
> Hi!!!
> which permissions are necessary to execute xp_cmdshell?
> -->without being SA
> Error:
> Msg 50001, Level 1, State 50001
> xpsql.cpp: Error 87 from GetProxyAccount on line 604
>
> tanks!!!
>
>|||Heres what Ive done in SQL 2000. RClick the SQL Agent/ props/ job system/
uncheck Only users with SA bla bla.../ fill in appropriate credentials. Most
imprtantly, DO NOT set permissions on xp_cmdshell itself.
"Joao Mossmann" <mossmann@.feevale.br> wrote in message
news:%234YPh1rLEHA.1556@.TK2MSFTNGP10.phx.gbl...
> Hi!!!
> which permissions are necessary to execute xp_cmdshell?
> -->without being SA
> Error:
> Msg 50001, Level 1, State 50001
> xpsql.cpp: Error 87 from GetProxyAccount on line 604
>
> tanks!!!
>
>sql

Permissions WTF

I have a intigrated log using a local group
the login does not have explicit access to any db's and no server roles
when i log on with query analyzer i can access any data (even though not a
server admin or anything else)
when i remove login...can log (as it should be)
why does this login have full access to all db's ?When i add the login and run IS_MEMBER and USER it says i am dbo of a user
database that i did not give access to what is going on ?
"David J. Cartwright" <davidcartwright@.hotmail.com> wrote in message
news:uNI5pih6FHA.3684@.TK2MSFTNGP12.phx.gbl...
>I have a intigrated log using a local group
> the login does not have explicit access to any db's and no server roles
> when i log on with query analyzer i can access any data (even though not a
> server admin or anything else)
> when i remove login...can log (as it should be)
> why does this login have full access to all db's ?
>|||You are getting in with sysadmin priviliges, possibly by membership of
another group. What does the following query return for your windows
account?
exec master..xp_logininfo 'DOMAIN\username'
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"David J. Cartwright" <davidcartwright@.hotmail.com> wrote in message
news:uNI5pih6FHA.3684@.TK2MSFTNGP12.phx.gbl...
>I have a intigrated log using a local group
> the login does not have explicit access to any db's and no server roles
> when i log on with query analyzer i can access any data (even though not a
> server admin or anything else)
> when i remove login...can log (as it should be)
> why does this login have full access to all db's ?
>|||Thanks for reply, but it was my stupidity...i had been logged in as the
user when i had created the user databases...then forgot it was a member of
the group used to create the login....should have realized it when it said
i was member of db_owner and not srv role sysadmin...but i am getting slow
at my old age.
"Jasper Smith" <jasper_smith9@.hotmail.com> wrote in message
news:upEiioj6FHA.476@.TK2MSFTNGP15.phx.gbl...
> You are getting in with sysadmin priviliges, possibly by membership of
> another group. What does the following query return for your windows
> account?
> exec master..xp_logininfo 'DOMAIN\username'
> --
> HTH
> Jasper Smith (SQL Server MVP)
> http://www.sqldbatips.com
> I support PASS - the definitive, global
> community for SQL Server professionals -
> http://www.sqlpass.org
> "David J. Cartwright" <davidcartwright@.hotmail.com> wrote in message
> news:uNI5pih6FHA.3684@.TK2MSFTNGP12.phx.gbl...
>

Permissions within groups

Running SQL Server 2000 under Windows 2003 server. All
updates and service packs applied. Using Windows
Authentication via group membership. No individual users
are defined in SQL Server. Some users can update tables,
while other users in the same group cannot (permission
denied).
I'm baffled...These people are probably members of another group that has been denied
those rights. Remember that permissions are cumulative except that deny
trumps...
"Jay Varner" <dimsjay@.dims-vote.com> wrote in message
news:e55901c3f0e8$da00f2c0$a301280a@.phx.gbl...
> Running SQL Server 2000 under Windows 2003 server. All
> updates and service packs applied. Using Windows
> Authentication via group membership. No individual users
> are defined in SQL Server. Some users can update tables,
> while other users in the same group cannot (permission
> denied).
> I'm baffled...|||Try comparing users that can update vs those that can't using gpresult.
321709 HOW TO: Use the Group Policy Results Tool in Windows 2000
http://support.microsoft.com/?id=321709
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||I appreciate your quick reply, Don, but am not sure I expressed the
problem sufficiently.
Using Active Directory in W2K3 server, we defined specific user groups
for each of three domains that need to access the database. Each user
appears in only one group. All of these groups have been added to SQL
Server, and all have the same rights to the database(s). The problem
seems to occur for several people in each group, and does not seem to be
related to any permissions they are allowed on the domain. For
instance, in one of the groups, one user is a standard DOMAIN USER in
Windows, and he is able to perform updates to any of the tables in the
database; another user is a DOMAIN ADMIN who belongs to the same group,
but he is denied access to perform updates.
If we assign the group SYSTEM ADMINISTRATOR priveleges on the database,
it seems to resolve the problem, but thats not an acceptable resolution
for this large office.
If we assign each individual user (rather than the groups) to SQL, the
problem goes away. Again, this is a large office, and they would like
to avoid the additional overhead of having to add each new user to both
Windows and SQL Server.
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Permissions with Windows groups and view to other databases

I am having a problem with permissions using Windows groups. I have a database (database1) that has permissions granted via Windows groups. Two groups (group1 and group2) are members of the db_datareader role in database1, and this work fine. Do to the number of tables that get created during our work, using db_datareader is the easiest way to keep up with permissions without creating a maintenance problem. Now I have a table that I want to add to this database, but I only want group2 to have select permission on this one table which is a problem because group1 has the db_datareader role. So I thought I could create a view in this database to the restricted table that I put in database2. Then in database2 I only added group2 as a user with the permission to select from this table. Unfortunately the group membership does not seem to get interpretted correctly in database2 and no one can successfult select from the view in database1.

In other words, user1 who belongs to group1 connects to database1 and cannot select from the restricted view -- this is what I would expect. However, when user2 who belongs to group2 connects to database1 they also cannot select from the restricted view -- not the behvior I would expect. Now, if I make user2 a user in database2 with select on the restricted table then user2 can connect to database1 and successfuly get data from the restricted view. So it looks like the fact that user2 belongs to group2 is never passed to database2 via the select from the view on database1. Is this indeed the way that Windows group security is working or is meant to work in SQL Server?

I realize I could solve this simplified version of the problem by creating my own role in database1 for group1 etc., but I am trying to solve a bigger problem in our environment that has hundreds of databases across numerous servers.

Thanks

Rob

Why not simply deny SELECT permission to group1 for that particular table? The rule that you need to remember is that a deny will trump a grant, so the deny will take precedence over the db_datareader membership.

Thanks

Laurentiu

|||Well, that won't quite work. The two Windows groups we are talking about have some overlapping members, but one group is not a complete subset of the other. So if I deny SELECT to group1 then some people that I want to access the data (group2) because they are in both groups and as you point out deny has a higher priority. Is there any reason group permissions are not valid in database2 when selecting from the view in database1?|||

This is the expected behavior; but it sounds like you may be trying to attempt cross-database ownership chaining (also known as CDOC, look for “Using ownership chains” topic in BOL). CDOC is a feature that is disabled by default and we recommend against using it because of the security risks inherent from this feature. For more information on CDOC look for “Using ownership chains” topic in BOL.

The reason why user2 is failing to access the table is that there is a separate user token for database1 and database2 (both derived from the same Windows login token). On database1 the user2 token will look similar to this:

Primary identity:

· user2, Windows user

Secondary identities:

· group2, Windows group

· db_datareader, role

When accessing the view, the permissions are checked against this token, and they will succeed, but the view is making reference to database2.<some_schema>.restricted_table, therefore it is necessary to create a token for database2.

On your first attempt (without creating a user in Database2, and granting permission to access the table) the user token creation process for database2 should have failed with a “user cannot access this database”-type of error.

Here are a few potential workarounds that may help you:

Instead of using db_datareader you can use different schemas and grant SELECT based on the schemas to differentiate groups, for example:

GRANT SELECT ON SCHEMA::[Schema_group1] TO group1

GRANT SELECT ON SCHEMA::[Schema_group2] TO group2

GRANT SELECT ON SCHEMA::[Schema_all] TO group1, group2

That way the SELECT permission would be restricted to only the schemas you defined.

Another alternative for cross-DB access could be using signatures, similar to the one I described in the following article: http://blogs.msdn.com/raulga/archive/2006/10/30/using-a-digital-signature-as-a-secondary-identity-to-replace-cross-database-ownership-chaining.aspx

Please, let us know if any of this alternatives worked for you or if you have any additional questions.

Thanks a lot,

-Raul Garcia

SDE/T

SQL Server Engine

Permissions with Windows groups and view to other databases

I am having a problem with permissions using Windows groups. I have a database (database1) that has permissions granted via Windows groups. Two groups (group1 and group2) are members of the db_datareader role in database1, and this work fine. Do to the number of tables that get created during our work, using db_datareader is the easiest way to keep up with permissions without creating a maintenance problem. Now I have a table that I want to add to this database, but I only want group2 to have select permission on this one table which is a problem because group1 has the db_datareader role. So I thought I could create a view in this database to the restricted table that I put in database2. Then in database2 I only added group2 as a user with the permission to select from this table. Unfortunately the group membership does not seem to get interpretted correctly in database2 and no one can successfult select from the view in database1.

In other words, user1 who belongs to group1 connects to database1 and cannot select from the restricted view -- this is what I would expect. However, when user2 who belongs to group2 connects to database1 they also cannot select from the restricted view -- not the behvior I would expect. Now, if I make user2 a user in database2 with select on the restricted table then user2 can connect to database1 and successfuly get data from the restricted view. So it looks like the fact that user2 belongs to group2 is never passed to database2 via the select from the view on database1. Is this indeed the way that Windows group security is working or is meant to work in SQL Server?

I realize I could solve this simplified version of the problem by creating my own role in database1 for group1 etc., but I am trying to solve a bigger problem in our environment that has hundreds of databases across numerous servers.

Thanks

Rob

Why not simply deny SELECT permission to group1 for that particular table? The rule that you need to remember is that a deny will trump a grant, so the deny will take precedence over the db_datareader membership.

Thanks

Laurentiu

|||Well, that won't quite work. The two Windows groups we are talking about have some overlapping members, but one group is not a complete subset of the other. So if I deny SELECT to group1 then some people that I want to access the data (group2) because they are in both groups and as you point out deny has a higher priority. Is there any reason group permissions are not valid in database2 when selecting from the view in database1?|||

This is the expected behavior; but it sounds like you may be trying to attempt cross-database ownership chaining (also known as CDOC, look for “Using ownership chains” topic in BOL). CDOC is a feature that is disabled by default and we recommend against using it because of the security risks inherent from this feature. For more information on CDOC look for “Using ownership chains” topic in BOL.

The reason why user2 is failing to access the table is that there is a separate user token for database1 and database2 (both derived from the same Windows login token). On database1 the user2 token will look similar to this:

Primary identity:

· user2, Windows user

Secondary identities:

· group2, Windows group

· db_datareader, role

When accessing the view, the permissions are checked against this token, and they will succeed, but the view is making reference to database2.<some_schema>.restricted_table, therefore it is necessary to create a token for database2.

On your first attempt (without creating a user in Database2, and granting permission to access the table) the user token creation process for database2 should have failed with a “user cannot access this database”-type of error.

Here are a few potential workarounds that may help you:

Instead of using db_datareader you can use different schemas and grant SELECT based on the schemas to differentiate groups, for example:

GRANT SELECT ON SCHEMA::[Schema_group1] TO group1

GRANT SELECT ON SCHEMA::[Schema_group2] TO group2

GRANT SELECT ON SCHEMA::[Schema_all] TO group1, group2

That way the SELECT permission would be restricted to only the schemas you defined.

Another alternative for cross-DB access could be using signatures, similar to the one I described in the following article: http://blogs.msdn.com/raulga/archive/2006/10/30/using-a-digital-signature-as-a-secondary-identity-to-replace-cross-database-ownership-chaining.aspx

Please, let us know if any of this alternatives worked for you or if you have any additional questions.

Thanks a lot,

-Raul Garcia

SDE/T

SQL Server Engine

Permissions with views and tables

We are attempting to implement security on top of a shrink-wrapped software
package and are trying to get row-level security. Here's the scenario:

1. Table dbo.BOOK contains all the information about books in every
department.
2. There are a large number of developed reports that run queries like
"select * from BOOK..."
3. We wish to have each Department only be able to see their books - without
changing the existing reports.

Our thought was to create a series of views:

create view Dept1.BOOK as
select * from BOOK where Dept=1

...

and then create Roles for each Dept. We'd then remove rights to dbo.BOOK
and grant rights to DeptN.BOOK as appropriate for each role. We started
testing this and seemed to get it working, but are now having problems. Is
this possible? Is there another, better solution?

Thanks!Anon (anon email) writes:
> We are attempting to implement security on top of a shrink-wrapped
> software package and are trying to get row-level security. Here's the
> scenario:
> 1. Table dbo.BOOK contains all the information about books in every
> department.
> 2. There are a large number of developed reports that run queries like
> "select * from BOOK..."
> 3. We wish to have each Department only be able to see their books -
> without changing the existing reports.
> Our thought was to create a series of views:
> create view Dept1.BOOK as
> select * from BOOK where Dept=1
> ...
> and then create Roles for each Dept. We'd then remove rights to
> dbo.BOOK and grant rights to DeptN.BOOK as appropriate for each role.
> We started testing this and seemed to get it working, but are now having
> problems. Is this possible? Is there another, better solution?

And the problems you get are?

Whther this will work a lot, depends on your shrink-wrap. After all,
you are doing something for which it is not prepared. Updates would
fail, but you could have INSTEAD OF triggers to cate for that.

In the view definition, I would recommend that you say dbo.BOOK for
clarity.

You should also beware of that this sort of row-level security is not
fool-proof. It is possible to dig out information about data you don't
have access to. Then again, it's not trivial and it does require
expert skills to do it.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Sorry, I didn't clarify the view; it is created using "select * from
dbo.BOOK". However, when a user with rights to Dept1.BOOK but not to
dbo.BOOK attempts to run the query they get an error that states

Server: Msg 229, Level 14, State 5, Line 1
SELECT permission denied on object 'BOOK', database 'LIBRARY', owner 'dbo'.

What we'd like to see is the explicit rights on the View supercede the
rights on the table, but that doesn't seem to be the case.

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9662F1EE69756Yazorman@.127.0.0.1...
> Anon (anon email) writes:
>> We are attempting to implement security on top of a shrink-wrapped
>> software package and are trying to get row-level security. Here's the
>> scenario:
>>
>> 1. Table dbo.BOOK contains all the information about books in every
>> department.
>> 2. There are a large number of developed reports that run queries like
>> "select * from BOOK..."
>> 3. We wish to have each Department only be able to see their books -
>> without changing the existing reports.
>>
>> Our thought was to create a series of views:
>>
>> create view Dept1.BOOK as
>> select * from BOOK where Dept=1
>>
>> ...
>>
>> and then create Roles for each Dept. We'd then remove rights to
>> dbo.BOOK and grant rights to DeptN.BOOK as appropriate for each role.
>> We started testing this and seemed to get it working, but are now having
>> problems. Is this possible? Is there another, better solution?
> And the problems you get are?
> Whther this will work a lot, depends on your shrink-wrap. After all,
> you are doing something for which it is not prepared. Updates would
> fail, but you could have INSTEAD OF triggers to cate for that.
> In the view definition, I would recommend that you say dbo.BOOK for
> clarity.
> You should also beware of that this sort of row-level security is not
> fool-proof. It is possible to dig out information about data you don't
> have access to. Then again, it's not trivial and it does require
> expert skills to do it.
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Anon (anon email) writes:
> Sorry, I didn't clarify the view; it is created using "select * from
> dbo.BOOK". However, when a user with rights to Dept1.BOOK but not to
> dbo.BOOK attempts to run the query they get an error that states
> Server: Msg 229, Level 14, State 5, Line 1
> SELECT permission denied on object 'BOOK', database 'LIBRARY', owner
> 'dbo'.
> What we'd like to see is the explicit rights on the View supercede the
> rights on the table, but that doesn't seem to be the case.

I will have to admit that if you granted Dept1 rights on dbo.Book, and
then the users rights to Dept1.book it would work, but nope. In fact
I even tried creating a stored procedure Dept1.book_sp and grant users
execute rights on that one, but that also failed. However, this latter
arrangeent actually works on SQL 6.5, so at least I did remember
correctly so far. (But Microsoft has changed the rules. Grr!)

Right now, I have to good ideas to get this to work in SQL 2000. In
SQL 2005, it would be another matter, because Dept1 would just be a
schema, that still could be owned by dbo.

Of course, you can create the view as dbo.Dept1books, but I don't
if that meets your ambition to fool the shrink-wrap package.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Unfortunately it seems our quick trial was on a 2005 server, and that
remains in Beta. Sigh. Does anyone have any other ideas on how to
accomplish this?

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9667F329E4C86Yazorman@.127.0.0.1...
> Anon (anon email) writes:
>> Sorry, I didn't clarify the view; it is created using "select * from
>> dbo.BOOK". However, when a user with rights to Dept1.BOOK but not to
>> dbo.BOOK attempts to run the query they get an error that states
>>
>> Server: Msg 229, Level 14, State 5, Line 1
>> SELECT permission denied on object 'BOOK', database 'LIBRARY', owner
>> 'dbo'.
>>
>> What we'd like to see is the explicit rights on the View supercede the
>> rights on the table, but that doesn't seem to be the case.
> I will have to admit that if you granted Dept1 rights on dbo.Book, and
> then the users rights to Dept1.book it would work, but nope. In fact
> I even tried creating a stored procedure Dept1.book_sp and grant users
> execute rights on that one, but that also failed. However, this latter
> arrangeent actually works on SQL 6.5, so at least I did remember
> correctly so far. (But Microsoft has changed the rules. Grr!)
> Right now, I have to good ideas to get this to work in SQL 2000. In
> SQL 2005, it would be another matter, because Dept1 would just be a
> schema, that still could be owned by dbo.
> Of course, you can create the view as dbo.Dept1books, but I don't
> if that meets your ambition to fool the shrink-wrap package.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Anon (anon email) writes:
> Unfortunately it seems our quick trial was on a 2005 server, and that
> remains in Beta. Sigh. Does anyone have any other ideas on how to
> accomplish this?

Maybe you could start to give the full presumptions for your case. You've
presented some scattered some information, from which I was able to make
some guesses. But it does help to know what exact degrees of freedom
you have with your shrink-wrap.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.aspsql

permissions with sql server tables and access

Hello,
I need some help with implenting the following:
I recently migrated from access to sql server and i now i want to use
maintainable permissions on my tables, views, etc. The access database will
serve as a front-end.
I've created for testing purposes an testaccount with only a public role to
access to my database.
Now the hard part is when i want users to select and manipulate the data
through views and stored procedures.I want only permissions set on views and
stored procedures. The reason for this is because i don't want users to get
the data directly from tables by means of linking or importing them to
access
or other databases. Only views and stored procedures can be used.
Unfortunelately it doesn't work how i wanted to. When i open a view which is
linked in access as a table, i'm getting a message that the underlying table
has not the appropiate permissions.
Now there should be a way to apply a maintainable security, so if i could
have some advice and maybe an example on this matter i would be very
thankful.Create the view with the WITH VIEW_METADATA option, which will allow
users to use the view to update data. Without it, permissions on the
base tables are required. See the CREATE VIEW topic in SQL BooksOnline
for more information. If you put a Profiler trace on the Access-SQLS
app, you can see the exact calls that are being made. This will help
you troubleshoot future issues.
--Mary
On Fri, 13 Aug 2004 20:19:28 +0200, "Ezekil" <ezekil@.lycios.nl>
wrote:

>Hello,
>I need some help with implenting the following:
>I recently migrated from access to sql server and i now i want to use
>maintainable permissions on my tables, views, etc. The access database will
>serve as a front-end.
>I've created for testing purposes an testaccount with only a public role to
>access to my database.
>Now the hard part is when i want users to select and manipulate the data
>through views and stored procedures.I want only permissions set on views an
d
>stored procedures. The reason for this is because i don't want users to get
>the data directly from tables by means of linking or importing them to
>access
>or other databases. Only views and stored procedures can be used.
>Unfortunelately it doesn't work how i wanted to. When i open a view which i
s
>linked in access as a table, i'm getting a message that the underlying tabl
e
>has not the appropiate permissions.
>Now there should be a way to apply a maintainable security, so if i could
>have some advice and maybe an example on this matter i would be very
>thankful.
>|||Do you have an example? BOL is not very clear to me.
"Mary Chipman" <mchip@.online.microsoft.com> wrote in message
news:k37sh0hnmit3dfkgj0hk7tn7pi8cdem6g9@.
4ax.com...
> Create the view with the WITH VIEW_METADATA option, which will allow
> users to use the view to update data. Without it, permissions on the
> base tables are required. See the CREATE VIEW topic in SQL BooksOnline
> for more information. If you put a Profiler trace on the Access-SQLS
> app, you can see the exact calls that are being made. This will help
> you troubleshoot future issues.
> --Mary
> On Fri, 13 Aug 2004 20:19:28 +0200, "Ezekil" <ezekil@.lycios.nl>
> wrote:
>
will[vbcol=seagreen]
to[vbcol=seagreen]
and[vbcol=seagreen]
get[vbcol=seagreen]
is[vbcol=seagreen]
table[vbcol=seagreen]
>|||You've asked this same question in comp.databases.ms-sqlserver. Please
don't post the same question independently to multiple groups as this causes
duplication of effort.
Here's the example I posted to that thread:
CREATE TABLE dbo.MyTable
(
Col1 int NOT NULL,
Col2 int NOT NULL
)
GO
CREATE VIEW dbo.MyView
WITH VIEW_METADATA
AS
SELECT Col1
FROM dbo.MyTable
GO
GRANT SELECT ON MyView TO MyRole
GO
Hope this helps.
Dan Guzman
SQL Server MVP

permissions with sql server tables

Hello,

I need some help with implenting the following:

I recently migrated from access to sql server and i now i want to use
maintainable permissions on my tables, views, etc. The access database will
serve as a front-end.

I've created for testing purposes an testaccount with only a public role to
access to my database.

Now the hard part is when i want users to select and manipulate the data
through views and stored procedures.I want only permissions set on views and
stored procedures. The reason for this is because i don't want users to get
the data directly from tables by means of linking or importing them to
access
or other databases. Only views and stored procedures can be used.

Unfortunelately it doesn't work how i wanted to. When i open a view which is
linked in access as a table, i'm getting a message that the underlying table
has not the appropiate permissions.

Now there should be a way to apply a maintainable security, so if i could
have some advice and maybe an example on this matter i would be very
thankful.Try creating the view with the VIEW_METADATA option. This way, Access will
use view meta data instead of meta data from the underlying base tables.
See CREATE VIEW in the Books Online for more information.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Ezekil" <ezekil@.lycos.com> wrote in message
news:411d05d7$0$195$cd19a363@.news.wanadoo.nl...
> Hello,
> I need some help with implenting the following:
> I recently migrated from access to sql server and i now i want to use
> maintainable permissions on my tables, views, etc. The access database
will
> serve as a front-end.
> I've created for testing purposes an testaccount with only a public role
to
> access to my database.
> Now the hard part is when i want users to select and manipulate the data
> through views and stored procedures.I want only permissions set on views
and
> stored procedures. The reason for this is because i don't want users to
get
> the data directly from tables by means of linking or importing them to
> access
> or other databases. Only views and stored procedures can be used.
> Unfortunelately it doesn't work how i wanted to. When i open a view which
is
> linked in access as a table, i'm getting a message that the underlying
table
> has not the appropiate permissions.
> Now there should be a way to apply a maintainable security, so if i could
> have some advice and maybe an example on this matter i would be very
> thankful.|||Hi Dan,

I've looked it up in BOL but it is not very clear. Could you provide me an
example?

Thnx
"Dan Guzman" <danguzman@.nospam-earthlink.net> wrote in message
news:wxfTc.20463$9Y6.12982@.newsread1.news.pas.eart hlink.net...
> Try creating the view with the VIEW_METADATA option. This way, Access
will
> use view meta data instead of meta data from the underlying base tables.
> See CREATE VIEW in the Books Online for more information.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Ezekil" <ezekil@.lycos.com> wrote in message
> news:411d05d7$0$195$cd19a363@.news.wanadoo.nl...
> > Hello,
> > I need some help with implenting the following:
> > I recently migrated from access to sql server and i now i want to use
> > maintainable permissions on my tables, views, etc. The access database
> will
> > serve as a front-end.
> > I've created for testing purposes an testaccount with only a public role
> to
> > access to my database.
> > Now the hard part is when i want users to select and manipulate the data
> > through views and stored procedures.I want only permissions set on views
> and
> > stored procedures. The reason for this is because i don't want users to
> get
> > the data directly from tables by means of linking or importing them to
> > access
> > or other databases. Only views and stored procedures can be used.
> > Unfortunelately it doesn't work how i wanted to. When i open a view
which
> is
> > linked in access as a table, i'm getting a message that the underlying
> table
> > has not the appropiate permissions.
> > Now there should be a way to apply a maintainable security, so if i
could
> > have some advice and maybe an example on this matter i would be very
> > thankful.|||Here's a simple example:

CREATE TABLE dbo.MyTable
(
Col1 int NOT NULL,
Col2 int NOT NULL
)
GO

CREATE VIEW dbo.MyView
WITH VIEW_METADATA
AS
SELECT Col1
FROM dbo.MyTable
GO

GRANT SELECT ON MyView TO MyRole
GO

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Ezekil" <ezekil@.lycos.com> wrote in message
news:411df325$0$80325$a344fe98@.news.wanadoo.nl...
> Hi Dan,
> I've looked it up in BOL but it is not very clear. Could you provide me
an
> example?
> Thnx
> "Dan Guzman" <danguzman@.nospam-earthlink.net> wrote in message
> news:wxfTc.20463$9Y6.12982@.newsread1.news.pas.eart hlink.net...
> > Try creating the view with the VIEW_METADATA option. This way, Access
> will
> > use view meta data instead of meta data from the underlying base tables.
> > See CREATE VIEW in the Books Online for more information.
> > --
> > Hope this helps.
> > Dan Guzman
> > SQL Server MVP
> > "Ezekil" <ezekil@.lycos.com> wrote in message
> > news:411d05d7$0$195$cd19a363@.news.wanadoo.nl...
> > > Hello,
> > > > I need some help with implenting the following:
> > > > I recently migrated from access to sql server and i now i want to use
> > > maintainable permissions on my tables, views, etc. The access database
> > will
> > > serve as a front-end.
> > > > I've created for testing purposes an testaccount with only a public
role
> > to
> > > access to my database.
> > > > Now the hard part is when i want users to select and manipulate the
data
> > > through views and stored procedures.I want only permissions set on
views
> > and
> > > stored procedures. The reason for this is because i don't want users
to
> > get
> > > the data directly from tables by means of linking or importing them to
> > > access
> > > or other databases. Only views and stored procedures can be used.
> > > > Unfortunelately it doesn't work how i wanted to. When i open a view
> which
> > is
> > > linked in access as a table, i'm getting a message that the underlying
> > table
> > > has not the appropiate permissions.
> > > > Now there should be a way to apply a maintainable security, so if i
> could
> > > have some advice and maybe an example on this matter i would be very
> > > thankful.
> >

Permissions with sp

Hi,
I programmed a Sp, which I gave permissions to some users to execute,
nevertheless, inside the code makes inserts and updates to tables where they
only have select permissions. So whenever they execute them a error message
is produced. How can i turnaround this. I want the sp to actually write in
some tables which they only have select permissions. Is there a solution.
Thanks
--
Carlos DiasHi,
Execute permission on the SP for that user should be fine to Insert or
Delete or Update.
GRANT EXEC ON SPNAME TO Username
Thanks
Hari
SQL Server MVP
"Carlos Dias" <CarlosDias@.discussions.microsoft.com> wrote in message
news:1801CAC0-5691-4146-B63C-7E2E99E87405@.microsoft.com...
> Hi,
> I programmed a Sp, which I gave permissions to some users to execute,
> nevertheless, inside the code makes inserts and updates to tables where
> they
> only have select permissions. So whenever they execute them a error
> message
> is produced. How can i turnaround this. I want the sp to actually write in
> some tables which they only have select permissions. Is there a solution.
> Thanks
> --
> Carlos Dias|||It would help us better assist you if you could include table DDL, and the
entire stored procedure code. Without this effort from you, we are just
playing guessing games.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"Carlos Dias" <CarlosDias@.discussions.microsoft.com> wrote in message
news:1801CAC0-5691-4146-B63C-7E2E99E87405@.microsoft.com...
> Hi,
> I programmed a Sp, which I gave permissions to some users to execute,
> nevertheless, inside the code makes inserts and updates to tables where
> they
> only have select permissions. So whenever they execute them a error
> message
> is produced. How can i turnaround this. I want the sp to actually write in
> some tables which they only have select permissions. Is there a solution.
> Thanks
> --
> Carlos Dias|||Users do not need any permissions on tables used in a stored procedure as
long as:
1) all objects are owned by the same user (SQL 2000) or have same schema
owner (SQL 2005)
2) you do not use dynamic SQL
This behavior is known as ownership chaining. See the Books Online for more
information.
Hope this helps.
Dan Guzman
SQL Server MVP
"Carlos Dias" <CarlosDias@.discussions.microsoft.com> wrote in message
news:1801CAC0-5691-4146-B63C-7E2E99E87405@.microsoft.com...
> Hi,
> I programmed a Sp, which I gave permissions to some users to execute,
> nevertheless, inside the code makes inserts and updates to tables where
> they
> only have select permissions. So whenever they execute them a error
> message
> is produced. How can i turnaround this. I want the sp to actually write in
> some tables which they only have select permissions. Is there a solution.
> Thanks
> --
> Carlos Dias

Permissions With Dynamic SQL Within Stored Procedure

Okay, I have sort of a peculiar permissions question I am wondering if someone can help me with. Basically, here's the scenario...

I have a CLR stored procedure which does some dynamic SQL building based on values sent in via XML. It's a CLR stored procedure using XML because I want to build a parameterized statement (to guard against SQL Injection) based on a flexible number of parameters which are basically passed in the XML.

The dynamic SQL ends up reading from a table I'll call TableX and I actually discovered an (understandable) quirk with security.

Basically, the connection context is using security for a low-privilaged Windows account ("UserX") and UserX has no permission to the table referenced in the dynamic SQL but because of the dyanmic nature of the query, the stored procedure ends up adopting the security context of UserX. Naturally, this throws a security exception saying UserX has no SELECT permission on TableX.

Now, I can give UserX read permission to the table in question to get things running, but one of the points of using stored procedures is to defer security to the procedure level vs. configuration for tables or columns.

So in striving toward my ideal of security at the procedure level, my question is what is the best way to allow minimum privilege in this case?

I thought about having the internals of the CLR stored procedure run under a different (low-privalaged) security context, but I am wondering if there's an alternate configuration that may be as secure, but simpler.

PS - Please don't let this degenerate into a conversation about OR mappers. I know that happens a lot on these forums.Smile

BoulderBum:

Basically, the connection context is using security for a low-privilaged Windows account ("UserX") and UserX has no permission to the table referenced in the dynamic SQL but because of the dyanmic nature of the query, the stored procedure ends up adopting the security context of UserX. Naturally, this throws a security exception saying UserX has no SELECT permission on TableX.

Yes, this is by design. When you EXECUTE dynamic SQL statement. When a stored procedure is run that executes a string, permissions are checked in the context of the user who executes the procedure, not in the context of the user who created the procedure.

So in earlier SQL versions you have to choose: use dynamic SQL if you do have to, or not use it if not necessary. Fortunately in SQL 2005 we have another option: using EXECUTE AS clause when creating the stored procedure. For example:

create proc sp_testper WITH EXECUTE AS SELF
as
EXEC('select * from Orders')
go

For more information about this clause, please refer to:

http://msdn2.microsoft.com/en-us/library/ms188354(d=ide).aspx

|||

Thanks, lori_Jay.

That's the solution I'm probably going to end up going with, though I didn't know until a few days ago that EXECUTE AS could apply toCLRstored procedures. I was just deploying via the IDE which doesn't offer such options and the documentation I saw didn't give an example of how to use EXECUTE AS with a CLR stored procedure.

Luckily I was informed that it was indeed possible and though I haven't sat down to do it yet, and that solution suffices for my needs!

Anyway, thanks again!

|||

For future readers, something else I discovered comes in handy is that you can have a predeployscripts.sql and postdeployscripts.sql file in a database project.

With those files, I was able to rig the EXECUTE AS and change the schema for my stored procedures. It took some dropping/recreating to get everything where I wanted, but it was pretty easy and worked like a charm.

I now have one-touch deployment of my CLR stored procedures through Visual Studio again!

Permissions when using trusted connection

I want my users to use trusted connection when logging in to the SQL Server,
and that goes successful, but the strange thing is that the SQL Server
seemes to think that the logged in user is "sa" which is not so good, cause
then the user has all the pemissons. I want to set the permissions manually
for each "trusted connection"-user. What am I doing wrong. Probably an easy
question.When you login with a trusted connection (no userid/password in connection
string), you are logged in as that account rather than the 'sa' SQL Server
account. If the Windows account has sa-like permissions, then a likely
cause is that the user is a member of the SQL Server sysadmin server role.
Members of the Windows local Administrators group are sysadmin role members
by default so perhaps the account is an admin on the SQL Server box.
A best practice in SQL Server security admin is to grant permissions to
roles rather than individual users. This simplifies administration because
you can control access via role membership.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Uffe" <uffe.waldero@.home.se> wrote in message
news:ubEysOg0DHA.1684@.TK2MSFTNGP12.phx.gbl...
> I want my users to use trusted connection when logging in to the SQL
Server,
> and that goes successful, but the strange thing is that the SQL Server
> seemes to think that the logged in user is "sa" which is not so good,
cause
> then the user has all the pemissons. I want to set the permissions
manually
> for each "trusted connection"-user. What am I doing wrong. Probably an
easy
> question.
>|||I suspect the NT logins are members of a group for which you have given
sysadmin privileges.
Check all of your sql roles and remember everyone is a member of the public
role.
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Uffe" <uffe.waldero@.home.se> wrote in message
news:ubEysOg0DHA.1684@.TK2MSFTNGP12.phx.gbl...
> I want my users to use trusted connection when logging in to the SQL
Server,
> and that goes successful, but the strange thing is that the SQL Server
> seemes to think that the logged in user is "sa" which is not so good,
cause
> then the user has all the pemissons. I want to set the permissions
manually
> for each "trusted connection"-user. What am I doing wrong. Probably an
easy
> question.
>|||Why don't you make these users members of the db_datawriter fixed database
role? You can find more info in books online but here's an example:
EXEC sp_addrolemember 'db_datawriter', 'username'
--
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 Programming by Example
"Eugene" <eliu@.ctisinc.com> wrote in message
news:30D10394-6085-4C6B-A268-9E3BFA75833A@.microsoft.com...
> HI,
> I am having a little different issue. When my windows users login into sql
server with trustes connection, they can select the data but no update and
insert. It said permission denied. But I have put them into DBO group or
role and have all permission on database. What went wrong ? Please help.
Many thanks.sql

Permissions when using trusted connection

HI,
I am having a little different issue. When my windows users login into sql s
erver with trustes connection, they can select the data but no update and in
sert. It said permission denied. But I have put them into DBO group or role
and have all permission on
database. What went wrong ? Please help. Many thanks.Why don't you make these users members of the db_datawriter fixed database
role? You can find more info in books online but here's an example:
EXEC sp_addrolemember 'db_datawriter', 'username'
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 programming by Example
"Eugene" <eliu@.ctisinc.com> wrote in message
news:30D10394-6085-4C6B-A268-9E3BFA75833A@.microsoft.com...
quote:

> HI,
> I am having a little different issue. When my windows users login into sql

server with trustes connection, they can select the data but no update and
insert. It said permission denied. But I have put them into DBO group or
role and have all permission on database. What went wrong ? Please help.
Many thanks.

Permissions when restoring a database

Our staff login to SQL Server using NT Authentication. The logins have Security Administrator, Disk Administrator and Database Creator Server Roles.

Staff memebers create a new database with Enterprise Manager and are automatically the dbo of that database. They then need to restore the database (again using EM) from a backup file sent to us from various clients. Obviously their login/user will not exist in this external backup file we have been sent. When they restore the database (and they are large so this can take an hour), the restore is almost complete when it gives the error :

Server user 'BLAH' is not a valid user in database 'clientdb'.
RESTORE DATABASE is terminating abnormally

The user is no longer dbo or even part of the database they just created.

IS there any way for me to get around this error without making all our staff System Administrors ?

Thanks,
AlisonTry to create a New Database by rightclicking on the databases.

while restoring and select force restore over existing Database and try it in options tab

Cheers :)|||The database is created by right clicking on Databases in Enterprise Manager.

The restore already uses "force restore over existing Database".|||If you login(as Administrator) does it allow you to restore ?.

Also try to restore without creating the database first i.e straight way choose restore option when the "Restore Database" pops up put a new name (whatever you want) and continue with restore procedure. Let me know what happens.

I tried to simulate our situation no errors came up.|||If I log in as System Administrator there are no problems, but I really don't want all our staff to have System Administrator rights on the SQL Server.

I tried as per your suggestion of NOT creating the database first. The restore chugs along till 99% complete then shows the error message
"Server user blah is not a valid user in database CLIENTSDB.
Restore database is terminating abnormally"

*sigh*.

The only slight success I found was if I knew one of the users in the client database, and created a login with the same name, then logged in as this new login, I could restore the database. However, I would need to know an existing user.. which most of the time I dont.

Permissions when linking to reports

Hi,

I've adding a link from my web app to reports sitting on another box. However, that box is asking the user to login. How do I set the permissions to avoid it?Would like to help!
What OS are your "boxes" running ?
Are you using Active Directory?
Are your "boxes" on the same intranet ?
What security schema are you using with SQL connections?
Best Regards,

permissions via roles query (SQL Server 2000)

Is anybody willing to share a query which shows all permissions granted
to a user, including permissions granted via roles? The complexity is
that a role can be granted to a role, and therefore this becomes a
bill-of-materials explosion / tree hierarchy / adjacency list problem.
Example:
create role r1
grant select on t1 to r1
grant select on t2 to r1
create role r2
grant select on t3 to r2
grant select on t4 to r2
create role r3
grant r1 to r3
grant r2 to r3
grant r3 to user1
The end result is that you want to be able to see that user1 has select
on t1, t2, t3, t4. An added bonus would be able to see the lineage.
I have found general discussion about solving these kinds of problems.
I'm curious if anybody has a working example for permissions and roles
in SQLServer 2000.sp_helprotect
<rc8740@.netscape.net> wrote in message
news:1149690495.671940.102730@.i39g2000cwa.googlegroups.com...
> Is anybody willing to share a query which shows all permissions granted
> to a user, including permissions granted via roles? The complexity is
> that a role can be granted to a role, and therefore this becomes a
> bill-of-materials explosion / tree hierarchy / adjacency list problem.
> Example:
> create role r1
> grant select on t1 to r1
> grant select on t2 to r1
> create role r2
> grant select on t3 to r2
> grant select on t4 to r2
> create role r3
> grant r1 to r3
> grant r2 to r3
> grant r3 to user1
> The end result is that you want to be able to see that user1 has select
> on t1, t2, t3, t4. An added bonus would be able to see the lineage.
> I have found general discussion about solving these kinds of problems.
> I'm curious if anybody has a working example for permissions and roles
> in SQLServer 2000.
>|||There are some good ones up on sqlservercentral.com
It sounds like you may be looking for one like this one:
http://www.sqlservercentral.com/scr...butions/268.asp
-Sue
On 7 Jun 2006 07:28:15 -0700, rc8740@.netscape.net wrote:

>Is anybody willing to share a query which shows all permissions granted
>to a user, including permissions granted via roles? The complexity is
>that a role can be granted to a role, and therefore this becomes a
>bill-of-materials explosion / tree hierarchy / adjacency list problem.
>Example:
>create role r1
>grant select on t1 to r1
>grant select on t2 to r1
>create role r2
>grant select on t3 to r2
>grant select on t4 to r2
>create role r3
>grant r1 to r3
>grant r2 to r3
>grant r3 to user1
>The end result is that you want to be able to see that user1 has select
>on t1, t2, t3, t4. An added bonus would be able to see the lineage.
>I have found general discussion about solving these kinds of problems.
>I'm curious if anybody has a working example for permissions and roles
>in SQLServer 2000.|||There are some good ones up on sqlservercentral.com
It sounds like you may be looking for one like this one:
http://www.sqlservercentral.com/scr...butions/268.asp
-Sue
On 7 Jun 2006 07:28:15 -0700, rc8740@.netscape.net wrote:

>Is anybody willing to share a query which shows all permissions granted
>to a user, including permissions granted via roles? The complexity is
>that a role can be granted to a role, and therefore this becomes a
>bill-of-materials explosion / tree hierarchy / adjacency list problem.
>Example:
>create role r1
>grant select on t1 to r1
>grant select on t2 to r1
>create role r2
>grant select on t3 to r2
>grant select on t4 to r2
>create role r3
>grant r1 to r3
>grant r2 to r3
>grant r3 to user1
>The end result is that you want to be able to see that user1 has select
>on t1, t2, t3, t4. An added bonus would be able to see the lineage.
>I have found general discussion about solving these kinds of problems.
>I'm curious if anybody has a working example for permissions and roles
>in SQLServer 2000.|||I was really hopeful when I found this...but I'm getting zero records when
I run the SP created by the script.... any other tools or suggestions?
Thanks.
Neil
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:u7sr8217iivmuojp2cq7msh6mc7vplde0f@.
4ax.com...
> There are some good ones up on sqlservercentral.com
> It sounds like you may be looking for one like this one:
> http://www.sqlservercentral.com/scr...butions/268.asp
> -Sue
> On 7 Jun 2006 07:28:15 -0700, rc8740@.netscape.net wrote:
>
>|||I was really hopeful when I found this...but I'm getting zero records when
I run the SP created by the script.... any other tools or suggestions?
Thanks.
Neil
"Sue Hoegemeier" <Sue_H@.nomail.please> wrote in message
news:u7sr8217iivmuojp2cq7msh6mc7vplde0f@.
4ax.com...
> There are some good ones up on sqlservercentral.com
> It sounds like you may be looking for one like this one:
> http://www.sqlservercentral.com/scr...butions/268.asp
> -Sue
> On 7 Jun 2006 07:28:15 -0700, rc8740@.netscape.net wrote:
>
>