Is it possible to use signed-in windows user credentials to authenticate to web API?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I am implementing authentication for a command line client application that makes a web request to a web API. If I reason correctly, I can apply Azure Active Directory native app authentication scenario.



My concern here is that setting up Azure AD will require significant effort from the client app users on setting up AAD, plus they will have to work with interactive dialog. This gets even worse in case no human is present, as the service to service scenario is even more complicated.



Is it possible to instead rely on the credentials of the signed-in user of the client computer? Assume Windows-based client machine that is joined to a domain, say FooDomain. The server uses an OWIN-based self-host implementation, Katana.



Related questions:
OWIN Web API Windows Service - Windows Identity Impersonation










share|improve this question































    2















    I am implementing authentication for a command line client application that makes a web request to a web API. If I reason correctly, I can apply Azure Active Directory native app authentication scenario.



    My concern here is that setting up Azure AD will require significant effort from the client app users on setting up AAD, plus they will have to work with interactive dialog. This gets even worse in case no human is present, as the service to service scenario is even more complicated.



    Is it possible to instead rely on the credentials of the signed-in user of the client computer? Assume Windows-based client machine that is joined to a domain, say FooDomain. The server uses an OWIN-based self-host implementation, Katana.



    Related questions:
    OWIN Web API Windows Service - Windows Identity Impersonation










    share|improve this question



























      2












      2








      2








      I am implementing authentication for a command line client application that makes a web request to a web API. If I reason correctly, I can apply Azure Active Directory native app authentication scenario.



      My concern here is that setting up Azure AD will require significant effort from the client app users on setting up AAD, plus they will have to work with interactive dialog. This gets even worse in case no human is present, as the service to service scenario is even more complicated.



      Is it possible to instead rely on the credentials of the signed-in user of the client computer? Assume Windows-based client machine that is joined to a domain, say FooDomain. The server uses an OWIN-based self-host implementation, Katana.



      Related questions:
      OWIN Web API Windows Service - Windows Identity Impersonation










      share|improve this question
















      I am implementing authentication for a command line client application that makes a web request to a web API. If I reason correctly, I can apply Azure Active Directory native app authentication scenario.



      My concern here is that setting up Azure AD will require significant effort from the client app users on setting up AAD, plus they will have to work with interactive dialog. This gets even worse in case no human is present, as the service to service scenario is even more complicated.



      Is it possible to instead rely on the credentials of the signed-in user of the client computer? Assume Windows-based client machine that is joined to a domain, say FooDomain. The server uses an OWIN-based self-host implementation, Katana.



      Related questions:
      OWIN Web API Windows Service - Windows Identity Impersonation







      windows azure authentication azure-active-directory windows-authentication






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 '18 at 1:16







      Konrad Jamrozik

















      asked Nov 17 '18 at 1:11









      Konrad JamrozikKonrad Jamrozik

      1,31631938




      1,31631938
























          1 Answer
          1






          active

          oldest

          votes


















          2














          @Konrad Jamrozik. IF you are working on .NET and want to use the logged-in user in Windows domain joined (your case), and even AAD joined, my advice would be to use MSAL.NET with the Integrated Windows Authentication (IWA) override. See https://aka.ms/msal-net-iwa. The simplified code looks like this:



          string authority = "https://login.microsoftonline.com/contoso.com";
          string scopes = new string { "user.read" };
          PublicClientApplication app = new PublicClientApplication(clientId, authority);
          var accounts = await app.GetAccountsAsync();

          AuthenticationResult result=null;
          if (accounts.Any())
          {
          result = await app.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
          }
          else
          {
          result = await app.AcquireTokenByIntegratedWindowsAuthAsync(scopes);
          }


          This sample explains how to register the app and provides all the details about the code: https://github.com/azure-samples/active-directory-dotnet-iwa-v2






          share|improve this answer
























          • Thank you Jean-Marc, that is what I was looking for!

            – Konrad Jamrozik
            Nov 20 '18 at 23:53












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347292%2fis-it-possible-to-use-signed-in-windows-user-credentials-to-authenticate-to-web%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          @Konrad Jamrozik. IF you are working on .NET and want to use the logged-in user in Windows domain joined (your case), and even AAD joined, my advice would be to use MSAL.NET with the Integrated Windows Authentication (IWA) override. See https://aka.ms/msal-net-iwa. The simplified code looks like this:



          string authority = "https://login.microsoftonline.com/contoso.com";
          string scopes = new string { "user.read" };
          PublicClientApplication app = new PublicClientApplication(clientId, authority);
          var accounts = await app.GetAccountsAsync();

          AuthenticationResult result=null;
          if (accounts.Any())
          {
          result = await app.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
          }
          else
          {
          result = await app.AcquireTokenByIntegratedWindowsAuthAsync(scopes);
          }


          This sample explains how to register the app and provides all the details about the code: https://github.com/azure-samples/active-directory-dotnet-iwa-v2






          share|improve this answer
























          • Thank you Jean-Marc, that is what I was looking for!

            – Konrad Jamrozik
            Nov 20 '18 at 23:53
















          2














          @Konrad Jamrozik. IF you are working on .NET and want to use the logged-in user in Windows domain joined (your case), and even AAD joined, my advice would be to use MSAL.NET with the Integrated Windows Authentication (IWA) override. See https://aka.ms/msal-net-iwa. The simplified code looks like this:



          string authority = "https://login.microsoftonline.com/contoso.com";
          string scopes = new string { "user.read" };
          PublicClientApplication app = new PublicClientApplication(clientId, authority);
          var accounts = await app.GetAccountsAsync();

          AuthenticationResult result=null;
          if (accounts.Any())
          {
          result = await app.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
          }
          else
          {
          result = await app.AcquireTokenByIntegratedWindowsAuthAsync(scopes);
          }


          This sample explains how to register the app and provides all the details about the code: https://github.com/azure-samples/active-directory-dotnet-iwa-v2






          share|improve this answer
























          • Thank you Jean-Marc, that is what I was looking for!

            – Konrad Jamrozik
            Nov 20 '18 at 23:53














          2












          2








          2







          @Konrad Jamrozik. IF you are working on .NET and want to use the logged-in user in Windows domain joined (your case), and even AAD joined, my advice would be to use MSAL.NET with the Integrated Windows Authentication (IWA) override. See https://aka.ms/msal-net-iwa. The simplified code looks like this:



          string authority = "https://login.microsoftonline.com/contoso.com";
          string scopes = new string { "user.read" };
          PublicClientApplication app = new PublicClientApplication(clientId, authority);
          var accounts = await app.GetAccountsAsync();

          AuthenticationResult result=null;
          if (accounts.Any())
          {
          result = await app.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
          }
          else
          {
          result = await app.AcquireTokenByIntegratedWindowsAuthAsync(scopes);
          }


          This sample explains how to register the app and provides all the details about the code: https://github.com/azure-samples/active-directory-dotnet-iwa-v2






          share|improve this answer













          @Konrad Jamrozik. IF you are working on .NET and want to use the logged-in user in Windows domain joined (your case), and even AAD joined, my advice would be to use MSAL.NET with the Integrated Windows Authentication (IWA) override. See https://aka.ms/msal-net-iwa. The simplified code looks like this:



          string authority = "https://login.microsoftonline.com/contoso.com";
          string scopes = new string { "user.read" };
          PublicClientApplication app = new PublicClientApplication(clientId, authority);
          var accounts = await app.GetAccountsAsync();

          AuthenticationResult result=null;
          if (accounts.Any())
          {
          result = await app.AcquireTokenSilentAsync(scopes, accounts.FirstOrDefault());
          }
          else
          {
          result = await app.AcquireTokenByIntegratedWindowsAuthAsync(scopes);
          }


          This sample explains how to register the app and provides all the details about the code: https://github.com/azure-samples/active-directory-dotnet-iwa-v2







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 17 '18 at 7:38









          Jean-Marc PrieurJean-Marc Prieur

          83547




          83547













          • Thank you Jean-Marc, that is what I was looking for!

            – Konrad Jamrozik
            Nov 20 '18 at 23:53



















          • Thank you Jean-Marc, that is what I was looking for!

            – Konrad Jamrozik
            Nov 20 '18 at 23:53

















          Thank you Jean-Marc, that is what I was looking for!

          – Konrad Jamrozik
          Nov 20 '18 at 23:53





          Thank you Jean-Marc, that is what I was looking for!

          – Konrad Jamrozik
          Nov 20 '18 at 23:53




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347292%2fis-it-possible-to-use-signed-in-windows-user-credentials-to-authenticate-to-web%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine