Script Add user

  • Hey all,

    I am making a new script to add a user to our database.  I have so far written this.

    EXEC sp_addlogin @loginame =  'TESTER'

       ,@passwd = 'pwd'

        , @defdb =  'BBS TEST'

        ,  @deflanguage =  'British English'

    EXEC sp_adduser  @loginame =  'TESTER'

        ,@name_in_db = 'TESTER' 

        ,  @grpname =  'BBSUSER' 

    Ok - well a new user appears, and its a member of BBSUser but....

    If i then go onto this user using EM, goto database access then to BBSTest I get an error of

    "The name TESTER was not found in the users collection. If the name is a qualified name, use [] to separate the various parts and try again"

    Any ideas?

    Dan

  • When you executed sp_adduser where you physically in the database BBSTest?  (i.e. was BBSTest the active database when you ran the command).  Even though the login has a default DB assigned that doesn't make it part of that database until you run the Add User for that database.  Unless the role has permission on objects in that database you still might not be able to access anything, but you will get a different error message then the one you reported.

    James.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply