Skip to content

Demo buggy impersonation - impersonate doesn't work with SqlConnection

Notifications You must be signed in to change notification settings

ilanc/AspNetImpersonate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Impersonation on SqlConnection with .NET core

Provides a sample app which prints out the username of the current web app user and sql user.

Note you need to use different impersonation code in a .net core app vs .net core app which uses .net framework see HomeController.Index

See dotnet/aspnetcore#1805

How to run

  • clone the repo
  • change appsettings.json - your DB connection
  • build
  • setup a site on your webserver with the following:
    • Sites
      • Authentication
        • Anonymous Authentication = Disabled
        • ASP.NET Impersonation = Enabled
        • Windows Authentication = Enabled
      • Connect as = Application user (pass through)
    • Application Pools
      • .NET CLR version = No Managed Code
      • Pipeline = Classic
  • publish to your web server
  • browse the site

How to setup impersonation from webapp to sql

Various out of date links:

Double hop / Impersonation

setspn –a iisaccountname HTTP/IAMLINVWEBDEV
setspn –a iisaccountname HTTP/IAMLINVWEBDEV.investecam.corp 

setspn -a sqlaccountname MSSQLSvc/host:instanceName
setspn -a sqlaccountname MSSQLSvc/host:<TCPPORT>
setspn -a sqlaccountname MSSQLSvc/host.domain.com:instanceName
setspn -a sqlaccountname MSSQLSvc/host.domain.com:<TCPPORT>
  • Run dsa.msc to run RSAT

About

Demo buggy impersonation - impersonate doesn't work with SqlConnection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published