2015-05-07 14 views
9

Ho riscontrato un problema durante l'accesso a un servizio Web con impersonato senza un utente specificato.La rappresentazione funziona solo quando un utente è specificato

Works: <identity impersonate="true" userName="DOMAIN\USERNAME" password="MyPassword" />

non funziona

<identity impersonate="true" /> 

Durante il debug ho usato il codice sottostante per verifiy il corretto del dominio e nome utente sono stati utilizzati, essi sono.

System.Security.Principal.WindowsIdentity.GetCurrent().Name; 

qui è più del mio web.config

<authentication mode="Windows" /> 
<identity impersonate="true" /> 
<authorization> 
    <allow users="*" /> 
    <deny users="?"/> 
</authorization> 

sto accedendo al prompt, immagine qui sotto enter image description here

Tutte le idee perché funzionerà solo quando ho specificare un utente nella web.config? Sto effettuando l'accesso con lo stesso Domain\Username e la password che inserisco nello <identity impersonate="true" userName="DOMAIN\USERNAME" password="MyPassword" />. Ho provato con più account e tutti funzionano quando ho messo le loro credenziali nel web.config ma nessuno di lavoro con l'identità impostata come <identity impersonate="true" /> e la registrazione in

EDIT Il server remoto ha restituito un errore:. (403) Forbidden . enter image description here

EDIT 2 Tutto funziona bene durante il debug e mentre colpisce il servizio sul server che contiene l'IIS è ospitato su, ho provato con più account e tutti lavorano. Tutto è sullo stesso dominio

+0

È disponibile l'autenticazione anonima in IIS? Prova a eseguire il debug di questo codice: 'System.Web.HttpContext.Current.User.Identity.Name' –

+0

Anonimo è attualmente disabilitato in IIS – joetinger

+0

Ho provato il codice che hai suggerito e sto ottenendo il DOMINIO \ username previsto. – joetinger

risposta

3

Nota il seguente testo da https://support.microsoft.com/en-us/kb/306158

Impersonate a Specific User for All the Requests of an ASP.NET Application

To impersonate a specific user for all the requests on all pages of an ASP.NET application, you can specify the userName and password attributes in the tag of the Web.config file for that application. For example: Note The identity of the process that impersonates a specific user on a thread must have the "Act as part of the operating system" privilege. By default, the Aspnet_wp.exe process runs under a computer account named ASPNET. However, this account does not have the required privileges to impersonate a specific user. You receive an error message if you try to impersonate a specific user. This information applies only to the .NET Framework 1.0. This privilege is not required for the .NET Framework 1.1.

To work around this problem, use one of the following methods: Grant the "Act as part of the operating system" privilege to the ASPNET account (the least privileged account).

Note Although you can use this method to work around the problem, Microsoft does not recommend this method. Change the account that the Aspnet_wp.exe process runs under to the System account in the configuration section of the Machine.config file.

Potreste installare il processo Aspnet_wp.exe per l'esecuzione come l'utente che si sta tentando di impersonare per ottenere i privilegi desiderati.

Questo è stato anche discusso in precedenza: How do you do Impersonation in .NET?

1

potrebbe essere il problema di autenticazione doppio hop NTLM. In breve, assicurati che gli SPN di Kerberos siano impostati correttamente in modo che vengano utilizzati al posto di NTLM. Questo post del blog MSDN ha una grande spiegazione.

http://blogs.msdn.com/b/besidethepoint/archive/2010/05/09/double-hop-authentication-why-ntlm-fails-and-kerberos-works.aspx

In alternativa, l'autenticazione di base o forme saranno anche ottenere quello che stai cercando di realizzare. Questo perché l'applicazione avrà le credenziali dell'utente e, se opportunamente configurata, può usarle per accedere alle risorse back-end.

Si potrebbe anche voler esaminare la delega Kerberos. È un modo per limitare il secondo salto a una sola risorsa tramite il suo SPN.

+0

grazie per la risposta. Non ho ancora avuto la possibilità di provare questo, ma dopo aver letto l'articolo sembra che potrebbe essere la risposta – joetinger

+0

Dopo aver letto questo su come impostare SPN https://support.microsoft.com/en-us/kb/929650 sarà questo set il pool di applicazioni per utilizzare il dominio/utente fornito ogni volta che si accede al sito? – joetinger

+0

No. Da un'impostazione di alto livello l'SPN è solo un modo per registrare una risorsa con un account. In questo caso stai registrando l'account utilizzato per il tuo sito web. In questo modo quando qualcuno autentica tramite Kerberos tale account può verificare/decodificare il ticket di servizio presentato dall'utente che richiede l'accesso. – user2320464