Impersonating windows identity for Test Project - c#

I am using Windows Authentication of a specific account (not mine) to connect to database, for this, I've made changes in my web application's app domain's identity to that specific account and it works fine.
Database does not allow any other identity.
For the same web application I have a Visual Studio Test Project, the connection string in Test Project should also be authenticated for that specific account.
How can I do this?
I've tried impersonation but it did not work for test project

Related

Website stopped working after we changed the connection string from sspi to azure active directory integrated

Our Website uses Windows Authentication for both UI and SQL, we are now migrating to Azure. Our On-Prem Active Directory is already federated to Azure Active Directory. we created a new VM and hosted our site and it worked.
Now we migrated our SQL databases to SQL Managed instance on Azure and used the connection string for managed instance in our site's web config. the same setup is working when we debugged the site from visual studio.
IIS is throwing a error stating
could not discover a user realm
however we have added our VM to domain and website is working fine when run from IIS Express.
I compared configuration files to see if there any are any differences.
When I run the same site which has managed instance connection string on IIS Express, it is working as expected. But it is not working from IIS.

Web Deploy to IIS fails. Why?

I am trying to deploy a .net core c# app to an IIS running on Windows Server 2016. I created a publish profile. I click on Validate Connection button and get the following error, that I need to install Web Deploy and that Web Management Service should be started:
I did install Web Deploy 3.6 and the Web Management Service is definitely running.
Here is my profile. The Site Name is AppPool\WebSiteName. User name is the same as I logged in on the server with.
What am I missing?
Figured out the problem. The Server entry needs to have the protocol. So http://winserver instead of just the name of the box.

Windows Azure: Register Application to Azure Active Directory

Following is the scenario which works differently in windows azure,
Scenario 1:
Create web app from visual studio using Azure AD authentication setup.
Application works fine. Authentication is successful.
Scenario 2
Manually add application to Azure Active directory
Update the configuration related to new application register in Active directory and try to authenticate the application.
In the Scenario 2, Getting error that "Application with identifier XXXX not found in the directory XXXXX"
Based on the error message, it should be that either you using the incorrect application id or the tenant. Please ensure the app you config in the project is on the tenant you were using.
Microsoft also provides lots of code sample to help developer get started with developing Azure AD. You may refer here which contains the detail steps for register and config apps manually.

How can I authenticate a web application running PaaS in Azure against Visual Studio Online

I'm creating a web app for my company that I want to provide extra functionality for Visual Studio Team Services that's very business specific. We have some custom rules about how we want to setup and manage Work Items in Visual Studio Team Services. Is there I way that I can use delegated authentication with Azure Active Directory so that my web app can authenticate the user against Visual Studio Team Services and make calls and setup work items on the user's behalf ?
To authenticate with Azure Active Directory, refer to this link for details: Use Active Directory for authentication in Azure App Service. But this only works when your VSTS accounts are backed by Azure Active Directory.
If your VSTS accounts are not backed by Azure Active Directory, I would recommend you to use OAuth 2.0 to authorize with Visual Studio Team Service.

Consuming Windows Authenticated Service for Client Development in Visual Studio

I have a service hosted in server. The service authentication is using Windows Authentication. I want to use this service in my website development in Visual Studio 2010. When I try to add a reference it says the following error.
“Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service.”
What should I do to overcome it and be able to consume the service for development?
Note: The error message is obvious. What I am looking for is the best way to overcome this.
Note: When I type the service address in Mozilla Firefox, it asks for my windows credentials -upon entering credentials it gives me the service descriptions. The problem is when I use it via Visual Studio.
If I understand you correctly, your service is already running happily and using Windows Authentication, so it requires the calling application, your web site to also be using Windows Authentication.
When you try and add a reference, VS will start your site in the background using whichever web server is defined in Project Properties. You say that you are starting your site using the built-in web server (also known as Cassini or Webdev). You need to ensure that your site is using Windows Authentication. You do this from the service's Project Properties (right-click on the root folder and select Properties). In there you will see a Web tab which has an NTLM Authentication checkbox - make sure that is checked.
Also, make sure that you use:
<system.web>
<authentication mode="Windows">
...
in your web.config.
However, if you want to use IIS itself, I assume you have it installed and know how to define a web application. Depending on which version of Windows you are running, you may or may not have IIS installed or it may not be installable (using Programs and Features from Control Panel). If you don't have IIS, you can install IIS Express from here: http://learn.iis.net/page.aspx/868/iis-express-overview/
After you have installed IIS and defined your application root, and pointed the directory to your local source folder, enable Windows (NTLM) Authentication for that web app/site. How you do that depends on which version of IIS you are running but it is normally by clicking on the Authentication icon. You probably need to disable Anonymous as well as enable Windows Authentication, so that all requests are forced into Windows authentication. For browsers that do not support automatic NTLM authentication, I also turn on Basic Forms authentication as well.
Once you have an IIS application defined, you can use that for debugging from Visual Studio instead of the built-in web server. You also do that from Project Properties by choosing 'Use Local IIS Server' and selecting the Url of the IIS site you created above. Alternatively, VS can create the IIS site definition for you if it doesn't yet exist.
Either of the above methods should ensure that when VS starts your site to add a reference, it will be using authentication, as well as at runtime. Note that you can add a reference manually, without the need for starting the site. Then you just need to make sure you have Windows authentication at runtime, as described above.

Categories

Resources