Error on Create User - Server identity does not have Azure Active Directory Readers permission.

Saish Paradkar 25 Reputation points
2025-04-17T13:57:53.3933333+00:00

I do not have entry for my user in sys.database_principals. But I do have in sys.server_principals.
As per this I can add user to sys.database_principals using Create user command.
I am getting below error but not able to figure out how I can fix it or how I can give permission for Directory Readers?
{ED36011E-DC25-4E15-80A7-30877F095B72}

Azure Database for MySQL
{count} vote

1 answer

Sort by: Most helpful
  1. KGY Udayanga 0 Reputation points
    2025-10-17T16:30:32.0433333+00:00

    An orphaned user is a database user whose corresponding server login is missing or mismatched. You can't create a new user for the login because, as far as the database is concerned, a user for that login already exists it's just broken.

    The solution is not to CREATE a new user, but to re-link the existing user to the server login.

    1. Find the Existing User Name

    First, run this query on the specific database to see if a user already exists that should be linked to your login.

    SQL

    SELECT
        name AS DatabaseUserName,
        sid AS UserSID
    FROM sys.database_principals
    WHERE type_desc IN ('SQL_USER', 'WINDOWS_USER', 'WINDOWS_GROUP')
      AND authentication_type_desc != 'NONE'; -- Exclude roles and schema-only users
    

    Look for a user name in the results that should correspond to your server login.

    1. Re-link the User to the Login

    Once you've identified the existing database user name (e.g., SomeUser), run the following command to fix the mapping. This is the modern and preferred method.

    SQL

    -- Syntax: ALTER USER [database_user_name] WITH LOGIN = [server_login_name];
    ALTER USER [SomeUser] WITH LOGIN = [YourLoginName];
    

    This command updates the security identifier (SID) of the database user to match the SID of the server login, fixing the broken link. After running this, your login should work correctly without needing to create a new user.

    If the above doesn't work, here are other things to check:

    Incorrect Syntax: Double-check that your command is correct. The FROM LOGIN clause is required to link the new user to an existing server login.

    SQL

    CREATE USER [SomeUser] FROM LOGIN [YourLoginName];
    

    Insufficient Permissions: To create or alter a user, you need the ALTER ANY USER permission or membership in the db_owner or db_accessadmin database roles.

    To get to the right solution, the best next step is for you to share the exact error message you're seeing.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.