whoami still returning old username after surname change, SSMS not able to recognize the windows authentication user

Tomasz Sobotka 35 Reputation points
2025-06-25T12:31:34.1933333+00:00

Hello,

After a surname change in users profile we are experiencing some issues when running SSMS and trying to log to any database.

Old username: firstname.lastname @ company.com - monika.wozniak

New username: firstname.newlastname @ company.com - monika.dzielo

Device state: AzureAd Joined - Yes

User has already:

  • switched over to new Windows profile by logging via other user >> new email
  • credentials which are used for connecting with SSMS databases were updated accordingly in Windows Credential Manager

I have also tried removing and adding back user to localadmin group via:

net localgroup administrators /add "AzureAD\firstname.newlastname @ company.com"

However user is still added as old username and same goes for listing

CMD is returning:

User's image

the result in SSMS is:

User's image

User's image

Windows for business | Windows Server | Directory services | Active Directory
{count} votes

1 answer

Sort by: Most helpful
  1. Chen Tran 1,115 Reputation points Independent Advisor
    2025-06-28T07:32:20.4366667+00:00

    Hello,

    Thank you for posting question on Microsoft Windows Forum.

    Based on the error message "The target principal name is incorrect. Cannot generate SSPI context. (Microsoft SQL Server)" generated in SSMS. This error typically points to an issue with Kerberos authentication, most likely due to a mismatch. When your username changed from "@company.com" to "@company.com", even though you have updated credentials locally and switched profiles, the Kerberos system on the server-side (where SQL Server runs) might still be trying to authenticate your old principal name, or the SPN for the SQL Server itself might be incorrectly registered against an old service account, or not updated to reflect the new user principal.

    The followings are a few of suggested steps for troubleshooting to the issue.

    1.Verify Azure AD Profile Sync:

    • Ensure Azure AD shows the new UPN (******@company.com) as the primary username

    Check sync status in: Azure Portal → Azure Active Directory → Users

    2.Purge Kerberos tickets on the client:

    • Open Command Prompt as the user and run:
    • klist purge
    • klist ticket ->Verify no old UPN remains.

    3.Check Existing SPNs:

    • Open a command prompt as administrator on a domain-joined machine (or the SQL Server itself) and run:
    • setspn -L DOMAIN\SQLSvcAccount
    • If the SPNs are incorrect, missing, or registered against an old account, you'll need to correct them.

    4.Test Kerberos Auth:

    • Running below 2 commands:
    • setspn -Q MSSQLSvc/<SQL_Server_FQDN> > Verify SPN registration
    • klist get MSSQLSvc/<SQL_Server_FQDN> > Request new ticket

    5.Checking Old Profile References:

    1. Open regedit
    2. Navigate to this path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
    3. Searching for any keys referencing the old SID (look for profile paths with monika.wozniak)

    You can refer to below article for more information regarding the error message.

    Hope the above information is helpful!


Your answer

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