Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6069693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:50:59+00:00 2026-05-23T09:50:59+00:00

I have got a user in my database that hasn’t got an associated login.

  • 0

I have got a user in my database that hasn’t got an associated login. It seems to have been created without login.

Whenever I attempt to connect to the database with this user I get the following error:

Msg 916, Level 14, State 1, Line 1
The server principal "UserName" is not able to access the database 
"DatabaseName" under the current security context.

I’d like to specify a login for this user so that I can actually use it to access the database. I’ve tried the following script to associate a login with the user.

USE [DatabaseName]
ALTER USER [UserName]
WITH LOGIN = [UserName]

But this gives me the following error:

Msg 33016, Level 16, State 1, Line 2
The user cannot be remapped to a login. Remapping can only be done for users 
that were mapped to Windows or SQL logins.

Is there any way I can assign a login to this user? I’d like to not have to start from scratch because this user has a lot of permissions that would need setting up again.

Edit: in response to Philip Kelley’s question, here’s what I get when I run select * from sys.database_principals where name = 'username'.

SQL User

Apologies for the size of the image, you’ll need to open it in a new tab to view it properly.

Edit2:

Ok, I’ve dropped the existing LOGIN as suggested by gbn, and I’m using the following script to create a new LOGIN with same SID as the user.

CREATE LOGIN [UserName] 
WITH PASSWORD=N'Password1', 
DEFAULT_DATABASE=[DatabaseName], 
CHECK_EXPIRATION=OFF, 
CHECK_POLICY=OFF, 
SID=0x0105000000000009030000001139F53436663A4CA5B9D5D067A02390

It’s now giving me the following error message, it appears that the SID is too long for the LOGIN’s SID field.

Msg 15419, Level 16, State 1, Line 1
Supplied parameter sid should be binary(16).

Am I up the creek without a paddle?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:51:00+00:00Added an answer on May 23, 2026 at 9:51 am

    You have an orphaned user and this can’t be remapped with ALTER USER (yet) becauses there is no login to map to. So, you need run CREATE LOGIN first.

    If the database level user is

    • a Windows Login, the mapping will be fixed automatcially via the AD SID
    • a SQL Login, use “sid” from sys.database_principals for the SID option for the login

    Then run ALTER USER

    Edit, after comments and updates

    The sid from sys.database_principals is for a Windows login.

    So trying to create and re-map to a SQL Login will fail

    Run this to get the Windows login

    SELECT SUSER_SNAME(0x0105000000000009030000001139F53436663A4CA5B9D5D067A02390)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that requires user to register. I've got the app conected
I have 3 tables in a MySql Database: User; Company that has a date
I have got a basic login script at the moment. When the user logs
I have got a form which a user can use to create a new
I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
I have got an application, that is getting data via XML-files. During the parsing-part
I am using datalist to display data from the database,I have got three fields
I am using external Users database for different projects. Now I have got School
Lets say I have a class User. A user got a name, gender, ...,
I've got a database site that will serve approximately 1,200 primary entries at launch,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.