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

Tuesday, March 27, 2012

addlogin & grantdbaccess for a user

We are developing an application and we need to create a
user called "Application" which must be capable to create
new logins and grant permissions to they, so it must be
capable to run sp_addlogin and sp_grantdbaccess stored
procedures.
Can anyone help us?
Thanks.You can add the login to predefined server and database roles in order to
manage security:
--add security admin login
EXEC sp_addlogin 'Application', 'ApplicationPassword'
EXEC sp_addsrvrolemember 'Application', 'securityadmin'
GO
--grant security admin login database access
EXEC sp_adduser 'Application'
EXEC sp_addrolemember 'db_accessadmin', 'Application'
EXEC sp_addrolemember 'db_securityadmin', 'Application'
GO
Hope this helps.
Dan Guzman
SQL Server MVP
"Peter" <pedrojpz@.terra.es> wrote in message
news:015401c3c757$fd83eeb0$a601280a@.phx.gbl...
quote:

> We are developing an application and we need to create a
> user called "Application" which must be capable to create
> new logins and grant permissions to they, so it must be
> capable to run sp_addlogin and sp_grantdbaccess stored
> procedures.
> Can anyone help us?
> Thanks.

Thursday, March 22, 2012

Adding users and giving permissions in MSDE

How can I add users and give permissions to access a database in MSDE.
Hi
Have a look at
sp_addrole
sp_dropuser
sp_grantdbaccess
sp_grantlogin
sp_helpuser
"Antonin Koudelka" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
news:u5etHL9FFHA.1292@.TK2MSFTNGP10.phx.gbl...
> How can I add users and give permissions to access a database in MSDE.
>

Adding users and giving permissions in MSDE

How can I add users and give permissions to access a database in MSDE.Hi
Have a look at
sp_addrole
sp_dropuser
sp_grantdbaccess
sp_grantlogin
sp_helpuser
"Antonin Koudelka" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
news:u5etHL9FFHA.1292@.TK2MSFTNGP10.phx.gbl...
> How can I add users and give permissions to access a database in MSDE.
>

Adding users and giving permissions in MSDE

How can I add users and give permissions to access a database in MSDE.Hi
Have a look at
sp_addrole
sp_dropuser
sp_grantdbaccess
sp_grantlogin
sp_helpuser
"Antonin Koudelka" <Antonin.Koudelka@.fmc.sa.gov.au> wrote in message
news:u5etHL9FFHA.1292@.TK2MSFTNGP10.phx.gbl...
> How can I add users and give permissions to access a database in MSDE.
>

Adding users

Hi
I want to programatically attach a DB to an instance of MSDE, and then
create the user, and give permissions to the DB I've just attached.
I can successfully attach the DB, but cannot get the permissions correct
Which sequence of T-SQL commands should I be calling to:
a). create the login in the instance of MSDE
b). associate the login with the newly attached DB
I have played around with:
sp_attach_single_file_db
sp_addlogin
sp_grantdbaccess
sp_grantlogin
but I cannot get a successful logon with the new account, even though the
T-SQL commands run successfully.
Thanks
Hi Paul,
Is there any chance the users already exist in the database you're
attaching? If so, you get into a weird situation because you have users with
the same name but different SID's. If you download a copy of MSDE Manager
from our site (free for personal use), it's got a menu option that lets you
list and fix security ID problems. Might well help.
To avoid these, we normally create the users on the target system by
supplying the sid parameter.
HTH,
Greg Low [MVP]
MSDE Manager SQL Tools
www.whitebearconsulting.com
"Paul Aspinall" <paul@.aspy.co.uk> wrote in message
news:m%IUd.241292$K7.73273@.fe2.news.blueyonder.co. uk...
> Hi
> I want to programatically attach a DB to an instance of MSDE, and then
> create the user, and give permissions to the DB I've just attached.
> I can successfully attach the DB, but cannot get the permissions correct
> Which sequence of T-SQL commands should I be calling to:
> a). create the login in the instance of MSDE
> b). associate the login with the newly attached DB
> I have played around with:
> sp_attach_single_file_db
> sp_addlogin
> sp_grantdbaccess
> sp_grantlogin
> but I cannot get a successful logon with the new account, even though the
> T-SQL commands run successfully.
> Thanks
>
>
|||Hi Greg,
I was reading Paul message and experienced the same problems setting up MSDE.
I installed the MSDE on a machine i was using for the server.
Used (local)netSDK for instance as in the documentation .
Then I accessed the database NorthWind using the SQLClient.
The samples in VB.net now work ok when ran from the server where I installed
MSDE.
However, I then got very bold, and tried to access the NorthWind database
from another computer that was setup on our network.
I added a login name, added a role and a member, granted premission.
Then in the vb.net program I tried to open the database with the same code
from the program on the server. I did change the server name to the Name of
the computer that MSDE was installed on. I also tried the IP address as the
server.
I kept getting the error "Server not found or do not have premission.
WHAT AM I DOING WRONG?
Best regards,
Dave
"Greg Low [MVP]" wrote:

> Hi Paul,
> Is there any chance the users already exist in the database you're
> attaching? If so, you get into a weird situation because you have users with
> the same name but different SID's. If you download a copy of MSDE Manager
> from our site (free for personal use), it's got a menu option that lets you
> list and fix security ID problems. Might well help.
> To avoid these, we normally create the users on the target system by
> supplying the sid parameter.
> HTH,
> --
> Greg Low [MVP]
> MSDE Manager SQL Tools
> www.whitebearconsulting.com
> "Paul Aspinall" <paul@.aspy.co.uk> wrote in message
> news:m%IUd.241292$K7.73273@.fe2.news.blueyonder.co. uk...
>
>

Sunday, March 11, 2012

Adding permissions to New Database

Hi,

When a new Database is created ( some , not all. All that begins with 'PW' ) i want to add a windows-usergroup to it so they can access the DB.
Normally I could do this by adding this user to the model-db but it's not for all DB's that are added (The other DB's must not be accesible for this usergroup ).
The DB's are added by an External App so I have no control over it.

So I was thinking, no problem we can just add a trigger to the master..sysdatabases table and add if necessary the permissions.
Not -> Even with allowupdates = 1 you cannot add a trigger to a system table ( a bit overprotection from ms, should be allowed if you know what you are doing ).

I would like to avoid running a job every x time to look if a new DB has been added, the DB must be available within minutes after creation.

Does anybody has any suggestions ?

Thanks in advance,

Sven Peeters
Belgiumif you know what you are doing

Indeed

Does anybody has any suggestions ?

Yeah, don't do what you're doing...

What's with the dynamic database creation anyway?

What is this for?|||That's the beauty of it all, that i cannot control.
It's an external app that generates these DB's ( that are deleted after a while ).
I think they use them as temporary database with statistics or some sort.

Anyway, i cannot change anything about the app and other users must have access to this database.

Any help is welcome, otherwise I will have to use a job to do this.

Thnx in adv,

Sven Peeters
Belgium|||It's an external app that generates these DB's ( that are deleted after a while

Just curious...is this a third party app or an in house external app?

If it's 3rd party, what is it?

And how do you know what users are suppose to have access to which databases.

How do they not step on their own ducks when creating the dbs..are they timestamped?

What about the logins? Are these new users or old users?

Adding permissions to an AD user on a remote database

I was wondering if someone can point me in the right direction. I am lookin
g
for a way to automate (in a script format) the addition of a user to a
database on a remote server. We have an application that requires that the
user have Owner permissions on 3 databases and 1 store procedure. Manually
connectiing to 400 workstations will be a huge pain..I'm not sure what you mean by 400 workstations - if a login
needs access to databases and stored procedures, you would
set that at the server level in SQL Server and in whatever
databases.
Unless there is something in the application itself that has
to be coded which would be an application issue
If you are just trying to add the login and user to the
databases, you can script these using t-sql commands. See
books online topics for sp_grantlogin, sp_grantdbaccess,
sp_addrolemember.
-Sue
On Mon, 27 Feb 2006 13:11:27 -0800, Chad T
<ChadT@.discussions.microsoft.com> wrote:

>I was wondering if someone can point me in the right direction. I am looki
ng
>for a way to automate (in a script format) the addition of a user to a
>database on a remote server. We have an application that requires that the
>user have Owner permissions on 3 databases and 1 store procedure. Manually
>connectiing to 400 workstations will be a huge pain..|||Just to clarify... the 400 workstations have sql running on it for an
application that has an offline mode...
The previous post mentioned to use: sp_grantlogin, sp_grantdbaccess,
sp_addrolemember which got me to here <see working code below>
How can I verify or check to see a user is already a member of the role ONE
database?
Example: If I am trying to add a user to the 'db_owner' role on the DB1
database and they are already listed as a member I would like to skip the
sp_addrolemember command.
This is all I could find:
IF SUSER_SID('domain\userid') IS NULL begin
but this only seems to find out if the user has a sid, not if the user is
listed in the DB1 database as a db_owner
Any help would be greatly appreciated.
This is my code so far...
'++++++++++++++++++++++++++++++++++++++
Domain = "DDDDDDDD"
Userid = "HHHHHHHH"
RemoteSQL = "WWW"
full_login = domain & "\" & userid
strconn = "Provider='SQLOLEDB'; Data Source='"&remotesql&"'; Initial
Catalog='master'; User Id='XXXXXX'; Password='''';"
Set conn = CreateObject("adodb.connection")
conn.Open strconn
m = m & "USE DB0" & vbCrLf
m = m & "EXEC sp_grantlogin '"& full_login &"'" & vbCrLf
m = m & "EXEC sp_grantdbaccess '"& full_login &"', '"& full_login &"'" &
vbCrLf
m = m & "USE DB1" & vbCrLf
m = m & "EXEC sp_grantdbaccess '"& full_login &"', '"& full_login &"'" &
vbCrLf
m = m & "EXEC sp_addrolemember 'db_owner', '"& full_login &"'" & vbCrLf
m = m & "USE DB2" & vbCrLf
m = m & "EXEC sp_grantdbaccess '"& full_login &"', '"& full_login &"'" &
vbCrLf
m = m & "EXEC sp_addrolemember 'db_owner', '"& full_login &"'" & vbCrLf
'for the store procedure
m = m & "Use DB3" & vbCrLf
m = m & "GRANT EXECUTE ON CustOrdersOrders TO ["& full_login &"]" & vbCr
Lf
conn.execute(m)
Conn.close
set conn = nothing
"Sue Hoegemeier" wrote:

> I'm not sure what you mean by 400 workstations - if a login
> needs access to databases and stored procedures, you would
> set that at the server level in SQL Server and in whatever
> databases.
> Unless there is something in the application itself that has
> to be coded which would be an application issue
> If you are just trying to add the login and user to the
> databases, you can script these using t-sql commands. See
> books online topics for sp_grantlogin, sp_grantdbaccess,
> sp_addrolemember.
> -Sue
> On Mon, 27 Feb 2006 13:11:27 -0800, Chad T
> <ChadT@.discussions.microsoft.com> wrote:
>
>|||So the last piece you are looking for is the IS_MEMBER
function. That will tell you if a user is a member of the
specified database role.
-Sue
On Mon, 27 Feb 2006 20:47:26 -0800, Chad T
<ChadT@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Just to clarify... the 400 workstations have sql running on it for an
>application that has an offline mode...
>The previous post mentioned to use: sp_grantlogin, sp_grantdbaccess,
>sp_addrolemember which got me to here <see working code below>
>How can I verify or check to see a user is already a member of the role ONE
>database?
>Example: If I am trying to add a user to the 'db_owner' role on the DB1
>database and they are already listed as a member I would like to skip the
>sp_addrolemember command.
>This is all I could find:
>IF SUSER_SID('domain\userid') IS NULL begin
>but this only seems to find out if the user has a sid, not if the user is
>listed in the DB1 database as a db_owner
>Any help would be greatly appreciated.
>
>This is my code so far...
>'++++++++++++++++++++++++++++++++++++++
>Domain = "DDDDDDDD"
>Userid = "HHHHHHHH"
>RemoteSQL = "WWW"
>full_login = domain & "\" & userid
>strconn = "Provider='SQLOLEDB'; Data Source='"&remotesql&"'; Initial
>Catalog='master'; User Id='XXXXXX'; Password='''';"
>Set conn = CreateObject("adodb.connection")
>conn.Open strconn
>m = m & "USE DB0" & vbCrLf
>m = m & "EXEC sp_grantlogin '"& full_login &"'" & vbCrLf
>m = m & "EXEC sp_grantdbaccess '"& full_login &"', '"& full_login &"'" &
>vbCrLf
>m = m & "USE DB1" & vbCrLf
>m = m & "EXEC sp_grantdbaccess '"& full_login &"', '"& full_login &"'" &
>vbCrLf
>m = m & "EXEC sp_addrolemember 'db_owner', '"& full_login &"'" & vbCrLf
>m = m & "USE DB2" & vbCrLf
>m = m & "EXEC sp_grantdbaccess '"& full_login &"', '"& full_login &"'" &
>vbCrLf
>m = m & "EXEC sp_addrolemember 'db_owner', '"& full_login &"'" & vbCrLf
>'for the store procedure
>m = m & "Use DB3" & vbCrLf
>m = m & "GRANT EXECUTE ON CustOrdersOrders TO ["& full_login &"]" & vbC
rLf
>conn.execute(m)
>Conn.close
>set conn = nothing
>"Sue Hoegemeier" wrote:
>|||I am having issues with IS_Member...
"Indicates whether the current user is a member of the specified Microsoft
Windows group or Microsoft SQL Server database role. "
I did find this:
sp_helplogins 'domain\userid'
The problem with this is that the records that I want are in the second
record set.
Is there a way I can loop through the second record set instead of the first
one?
"Sue Hoegemeier" wrote:

> So the last piece you are looking for is the IS_MEMBER
> function. That will tell you if a user is a member of the
> specified database role.
> -Sue
> On Mon, 27 Feb 2006 20:47:26 -0800, Chad T
> <ChadT@.discussions.microsoft.com> wrote:
>
>|||Okay...so you actually want to know if the login exists -
not if it's a member of a database role. You can check if
the login exists before you add it using something like:
if not exists (select * from master.dbo.syslogins where
loginname = N'domain\userid')
exec sp_grantlogin N'domain\userid'
-Sue
On Tue, 28 Feb 2006 21:42:26 -0800, Chad T
<ChadT@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>I am having issues with IS_Member...
>"Indicates whether the current user is a member of the specified Microsoft
>Windows group or Microsoft SQL Server database role. "
>I did find this:
>sp_helplogins 'domain\userid'
>The problem with this is that the records that I want are in the second
>record set.
>Is there a way I can loop through the second record set instead of the firs
t
>one?
>
>"Sue Hoegemeier" wrote:
>|||Thank you so much for your help Sue.
I was looking at the second record set for "sp_helplogins" and it has
multiple columns (Login Name, DB Name, UserName, UserorAlias) It appears
that when I run it the columns tell me: (UserID, Database Name, Permission
Type, Member/User)
Is that right?
"Sue Hoegemeier" wrote:

> Okay...so you actually want to know if the login exists -
> not if it's a member of a database role. You can check if
> the login exists before you add it using something like:
> if not exists (select * from master.dbo.syslogins where
> loginname = N'domain\userid')
> exec sp_grantlogin N'domain\userid'
> -Sue
> On Tue, 28 Feb 2006 21:42:26 -0800, Chad T
> <ChadT@.discussions.microsoft.com> wrote:
>
>|||If you are executing this in query analyzer, there will be
two results in the results pane. You need to use the scroll
for the results pane to see the other set of results.
-Sue
On Thu, 2 Mar 2006 07:48:27 -0800, Chad T
<ChadT@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>Thank you so much for your help Sue.
>I was looking at the second record set for "sp_helplogins" and it has
>multiple columns (Login Name, DB Name, UserName, UserorAlias) It appears
>that when I run it the columns tell me: (UserID, Database Name, Permission
>Type, Member/User)
>Is that right?
>
>"Sue Hoegemeier" wrote:
>

Adding Permissions

We created a database with approximately 80 tables and 170 stored procedures
.
We were not too bright to begin with and one thing we did not consider was
not using sa as the login. Now, we need to create a user that does not have
full sa privileges but can execute all stored procedures and view all data i
n
the tables. Some of the stored procedures use dynamic sql (sp_executesql). W
e
also will be creating a new database, which corresponds to a specific test
event, about two or three times a month.
Question I have is can we create one user that can access all the stored
procedures and tables in ALL databases (as they are created) and is there a
fast way of granting privileges to all these objects without having to go in
the permissions for each one?You can create a login and create a user which is in the data_reader role in
every database and grant it rights to execute all stored procedures.
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Wannabe" <Wannabe@.discussions.microsoft.com> wrote in message
news:FE43D341-3AD0-459D-AA6A-794CA3E02915@.microsoft.com...
> We created a database with approximately 80 tables and 170 stored
> procedures.
> We were not too bright to begin with and one thing we did not consider was
> not using sa as the login. Now, we need to create a user that does not
> have
> full sa privileges but can execute all stored procedures and view all data
> in
> the tables. Some of the stored procedures use dynamic sql (sp_executesql).
> We
> also will be creating a new database, which corresponds to a specific test
> event, about two or three times a month.
> Question I have is can we create one user that can access all the stored
> procedures and tables in ALL databases (as they are created) and is there
> a
> fast way of granting privileges to all these objects without having to go
> in
> the permissions for each one?
>|||Also note that in SQL Server 2005, you can grant SELECT and EXECUTE
permissions at database level, so you don't need to perform grants for each
table or procedure.
Do you need to do this in all databases or only in databases of a certain
type? If the answer is all, consider setting this up in the model database.
Thanks
Laurentiu Cristofor [MSFT]
Software Design Engineer
SQL Server Engine
http://blogs.msdn.com/lcris/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:up6oLty7GHA.1256@.TK2MSFTNGP04.phx.gbl...
> You can create a login and create a user which is in the data_reader role
> in every database and grant it rights to execute all stored procedures.
> --
> Hilary Cotter
> Director of Text Mining and Database Strategy
> RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
> This posting is my own and doesn't necessarily represent RelevantNoise's
> positions, strategies or opinions.
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
>
> "Wannabe" <Wannabe@.discussions.microsoft.com> wrote in message
> news:FE43D341-3AD0-459D-AA6A-794CA3E02915@.microsoft.com...
>

Saturday, February 25, 2012

Adding logins and permissions

Hi,
I am at a company with 18 employees and I have 11-12 databases in SQL server. I can't seem to give logins and permissions to groups. Is there a simpler way, or do I have to add every single employee to each database and give permissions?
You may create roles (it's a group analogue) within databases and then assign your employees to these groups. There are no serverwide groups except of builtin server roles.

Friday, February 24, 2012

Adding Execute permissions on Stored Procedures

How can i add Execute permissions on the Stored Procedures under the
created user permission iusing SQLDMO ?hi,
arfanameer@.hotmail.com wrote:
> How can i add Execute permissions on the Stored Procedures under the
> created user permission iusing SQLDMO ?

Dim oProcedure As SQLDMO.StoredProcedure
Dim oServer As SQLDMO.SQLServer
' connect to the server, etc...

'get a pointer to the procedure..
Set oProcedure = oServer.Databases("Pubs").StoredProcedures("byroyalty")
'grant EXEC permission to an existing user
oProcedure.Grant SQLDMOPriv_Execute, "user_name"

Set oProcedure = Nothing
Set oServer = Nothing

--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.10.0 - DbaMgr ver 0.56.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--- remove DMO to reply

Sunday, February 12, 2012

adding another system administrator

Hi all

I deleted the sa account

how do I add it with all the correct permissions (plus include it in all the tables )

TIA

Guy

Recreate the login 'sa', then add it to the sysadmin server roleSmile For more information about sa, take a look at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_security_8soe.asp