none
How to map Security/Logins users? RRS feed

  • Question

  • If I right click on a login userAdmin, Properties, User Mapping, under "User mapped to this login:", I check the myDatabase I wanted and then under the "Database role membership for: myDatabase", I checked db_ddladmin and tbmsUSER and then click OK. This process works. However, when I script it, it does not.

    USE [myDatabase]
    GO
    ALTER ROLE [db_ddladmin] ADD MEMBER [userAdmin]
    GO
    USE [myDatabase]
    GO
    ALTER ROLE [tbmsUSER] ADD MEMBER [userAdmin]
    GO

    I got this error:

    Msg 15151, Level 16, State 1, Line 3
    Cannot add the principal 'userAdmin', because it does not exist or you do not have permission.
    Msg 15151, Level 16, State 1, Line 7
    Cannot add the principal 'userAdmin', because it does not exist or you do not have permission.
    

    Friday, December 6, 2019 4:37 PM

All replies

  • Friday, December 6, 2019 5:10 PM
  • Hi Charlie2,

    Please check :Try executing 'SELECT USER'; If you are an administrator, this statement will return 'dbo'.

    And then I can execute following script correctly.

    USE test;
    GO
    CREATE ROLE [AnotherRole];
    ALTER ROLE [db_datareader] ADD MEMBER [AnotherRole];
    GO

    Best Regards,

    Rachel 



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 9, 2019 8:23 AM
  • Hi ,

     

    I am writing to follow up this thread with you. Have you solved your issue? If you have solved your issue ,in order to close this thread, please kindly mark helpful replies as answers. By doing so, it will benefit all community members who are having this similar issue.  Your contribution is highly appreciated.

     

    Best Regards,

    Rachel


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 11, 2019 9:51 AM
  • Hi,

     

    If you find any post in the thread is helpful, you could kindly mark it as answer. This would benefit the community, and also encourage the community member to keep working on your issues.

     

    Best Regards,

    Rachel


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 26, 2019 3:06 AM