Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Want to remove an existing user mapping for a login. Expand / Collapse
Author
Message
Posted Friday, November 16, 2012 3:25 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 9:09 AM
Points: 2, Visits: 2
In SQL Server 2012, I want to remove (programmatically in C# or via SQL command line) a login mapping to a user. I have a login that is mapped to a database user and I want to remove that mapping without removing the login, user or database.
Post #1385873
Posted Friday, November 16, 2012 3:36 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:47 PM
Points: 14,437, Visits: 37,834
looks like it cannot be done;
my knee jerk reaction was to see if ALTER USER supported WITHOUT LOGIN, which it does not;
my next idea was to ALTER USER WITH LOGIN = NULL, which is also not supported.



--syntax errors:
ALTER USER SampleUser WITHOUT LOGIN
ALTER USER SampleUser WITH LOGIN = NULL


i think it's better to drop and recreate the user without login? then you can alter thema nd remap them to the login?
DROP USER SampleUser
CREATE USER SampleUser WITHOUT LOGIN

maybe you could move the user out of it's existing roles so it effectively cannot do anything in the database instead?


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1385875
Posted Monday, November 19, 2012 8:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 9:09 AM
Points: 2, Visits: 2
Thanks. The DROP USER will work for me.
Post #1386426
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse