Visual Studio Requests Login Multiple Times and is failing on most of them!

Is Visual Studio asking you to login multiple times, but only the first seems to have succeeded? Read more to find out why...

I'm using Visual Studio 2022, but I suspect this will apply to any versions that use Active Directory to login.

Vs2022 must've updated since I used it yesterday, because it popped up saying it was more secure than ever so I need to login again. Great, that's easy to do (or so I thought).

Up pops the AD window with my normal work login details, and I login using my Microsoft authenticator app. But wait, it's now popped up again using my Microsoft account again but no longer is sending me a push to Microsoft Authenticator, and is not taking the 6 digit code either. Very confusing. What is going on???

To cut a long story short, I have been added to several customer's Azure tenants over the years, and due to their poor hygiene have not been removed. I cannot "Leave" myself because I need to login using their credentials and 2FA which I no longer have!

How to fix?

The first login was my primary work account, which succeeded. All subsequent logins (in my case I had five) I could just cancel.

To stop this happening, In Visual Studio we need to deselect these accounts I no longer use.

On the File menu, choose Account Settings

Image showing the File menu choice, and then selecting Account Settings

On this screen it is showing I'm not logged in, but if you had a successful login then it will be logged in already.

Image shows the Visual Studio accounts screen, in an un-logged in state.

Interestingly, when I clicked the Sign-In button it only asked for credentials once (for my primary identity). I am now logged in...

Image showing that I am logged in

Next we need to Apply a filter to all the obsolete accounts so it will not prompt to login again.

You can see that by default it has checked against every tenant I'm added to. I just need to deselect the one's I'm no longer interested in and that's it.

If you maintain an Active Directory, you should automate account cleanup (e.g. when users depart the company or inactive for a while). You may want to look into Microsoft purview Insider Risk activities too https://learn.microsoft.com/en-us/purview/insider-risk-management-activities