c# - sql server creation of logins and users by another user -


i using sql server express 2005. have single database mydb

i have created login l-1 user u-1 on databas mydb.

to connect database mydb found 3 ways:

-1(a)-after creating l-1 login default database = mydb , have create user u-1 , , when connected sql server , connected.

i used query:

create login l-1 password='passl1'  , default_database = mydb  use mydb  create user u-1 login l-1  

means, creating user inside login , gives user connect permission implicitly. right ?

-1(b)-i didn't create user u-1, executed :

use mydb  sp_grantdbaccess l-1  

this made me connect , reason being that, sql added user named l-1 implicitly in mydb database. right?

-1(c)-this time also, didn't create user u-1,but executed this:

sp_changedbowner l-1   

this made me connect , reason being that, sql added user named l-1 implicitly in mydb database. right?

now, want give user u-1 created in 1(a) following permissions:

  1. create logins l-2,l-3
  2. create users u2,u3 can connect database mydb.

how do this?

yes - calling sp_grantdbaccess or sp_changedbowner implicitly create user - no difference.

calling create user explicitly clearer, more obvious you're doing etc.

also: don't use sp_grantdbaccess anymore - because:

this feature will removed in future version of microsoft sql server. avoid using feature in new development work, , plan modify applications use feature. use create user instead.

source: technet on sp_grantdbaccess

and don't use sp_changedbowner either - same reason:

this feature will removed in future version of microsoft sql server. avoid using feature in new development work, , plan modify applications use feature. use alter authorization instead.

source: technet on sp_changedbower


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -