4

I want to build Azure admin app and i need to log in to my Azure account. The problem is that i want to do it in interactive way like in Powershell Login-AzAccount command. I don't want to register AzureAD app like in many tutorials in the web.

enter image description here

Is there any way to achieve it?

I've done it using .net library for Powershell.

        using (PowerShellExec commander = new PowerShellExec())
        {
            response = commander.RunCommand("Login-AzAccount");
        }

But is there any way to do it without powershell?

  • 2
    Why do not you register your admin app as an application in Azure AD ? That way, Azure AD itself will show this login popup. You can add policies to check role (to check if current user is admin then only authentication is successful ) – Manoj Choudhari Mar 15 '19 at 10:56
  • For some reason i need to use login and password without registered AD app. – Konrad Śledziewski Mar 15 '19 at 11:11
  • If you are building an admin app and want to authenticate users against Azure AD, then registering it with Azure AD is a must from security standpoint.. I have answered a very similar question before here - https://stackoverflow.com/questions/54189040/c-sharp-console-app-azuread-how-to-mimic-powershells-get-azureaduser/54189977#54189977 – Rohit Saigal Mar 15 '19 at 11:18
  • PowerShell itself also uses an `appId:"1b730954-1685-4b74-9bfd-dac224a7b894"`. So my guess is that there would be a multi-tenant application registered to represent PowerShell as well.. we just don't see it in the regular interfaces/api's. Broader point still being, everything that works with Azure AD to authenticate and query information should have a registered application. – Rohit Saigal Mar 15 '19 at 11:19
  • So, is there any possibility to get information about that app? – Konrad Śledziewski Mar 15 '19 at 16:29

1 Answers1

0

Yes.

PowerShell uses ADAL - Active Directory Authentication Library.

There are all sorts of samples on the official ADAL Site.

And please do not even try the app id for PowerShell. It will not work for you. You have to register your own application. Follow the tutorial here.

astaykov
  • 30,768
  • 3
  • 70
  • 86