on premise integrated windows authentication get access token












0














We have a Azure Passthrough setup i.e Azure authentication is done on premise AD.



Here we have a on premise MVC application hosted in IIS which needs to consume application services hosted in azure. for this we have registered the application in azure ad as native and mapped the permissions to the services.



The hosted on premise application uses Integrated Windows authentication.
we are able to get the access token by using the below code from visual studio debug mode i.e running on IIS Express.



var clientId = "XXXX-XXXX-XXXX-XXXX-XXXX";

string authority = "https://login.microsoftonline.com/XXXX-XXXX-XXXX-XXXX-XXXX/oauth2/authorize";

string resource = "https://ourdomain.sharepoint.com"; ///put id or url of resource you're accessing

AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);

UserCredential uc = new UserCredential(); // By passing empty means windows Authentication

AuthenticationResult token = null;

return authenticationContext.AcquireTokenAsync(resource, clientId, uc).Result;


But once deployed in IIS and running app pool with service account. we are receiving access token for the service account instead need to receive access token based on the user authenticated.










share|improve this question
























  • Have you checked the guide and accompanying github sample? github.com/AzureAD/azure-activedirectory-library-for-dotnet/…
    – Marilee Turscak - MSFT
    Jan 2 at 21:06










  • i have checked, the sample is for desktop app ..but my application is web application running on premise and is already using integrated windows authentication. When trying to get the access token from azure using above code it gets token based on the application pools service account.. need to get the access token for windows authenticated user
    – user1014275
    Jan 3 at 6:04
















0














We have a Azure Passthrough setup i.e Azure authentication is done on premise AD.



Here we have a on premise MVC application hosted in IIS which needs to consume application services hosted in azure. for this we have registered the application in azure ad as native and mapped the permissions to the services.



The hosted on premise application uses Integrated Windows authentication.
we are able to get the access token by using the below code from visual studio debug mode i.e running on IIS Express.



var clientId = "XXXX-XXXX-XXXX-XXXX-XXXX";

string authority = "https://login.microsoftonline.com/XXXX-XXXX-XXXX-XXXX-XXXX/oauth2/authorize";

string resource = "https://ourdomain.sharepoint.com"; ///put id or url of resource you're accessing

AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);

UserCredential uc = new UserCredential(); // By passing empty means windows Authentication

AuthenticationResult token = null;

return authenticationContext.AcquireTokenAsync(resource, clientId, uc).Result;


But once deployed in IIS and running app pool with service account. we are receiving access token for the service account instead need to receive access token based on the user authenticated.










share|improve this question
























  • Have you checked the guide and accompanying github sample? github.com/AzureAD/azure-activedirectory-library-for-dotnet/…
    – Marilee Turscak - MSFT
    Jan 2 at 21:06










  • i have checked, the sample is for desktop app ..but my application is web application running on premise and is already using integrated windows authentication. When trying to get the access token from azure using above code it gets token based on the application pools service account.. need to get the access token for windows authenticated user
    – user1014275
    Jan 3 at 6:04














0












0








0







We have a Azure Passthrough setup i.e Azure authentication is done on premise AD.



Here we have a on premise MVC application hosted in IIS which needs to consume application services hosted in azure. for this we have registered the application in azure ad as native and mapped the permissions to the services.



The hosted on premise application uses Integrated Windows authentication.
we are able to get the access token by using the below code from visual studio debug mode i.e running on IIS Express.



var clientId = "XXXX-XXXX-XXXX-XXXX-XXXX";

string authority = "https://login.microsoftonline.com/XXXX-XXXX-XXXX-XXXX-XXXX/oauth2/authorize";

string resource = "https://ourdomain.sharepoint.com"; ///put id or url of resource you're accessing

AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);

UserCredential uc = new UserCredential(); // By passing empty means windows Authentication

AuthenticationResult token = null;

return authenticationContext.AcquireTokenAsync(resource, clientId, uc).Result;


But once deployed in IIS and running app pool with service account. we are receiving access token for the service account instead need to receive access token based on the user authenticated.










share|improve this question















We have a Azure Passthrough setup i.e Azure authentication is done on premise AD.



Here we have a on premise MVC application hosted in IIS which needs to consume application services hosted in azure. for this we have registered the application in azure ad as native and mapped the permissions to the services.



The hosted on premise application uses Integrated Windows authentication.
we are able to get the access token by using the below code from visual studio debug mode i.e running on IIS Express.



var clientId = "XXXX-XXXX-XXXX-XXXX-XXXX";

string authority = "https://login.microsoftonline.com/XXXX-XXXX-XXXX-XXXX-XXXX/oauth2/authorize";

string resource = "https://ourdomain.sharepoint.com"; ///put id or url of resource you're accessing

AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);

UserCredential uc = new UserCredential(); // By passing empty means windows Authentication

AuthenticationResult token = null;

return authenticationContext.AcquireTokenAsync(resource, clientId, uc).Result;


But once deployed in IIS and running app pool with service account. we are receiving access token for the service account instead need to receive access token based on the user authenticated.







azure-active-directory adal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 6:17









Joy Wang

6,3952212




6,3952212










asked Dec 28 '18 at 5:59









user1014275user1014275

156




156












  • Have you checked the guide and accompanying github sample? github.com/AzureAD/azure-activedirectory-library-for-dotnet/…
    – Marilee Turscak - MSFT
    Jan 2 at 21:06










  • i have checked, the sample is for desktop app ..but my application is web application running on premise and is already using integrated windows authentication. When trying to get the access token from azure using above code it gets token based on the application pools service account.. need to get the access token for windows authenticated user
    – user1014275
    Jan 3 at 6:04


















  • Have you checked the guide and accompanying github sample? github.com/AzureAD/azure-activedirectory-library-for-dotnet/…
    – Marilee Turscak - MSFT
    Jan 2 at 21:06










  • i have checked, the sample is for desktop app ..but my application is web application running on premise and is already using integrated windows authentication. When trying to get the access token from azure using above code it gets token based on the application pools service account.. need to get the access token for windows authenticated user
    – user1014275
    Jan 3 at 6:04
















Have you checked the guide and accompanying github sample? github.com/AzureAD/azure-activedirectory-library-for-dotnet/…
– Marilee Turscak - MSFT
Jan 2 at 21:06




Have you checked the guide and accompanying github sample? github.com/AzureAD/azure-activedirectory-library-for-dotnet/…
– Marilee Turscak - MSFT
Jan 2 at 21:06












i have checked, the sample is for desktop app ..but my application is web application running on premise and is already using integrated windows authentication. When trying to get the access token from azure using above code it gets token based on the application pools service account.. need to get the access token for windows authenticated user
– user1014275
Jan 3 at 6:04




i have checked, the sample is for desktop app ..but my application is web application running on premise and is already using integrated windows authentication. When trying to get the access token from azure using above code it gets token based on the application pools service account.. need to get the access token for windows authenticated user
– user1014275
Jan 3 at 6:04












0






active

oldest

votes











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%2f53954276%2fon-premise-integrated-windows-authentication-get-access-token%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53954276%2fon-premise-integrated-windows-authentication-get-access-token%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

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas