Unix Technical Forum

sp_adduser and the old question of why??

This is a discussion on sp_adduser and the old question of why?? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hello Group Ok, I've read the BOL topic on sp_adduser and have done some research here in the groups ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 03:48 AM
Martin Feuersteiner
 
Posts: n/a
Default sp_adduser and the old question of why??

Hello Group

Ok, I've read the BOL topic on sp_adduser and have done some research here
in the groups but the 'why' question remains...

A simple thing:
I would like to empower 'User A' to be able to add logins and users to
database 'ABC' so I don't have to do it.
Let's assume I'm far away on a tropical island with no remote access for
several months ...ahhhh

Now, I've added the Login for 'User A' to the server roles 'Security
Administrators' and 'System Administrators' and given access to the
databases 'ABC' and 'master' - it all works, 'User A' can create logins and
users for 'ABC'

What I find a little bit disturbing is, that this gives 'User A' the
possibility to do anything with any database and I just wondered whether
there's a way.. to avoid this perhaps?

So just createing logins and creating users permissions for database 'ABC'
and as little as needed from everything else...
Please describe in detail on how to do this as I'm new to this and don't
have much of a clue..as you see!

Later on, I might want to create a 'UserB' with the same capabilities but
for now I'm just happy to get going.

Thanks for your help & efforts!!

Martin


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 03:48 AM
Martin Feuersteiner
 
Posts: n/a
Default Re: sp_adduser and the old question of why??

Ok.. sp_grantdbaccess seems to do the trick.. also all samples are for NT
Users, it seems to work except for a message that the user already exists
when it is indeed not. But still creates it. I can trap this error but
wonder whether this is the right way??

That's my code:

EXEC @ReturnCode = sp_addlogin @ProgUserLogin, @ProgUserPassword,
'invent2b_com'
EXEC @ReturnCode = sp_grantdbaccess @ProgUserLogin, @ProgUserName
EXEC @ReturnCode = sp_addrolemember @SQLRole, @ProgUserLogin

Thank you very much for your thoughts!

Martin


"Martin Feuersteiner" <theintrepidfox@hotmail.com> wrote in message
news:ceb6fc$2jk$1@hercules.btinternet.com...
> Hello Group
>
> Ok, I've read the BOL topic on sp_adduser and have done some research here
> in the groups but the 'why' question remains...
>
> A simple thing:
> I would like to empower 'User A' to be able to add logins and users to
> database 'ABC' so I don't have to do it.
> Let's assume I'm far away on a tropical island with no remote access for
> several months ...ahhhh
>
> Now, I've added the Login for 'User A' to the server roles 'Security
> Administrators' and 'System Administrators' and given access to the
> databases 'ABC' and 'master' - it all works, 'User A' can create logins

and
> users for 'ABC'
>
> What I find a little bit disturbing is, that this gives 'User A' the
> possibility to do anything with any database and I just wondered whether
> there's a way.. to avoid this perhaps?
>
> So just createing logins and creating users permissions for database 'ABC'
> and as little as needed from everything else...
> Please describe in detail on how to do this as I'm new to this and don't
> have much of a clue..as you see!
>
> Later on, I might want to create a 'UserB' with the same capabilities but
> for now I'm just happy to get going.
>
> Thanks for your help & efforts!!
>
> Martin
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 03:48 AM
Simon Hayes
 
Posts: n/a
Default Re: sp_adduser and the old question of why??


"Martin Feuersteiner" <theintrepidfox@hotmail.com> wrote in message
news:ceb6fc$2jk$1@hercules.btinternet.com...
> Hello Group
>
> Ok, I've read the BOL topic on sp_adduser and have done some research here
> in the groups but the 'why' question remains...
>
> A simple thing:
> I would like to empower 'User A' to be able to add logins and users to
> database 'ABC' so I don't have to do it.
> Let's assume I'm far away on a tropical island with no remote access for
> several months ...ahhhh
>
> Now, I've added the Login for 'User A' to the server roles 'Security
> Administrators' and 'System Administrators' and given access to the
> databases 'ABC' and 'master' - it all works, 'User A' can create logins

and
> users for 'ABC'
>
> What I find a little bit disturbing is, that this gives 'User A' the
> possibility to do anything with any database and I just wondered whether
> there's a way.. to avoid this perhaps?
>
> So just createing logins and creating users permissions for database 'ABC'
> and as little as needed from everything else...
> Please describe in detail on how to do this as I'm new to this and don't
> have much of a clue..as you see!
>
> Later on, I might want to create a 'UserB' with the same capabilities but
> for now I'm just happy to get going.
>
> Thanks for your help & efforts!!
>
> Martin
>
>


I believe that adding UserA to securityadmin (manage logins) and
db_accessadmin in ABC (manage users in that database only) should do what
you want. UserA can create as many logins as he wants, but they're not much
use without access to databases. And being in db_accessadmin does not give
you the right to create objects or view data in that database. But I admit
that I haven't tested this, and there are some potential issues - only
sysadmin/db_owner can use sp_change_users_login to fix orphaned users, for
example.

Simon


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:09 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com